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

Slavic characters are replaced by ■ #792

Open
Netvia opened this issue Jan 16, 2025 · 0 comments
Open

Slavic characters are replaced by ■ #792

Netvia opened this issue Jan 16, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Netvia
Copy link

Netvia commented Jan 16, 2025

Describe the Bug

Slavic characters are replaced by ■. Standard Arial font knows this letters, where should be an error?

pdf is created with unreadable chars. I also tried updated this html (with file "arial.ttf" in the same directory), but there is the same ouptut:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
            <title>My HTML Document</title>
            <style>
                @font-face {
                    font-family: Arial;
                    src: url('/arial.ttf');
                }
                *{
                    font-family: Arial;
                    color: red;
                    }
            </style
        </head>
    <body>
        <h1>+ěščřžýáíéí</h1>
    </body>
</html>

Minimal Example to Reproduce

file input.html :

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
            <title>My HTML Document</title>
            <style>
                *{
                    font-family: Arial;
                    color: red;
                    }
            </style
        </head>
    <body>
        <h1>+ěščřžýáíéí</h1>
    </body>
</html>

python code (utf-8 enconding too):

  OUT = "output.pdf"
  IN = "input.html"

  from xhtml2pdf import pisa
  with open(IN, 'r', encoding='utf-8') as html_file:
      html_content = html_file.read()

  with open(OUT, 'wb') as pdf_file:
      pisa_status = pisa.CreatePDF(html_content, dest=pdf_file, encoding='utf-8')

  if pisa_status.err:
      return False

Expected Behavior

+ěščřžýáíéí

Actual Behavior

+■š■■žýáíéí

System Information

OS version: Windows 11 24H2
Python version: 3.13.0, also on 3.10.7
XHTML2PDF version: 0.2.16

@Netvia Netvia added the bug Something isn't working label Jan 16, 2025
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

1 participant