We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Help requested creating a document from a template

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”);
if(folders.hasnext()) {

I hope I explained this clearly. Files are attached. My test java is under the “src” folder.

Thank you

Hi Matthew,

Thanks for your request. Your pseudo-code is correct. You should simply use insertDocument method to insert your source documents at bookmarks in your template. You can find an example how to achieve this in the following article:


Then, you can use appendDocument method to append the generated document to the master document:


Hope this helps.

Best regards,

Thanks Alexey! Are there any plans to create some helper classes with static methods for operations like this?

Hi Matthew,

Thanks for your inquiry.

Yes, we do have plans to incorporate the InsertDocument functionality into the Aspose.Words API. I have linked your request to the appropriate issue, we will inform you as soon as it’s resolved.

Regarding the second example Alexey provided, that method is already part of the Aspose.Words API.


The issues you have found earlier (filed as WORDSNET-5251) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.