0

Hope someone can help me. It's about docx to pdf conversion having korean sign in docx document. I'm able to convert a docx document to pdf with docx4j.

In pdf document, I can see the result. But if my docx document contains korean font, I can't see any korean font in my pdf document except the latin numbers. What do I have to do to get korean font in my pdf from the docx document?

Here is my code:

File docXFile ="E:/contract2Files/test.docx";
WordprocessingMLPackage wordprocessingMLPackage = WordprocessingMLPackage.load(docXFile);
String   out = docXFile .replace("docx","pdf");
File pdfFile = new File(out);
OutputStream pdfFileOs = new java.io.FileOutputStream(pdfFile);
org.docx4j.convert.out.pdf.PdfConversion c = new JanoPdfConversion(wordprocessingMLPackage);
c.output(pdfFileOs);
duracell
  • 644
  • 8
  • 13

2 Answers2

1

Please try http://www.docx4java.org/docx4j/docx4j-3_0-beta2.zip (link updated 15 Nov)

You might need to configure your font mapper, though things work out of the box with the Identity mapper on my Windows box, since I have the relevant font installed.

If this doesn't help, please put a sample docx somewhere StackOverflow users can see it.

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84
  • Hello Jason,thank for your time. How can I put my korean docx document in stackoverflow so you can have a look at it? – duracell Oct 22 '13 at 11:41
  • Hello again. there must be a possibility to tell docx, that the encoding shoulb be korean, or so? it that the right approach? – duracell Oct 22 '13 at 11:45
  • See http://meta.stackexchange.com/questions/47689/how-can-i-attach-a-file-to-a-stack-overflow-post – JasonPlutext Oct 22 '13 at 19:56
  • Encoding etc should already be taken care of. Unzip the docx, and look at document.xml to see. – JasonPlutext Oct 22 '13 at 19:57
  • Hi Jason, here can you download my generated docx http://www.janolaw.de/export/livingwill.docx and here is my generated pdf from docx http://www.janolaw.de/export/livingwill.pdf THANKS – duracell Oct 23 '13 at 08:03
  • Jason, can you please tell me the verion of the jar you recommanded ? http://www.docx4java.org/docx4j/docx4j-nightly-20131008.jar ?? – duracell Oct 23 '13 at 12:39
0

thanks again. I tried the newest jar file with this code passage and it worked!!! Now I get the korean letters into pdf. Thank again.

ThemePart themePart = wordprocessingMLPackage.getMainDocumentPart().getThemePart(); org.docx4j.dml.BaseStyles.FontScheme fontScheme = themePart.getFontScheme(); org.docx4j.dml.TextFont textFont = fontScheme.getMinorFont().getLatin(); textFont.setTypeface("Malgun Gothic");

duracell
  • 644
  • 8
  • 13