Hi,
I'm trying to use template with docx4j but my output file seems to be corrupt and then the PDF file is created with many empty spaces...
I'm using Word from Mac is it the issue ?
Thanks for answering !
public static void convert(String inputfilepath) {
try {
//String inputfilepath = System.getProperty("user.dir") + "/simpleDoc.docx";
WordprocessingMLPackage wordMLPackage;
if (inputfilepath==null) {
System.out.println("No imput path passed, creating dummy document");
wordMLPackage = WordprocessingMLPackage.createPackage();
// SampleDocument.createContent(wordMLPackage.getMainDocumentPart());
} else {
System.out.println("Loading file from " + inputfilepath);
wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath));
}
Mapper fontMapper = new IdentityPlusMapper();
PhysicalFont font = PhysicalFonts.get("Comic Sans MS");
//fontMapper.put("Algerian", font);
wordMLPackage.setFontMapper(fontMapper);
FOSettings foSettings = Docx4J.createFOSettings();
foSettings.setWmlPackage(wordMLPackage);
String outputfilepath;
if (inputfilepath==null) {
outputfilepath = System.getProperty("user.dir") + "/simpleDoc.pdf";
} else {
outputfilepath = inputfilepath + ".pdf";
}
OutputStream os = new java.io.FileOutputStream(outputfilepath);
Docx4J.toFO(foSettings, os, Docx4J.FLAG_NONE);
} catch (Exception e) {
e.printStackTrace();
}
}
Users browsing this forum: No registered users and 125 guests