I'm trying to convert a docx-file to PDF. The docx-file contains a number of custom document properties and these are used throughout the document. The problem is that the properties values vanishes when I convert the document to PDF.
The code I'm currently using to convert to PDF is the following
- Code: Select all
public InputStream toPDF(InputStream is) throws DocumentProcessorException {
WordprocessingMLPackage doc;
try {
doc = WordprocessingMLPackage.load(is);
} catch (Docx4JException ex) {
throw new DocumentProcessorException(ex);
}
FOSettings foSettings = Docx4J.createFOSettings();
foSettings.setWmlPackage(doc);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
Docx4J.toFO(foSettings, baos, Docx4J.FLAG_EXPORT_PREFER_XSL);
} catch (Docx4JException ex) {
throw new DocumentProcessorException(ex);
}
byte[] ba = baos.toByteArray();
try {
baos.close();
} catch (IOException ex) {
throw new DocumentProcessorException(ex);
}
return new ByteArrayInputStream(ba);
}
I'm not expecting the properties themselves to be transferred to the PDF, but I am expecting the values to show up as ordinary text in the PDF.
Is there something other then the above I need to do to archieve this?