I am trying to write a code using that PDF can be generated for different languages. Its working for most of the language like (english ,japanese ,korean ,chinese) but for arabic language text is appearing as "?" .This is git HTML TO PDF converted code link of code. Could you please suggest what i am missing and how it can be corrected . I am using PD4ML library for HTML to PDF generation.
Asked
Active
Viewed 445 times
1
-
In your test why do you make this for AB `PDFDoc pdf = PDFDocFactory.getPDFDoc("test_ab.pdf", new String(AB_HTML_CODE.getBytes()));` ? – MadaManu Jan 07 '20 at 04:40
-
Is the encoding set to UTF-8 ? – Maxdola Jan 07 '20 at 04:46
-
@MadaManu - Initially i simply tried passing html content as string but it didn't worked . So i thought of converting it into byte then string but that also didn't helped – vikash srivastava Jan 07 '20 at 05:23
-
@Maxdola - Yes for arabic i have set encoding to UTF-8 , ISO_8859_1 and even i have tried other encoding as well but its not working – vikash srivastava Jan 07 '20 at 05:24
-
Where did you set the encoding ? Did you set it in the pom ? – Maxdola Jan 07 '20 at 07:10
-
@Maxdola - I am setting it there in java code itself https://github.com/vikas101786/htmlToPdf/blob/master/src/main/java/pdf/HTMLPDFDocTest.java#L51 – vikash srivastava Jan 07 '20 at 07:44
3 Answers
1
Earlier versions of PD4ML was not supporting RTL . You can refer this doc https://pd4ml.com/support/html-css-to-pdf-rendering-issues-f3/direction-rtl-not-working-t284.html. Recent versions of PD4ML supports RTL . Please , refer below link https://pd4ml.com/relnotes.htm .

vikash srivastava
- 393
- 2
- 4
- 16
0
public void setEncoding(String encoding) {
if (encoding != null && !encoding.equals("iso-8859-1")) {
this.encoding = encoding;
}
}
Change setEncoding method as
public void setEncoding(String encoding) {
if (encoding != null && !encoding.equals("utf-8")) {
this.encoding = encoding;
}
}

Xihar
- 103
- 1
- 12
-
Its not resolving the issue . Even i am not sure how by just checking for UTF-8 can resolve the issue. – vikash srivastava Jan 07 '20 at 05:45
0
Try adding the encoding to your pom.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Maxdola
- 1,562
- 2
- 10
- 29
-
I added it in pom . but still its same , is it working for you ? – vikash srivastava Jan 09 '20 at 05:13