pyfpdf icon indicating copy to clipboard operation
pyfpdf copied to clipboard

unescape() not supported and not required as of python 3.9 onwards

Open asafravid opened this issue 3 years ago • 5 comments

unescape() not supported and not required as of python 3.9 onwards

asafravid avatar Nov 14 '21 11:11 asafravid

Any update on merging this ? Using python 3.9 code I had this specific issue:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/home/meyer/code-project/HistoQuant/zc_Unet.ipynb Cell 16' in <cell line: 66>()
     63 print('Number of validation steps: '+str(validation_steps))
     64 print('---------------------------- ------------------------ ----------------------------')
---> 66 pdf_export(augmentation = Use_Data_augmentation, pretrained_model = Use_pretrained_model)

/home/meyer/code-project/HistoQuant/zc_Unet.ipynb Cell 6' in pdf_export(trained, augmentation, pretrained_model)
     91 pdf.ln(1)
     92 html = """ 
     93 <table width=40% style="margin-left:0px;">
     94   <tr>
   (...)
    129 </table>
    130 """.format(number_of_epochs, str(patch_width)+'x'+str(patch_height), batch_size, number_of_steps, percentage_validation, initial_learning_rate, pooling_steps, min_fraction)
--> 131 pdf.write_html(html)
    133 #pdf.multi_cell(190, 5, txt = text_2, align='L')
    134 pdf.set_font("Arial", size = 11, style='B')

File ~/.cache/pypoetry/virtualenvs/histoquant-cknpwBRB-py3.9/lib/python3.9/site-packages/fpdf/html.py:400, in HTMLMixin.write_html(self, text, image_map)
    398 "Parse HTML and convert it to PDF"
    399 h2p = HTML2FPDF(self, image_map)
--> 400 text = h2p.unescape(text) # To deal with HTML entities
    401 h2p.feed(text)

AttributeError: 'HTML2FPDF' object has no attribute 'unescape'

lambda-science avatar May 31 '22 08:05 lambda-science

pyfpdf is not maintained anymore, have you tried using fpdf2? https://pyfpdf.github.io/fpdf2/

Lucas-C avatar Sep 29 '22 09:09 Lucas-C

pyfpdf is not maintained anymore, have you tried using fpdf2? https://pyfpdf.github.io/fpdf2/

I haven’t Any good?

asafravid avatar Sep 29 '22 09:09 asafravid

Any good?

Yes! Disclaimer: I am its maintainer 😊

Lucas-C avatar Sep 29 '22 12:09 Lucas-C

Cool I see it was forked from this repo. I'll try yours and see if I get the same issue there (to which the PR fix relates)

fpdf2 is a library for simple & fast PDF document generation in Python.
It is a fork and the successor of PyFPDF

(cf. history).

asafravid avatar Sep 29 '22 13:09 asafravid