My boss likes the document conversion (document.save(rtf/html/etc)) we were able to do with Aspose, but has asked that I do one more task with Aspose.
I’ll start by saying that I’m not a Word expert, but this seemed like the right approach.
We want to create a document from a template. In the template, I have created two bookmarks (“FromText” and “ToText”). For my test, I’m required to iterate a list (zero to n) of folders. Each folder will contain one file FROM.RTF and possibly one file TO.RTF.
I want to end up with something like pseudo:
Document doc = new Document("C:\xyz\doc.doc");
while (folders.hasnext())
{
File folder = folders.next();
Document from = new Document(folder.getfile("from.rtf"));
Document to = new Document(folder.getfile("to.rtf"));
Document template = new Document("C:\xyz\template.dotx");
template.setBookmarkContents("FromText", from);
template.setBookmarkContents("ToText", to);
doc.append(template);
if (folders.hasnext())
{
doc.appendPageBreak();
}
}
doc.save("C:\xyz\output.doc");
I hope I explained this clearly. Files are attached. My test java is under the “src” folder.
Thank you