Generate PDF using word doc template

Hi ,
Our business case is to generate PDF containing dynamic tables and text with xml(for table and text) and word template as inputs. We are facing difficulties in identifying an approach. Is there an api available which takes xml and a word document template as input to generate PDF ? or Please suggest an approach or APIs which can be used here.



Thanks for your inquiry. You can use MailMerge feature to generate PDF from Word Template, it supports XML data. Initially execute mail merge and then save output as PDF document. Please check following documentation links and examples link, hopefully it will help you to accomplish the task.

Please feel free to contact us for any further assistance.

Best Regards,


I am trying with the Mail merge. But I am not able to create table with data from XML. I tried with mail merge regions as well but not able to achieve desired output. I am attaching my code, input XML, input word template and the output file I am (22.5 KB)

Anusha Jain


Thanks for sharing your sample document. We are looking into it and will update you soon.

Best Regards,


Thanks for your patience. Please note your template is causing issue, field names and table names in the template and data should match. Please use executeWithRegions() method as following with updated template, it will help you to accomplish the task. Please find updated template and output file for reference.
TestFile (19.3 KB)

// Note that this class also works with a single repeatable region (and any nested regions).
// To merge multiple regions at the same time from a single XML data source, use the XmlMailMergeDataSet class.
doc.getMailMerge().executeWithRegions(new XmlMailMergeDataTable(xmlData,"customer"));
//doc.getMailMerge().execute(new XmlMailMergeDataTable(xmlData, "customer"));

Best Regards,