I'm trying to convert a docx file to pdf, docx is a template with header, text and pictures that has been edited through docx4j. This is the piece of code for conversion...
private static void wordClientToPDF() throws FileNotFoundException, IOException
{
try {
// 1) Load DOCX into WordprocessingMLPackage
InputStream is = new FileInputStream(new File(WORD_FILE_PATH_CLIENT));
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(is);
// 2) Prepare Pdf settings
PdfSettings pdfSettings = new PdfSettings();
// 3) Convert WordprocessingMLPackage to Pdf
OutputStream out = new FileOutputStream(new File(PDF_FILE_PATH_CLIENT));
PdfConversion converter = new org.docx4j.convert.out.pdf.viaXSLFO.Conversion(wordMLPackage);
converter.output(out, pdfSettings);
} catch (Throwable e) {
//YURY: print stack trace in message
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
sw.toString(); // stack trace as a string
javax.swing.JOptionPane.showMessageDialog(panel, "PDF conversion error: " + sw.toString());
}
}
However, I'm receiving the following error
Any help is appreciated.