pyfpdf icon indicating copy to clipboard operation
pyfpdf copied to clipboard

fpdf output string encoding

Open cdmckinnon opened this issue 5 years ago • 1 comments
trafficstars

I have created a pdf object using FPDF, and am trying to save to Microsoft Azure Blob storage.

I can save the FPDF-object fine locally using pdf.output('savename.pdf', 'F')

To store in Blob, it seems I need to convert the object to data. I have tried data_str = pdf.output('savename.pdf', 'S'), then upload data_str to Blob. This saves the PDF file, but it is blank (although the file size is the same as the full popularly pdf).

I am guessing this is an encoding issue, with which I have limited familiarity. What is the encoding of the string coming out of pdf.output('savename.pdf', 'S')? I can't find anywhere in the documentation.

Any guidance with this issue would be extremely helpful.

cdmckinnon avatar Jun 04 '20 13:06 cdmckinnon

I can answer for https://pypi.org/project/fpdf2/ : the encoding is latin-1

Lucas-C avatar Jan 09 '21 13:01 Lucas-C