-
Notifications
You must be signed in to change notification settings - Fork 249
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
writehtml Turkish Character Error #1281
Comments
Hi @mglnr I'd be happy to try to help you, but the information you provided is not precise enough to be able to solve your problem. Could you please provide some minimal code reproducing your problem: https://stackoverflow.com/help/minimal-reproducible-example Also, what do you mean by "The application does not open"? Do you get an error when running your Python script? Or is it that you cannot open the PDF file produced? At this point, I can only guess that the font file you provided (the "external Turkish character support") simply does not render the characters |
Thank you for your interest. When I type one of the characters "ğĞİÖÖÜÜ" and run my test application, the application closes without creating the pdf. When I use only the characters I specified, the situation I specified occurs. |
Do you have any error produced? If the call to If so, could you please share the stacktrace? Otherwise there is really not much I can do to help you... |
@mglnr Here is a small test I did showing fpdf2 can handle the characters if you are using a compatible font: from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.add_font(family="Noto", fname="NotoSans-Regular.ttf")
pdf.set_font("Noto", "", 16)
pdf.write_html("""
<h1>ğĞİÖÖÜÜ</h1>
""")
pdf.output("issue1281.pdf") I really don't know how to help you any further without specific information about your code and the error you are getting. |
I am sharing my test code below. I encounter an error when I use the characters ĞĞİÖÖÜÜ in the 14th line. My Test Code: from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.add_font("Times New Roman", "", "times.ttf", uni=True) # Normal font
pdf.add_font("Times New Roman", "B", "timesbd.ttf", uni=True) # Kalın font
pdf.write_html("""
<dl>
<dt>Description title</dt>
<dd>Description Detail</dd>
</dl>
<h1>Big title</h1>
<p align="justify"><b>deneme</b>
ğĞİÖÖüÜ deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme
deneme deneme deneme deneme deneme deneme deneme deneme
deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme
deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme deneme
</p>
<br>
<pre>i am preformatted text.</pre>
<br>
<blockquote>hello blockquote</blockquote>
<table width="50%" border="1">
<thead>
<tr>
<th width="30%">ID</th>
<th width="70%">Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Alice</td>
</tr>
<tr>
<td>2</td>
<td>Bob</td>
</tr>
</tbody>
</table>
""")
pdf.output("html.pdf")
input("pencereyi kapatma") `` |
Thank you for your interest. When I changed the family to times-roman in the code you gave, the Turkish characters worked, but when I wrote the html table code below it, it did not work. Sample code: from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.add_font(family="Times-Roman", fname="times.ttf")
pdf.set_font("Times-Roman", "", 12)
pdf.write_html("""
<p align="justify"> deneme deneme </p>
<table width="50%" border="1">
<thead>
<tr>
<th width="30%">ID</th>
<th width="70%">Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Alice</td>
</tr>
<tr>
<td>2</td>
<td>Bob</td>
</tr>
</tbody>
</table>
""")
pdf.output("html.pdf")
input("Pencereyi kapatma.") |
The default is table header being in bold and your code is failing because you didn't add a bold version of the font. Add this line and your code should run OK: pdf.add_font(family="Times-Roman", style="B", fname="timesbd.ttf") |
Thank you. I missed that detail. |
Hello,
I'm testing with writehtml at https://py-pdf.github.io/fpdf2/HTML.html. Unfortunately, I could not run the application when I used Turkish characters in my test. The application does not open when you type the characters "ğĞİÖÖüÜ". I added add_font with external Turkish character support, but the problem persists.
The text was updated successfully, but these errors were encountered: