Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font 'Verdana' not flowing correctly, When generate PDF #739

Open
Denny814 opened this issue Nov 14, 2023 · 4 comments
Open

Font 'Verdana' not flowing correctly, When generate PDF #739

Denny814 opened this issue Nov 14, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@Denny814
Copy link

  • 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.
Actual_Verdana_Font
xhtml2pdf_created_font

OS version:
Python version: 3.11.4
XHTML2PDF version: 0.2.13

@Denny814 Denny814 added the bug Something isn't working label Nov 14, 2023
@stefan6419846
Copy link
Contributor

Does this use the same reportlab version for both cases?

@Denny814
Copy link
Author

yes

@Denny814
Copy link
Author

Hi,
Any update on this?

@JanEgner
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants