HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML Forums › Technical questions / Troubleshooting › Korean font is not being applied
- This topic has 2 replies, 2 voices, and was last updated Apr 03, 2024
14:01:56 by PD4ML.
-
AuthorPosts
-
April 3, 2024 at 13:32#38052
Hello,
I’m using the PD4ML 4.0.19 demo version for testing purposes.
While Korean characters are displayed correctly in regular HTML text, Korean text that requires bold treatment, such as within <h2> or tags, is not appearing in the generated PDF.
Could you please let me know what might be wrong?
I will attach the resulting PDF and here is my source codeString doc = "<h2 style=\"border:1px solid #000\">ENG</h2>"+ "<h2 style=\"border:1px solid #000\">한글</h2>"+ "그냥 한글 텍스트\n"+ "<p style=\"font-weight: bold;\">bold eng, bold 한글</p>"; ByteArrayInputStream bais = new ByteArrayInputStream(doc.getBytes("UTF-8")); PD4ML pd4ml = new PD4ML(); pd4ml.useTTF("java:fonts", true); pd4ml.enableLigatures(true); pd4ml.setPageSize(PageSize.A4); pd4ml.setPageMargins(new PageMargins(top, right, left, bottom)); pd4ml.readHTML(bais); File pdf = new File("test.pdf"); FileOutputStream fos = new FileOutputStream(pdf); pd4ml.writePDF(fos);
April 3, 2024 at 13:34#38053Hello,
I’m using the PD4ML 4.0.19 demo version for testing purposes.
While Korean characters are displayed correctly in regular HTML text, Korean text that requires bold treatment, such as within <h2> or tags, is not appearing in the generated PDF.
Could you please let me know what might be wrong?
I will attach the resulting PDF and here is my source code
String doc = "<h2 style=\"border:1px solid #000\">ENG</h2>"+ "<h2 style=\"border:1px solid #000\">한글</h2>"+ "그냥 한글 텍스트\n"+ "<p style=\"font-weight: bold;\">bold eng, bold 한글</p>"; ByteArrayInputStream bais = new ByteArrayInputStream(doc.getBytes("UTF-8")); PD4ML pd4ml = new PD4ML(); pd4ml.useTTF("java:fonts", true); pd4ml.enableLigatures(true); pd4ml.setPageSize(PageSize.A4); pd4ml.setPageMargins(new PageMargins(top, right, left, bottom)); pd4ml.readHTML(bais); File pdf = new File("test.pdf"); FileOutputStream fos = new FileOutputStream(pdf); pd4ml.writePDF(fos);
Attachments:
You must be logged in to view attached files.April 3, 2024 at 14:01#38055Most probably you can fix the issue by an explicit specifying of a font face:
H2, BODY {font-family: Times New Roman, Batang, Serif}
Please find attached a test document, which uses no Batang, but only Arial Unicode MS as a fallback font. Arial Unicode MS has no bold version (the same as Batang), and you can see PD4ML successfully synthesizes bold font weight
Attachments:
You must be logged in to view attached files. -
AuthorPosts
You must be logged in to reply to this topic.