I am using Docx4J.toPDF(wordMLPackage, new FOS("path/to/file.pdf"))
in order to convert a ".docx"
file to ".pdf"
. Although the conversion is happening fine but the original document had Calibri font and the resultant pdf has Arial. Is there a way to set the font while doing this conversion.
It would be better if you could give some link to how font properties can be set in general like font size, font family etc, if there is facility for that.
I searched online but could not find any help on this. Waiting for your responses. Thanks!
I think that you will have to embend the Calibiri font (file) into the PDF. I am using Calibri in generated PDFs as well and this is what i had to do. I was using PDFe
I dont know how how to do this in docx4j
, but in case of iText(that I am using) I had to register the font like this
FontFactory.registerDirectory("./resources/fonts/", true);
com.itextpdf.text.Font iFont = FontFactory.getFont(font, getEncodingForFont(font), true);
and after this, iFont was automaticly embended into PDF so it can be displayed correctly on systems that does not have Calibri
installed.
This may be related to your issue http://www.docx4java.org/forums/docx-java-f6/embedded-fonts-not-used-in-pdf-conversion-t1137.html
And also there seems to be something into the canse on SO already: How to change font encoding when converting docx -> pdf with docx4j?