i have Mail Merge Fields in my Microsoft Word document and i am trying to generate PDF document.
Problem is that in generated PDF are Mail Merge fields displayed in a wrong way. In Word, you can switch between views by ALT+F9.
So for example i have mail merge field
1.view : <<ContractNo>>
2.view : {MERGEFIELD ContractNo \* MERGEFORMAT}
If i try only to open Dotx and save it to PDF without any changes, in PDF i always get Mail Merge Fields showed like MERGEFIELD ContractNo \* MERGEFORMAT.
I want to show values of merge files, i think they are in w:t elements.
I attached word template and pdf...
My Code>
- Code: Select all
InputStream is = new FileInputStream( new File( this.filename ) );
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(is);
// 2) Prepare Pdf settings
PdfSettings pdfSettings = new PdfSettings();
//String outfilename = this.filename.replace(this.extention,DocumentNo+"_"+timestamp+".pdf");
String outfilename = (table+"_"+DocumentNo+"_"+timestamp+".pdf");
// 3) Convert WordprocessingMLPackage to Pdf
OutputStream out = new FileOutputStream( new File( outfilename ) );
PdfConversion converter = new Conversion( wordMLPackage );
converter.output(out, pdfSettings);