You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using xhtml2pdf updated version 0.2.13 version. At the time of PDF generation the font 'Verdana' not showing correctly. The font look and feel has changed.
Below is my Python File:
with open(output_filename, 'wb') as output_file:
result = pisa.CreatePDF(
src=html_content,
dest=output_file,
)
if result.err:
print(f"PDF creation error: {result.err}")
else:
print("PDF created successfully")
Below is my html_content File:
<title></title>
<style>
body {
font-family: 'Verdana', sans-serif;
}
</style>
This is Verdana Font.
Quarter basis distribution.
I have attached file for Actual Verdana font look and feel and xhtml2pdf generated file.
1st is the ACtual Verdana Font and 2nd is the xhtml2pdf generated font.
OS version:
Python version: 3.11.4
XHTML2PDF version: 0.2.13
The text was updated successfully, but these errors were encountered:
@Denny814, am I right in guessing the first example was not generated by xhtml2pdf or reportlab, but by a browser?
The second example looks very much like it rendered using the default sans-serif font. That also makes sense, since Verdana is not a standard PDF font you will have to provide it to xhtml2pdf in form of a ttf file:
in the <head> section of your html file, add @font-face { font-family: "Verdana"; src: url('Verdana.ttf'); }
assuming the ttf file is in the current directory (you could also use an http(s) URL instead to download it from somewhere).
One non-technical reminder: it seems Verdana is not a "free" font, i.e. it is probably illegal to use it without a license unless you run the process on Windows. You might want to check if there's a free look-alike alternative.
Below is my Python File:
with open(output_filename, 'wb') as output_file:
result = pisa.CreatePDF(
src=html_content,
dest=output_file,
)
if result.err:
print(f"PDF creation error: {result.err}")
else:
print("PDF created successfully")
Below is my html_content File:
<title></title> <style> body { font-family: 'Verdana', sans-serif; } </style> This is Verdana Font. Quarter basis distribution.I have attached file for Actual Verdana font look and feel and xhtml2pdf generated file.
1st is the ACtual Verdana Font and 2nd is the xhtml2pdf generated font.
OS version:
Python version: 3.11.4
XHTML2PDF version: 0.2.13
The text was updated successfully, but these errors were encountered: