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

Free Support Forum - aspose.com

Use existing document as template for PDF generation?

Is it possible to use an existing document (like the one attached) and replace items with some kind of mail-merge-like token to replace in our web app? If it's possible, is it further possible to replace a list (like "Skills" in the attached document) with a collection of variables e.g. the document might have 15 skills, or it might have 30, and I want to display 4 per line with bullets in between? Similary, in the "Professional Experience & Achievements" section, each company, city, state, "Date to date", job title, description of responsibilities, and achievements (a collection) are a sub-template (not sure if that's the Aspose term.) How can I dynamically replace these if I have the data source ready?

Items that need replacing:
  • Fields like "FIRST" and "LAST" in the top header
  • "Summary"
  • "Skills" (arbitrary number)
  • "Achievement" bullets - this is also a collection per "JOB TITLE"

Thanks in advance,

Hi David,

Thanks for your inquiry. Yes, you can achieve your requirements using Aspose.Words. Please refer to the following article:

Find and Replace

In your case, we suggest you following solution.

1) Please implement IReplacingCallback interface.
2) In IReplacingCallback.Replacing, create an instance of DocumentBuilder class.
3) Move the cursor to the matched node.
4) Insert the contents according to your requirements.

Please check the code example shared in following link.
How to Find and Highlight Text

Does this handle the collections I mentioned? My template document includes some bullets that are collections of strings, and there’s no way of predetermining how many there will be–could be 0, could be 10. How can I dynamically replace, for example, maybe one bullet with a set of arbitrary size?

Hi David,

Thanks for your inquiry. Yes, you can achieve the requirements using the shared solution in my previous post.

If you still face problem, please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.