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

Free Support Forum - aspose.com

Fill dynamically row table from dotx template and generate pdf file

Hi,

I have to do the followings:

  • use a .dotx template with header, footer, table, all marked with bookmarks at placeholders that will be filled with data
  • fill with data the header and the table
  • generate a pdf file
    What should be the steps to accomplish this from the coding perpective?
  • To create the document with the dotx. template?
  • to create programmatically a table?
  • to find the bookmarks and fill them?
    Please give some hints; I saw a lot of examples, but I don’t understand how to use the template and to fill it with data. Thanks!

@taia

Thanks for your inquiry. You need to import the template document into Aspose.Words’ DOM, move the cursor to the bookmark or placeholders and insert the content. You can use Document.Save method to save the document to PDF. We suggest you please read the following articles.
Use DocumentBuilder to Insert Document Elements
Using DocumentBuilder to Modify a Document Easily

If you want to find the text and replace it with tables, image or some other content, we suggest you please read following article.
Find and Replace

1 Like

thank for you help, I tried to find bookmarks and fill them with values; this solution is working for static data. But my issue is with dynamic data. I need to have a dynamic number of rows (some inner table rows should be multiplied), depending on some dynamic data.

@taia

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

aspose.zip (271.3 KB)

Hi, thanks again for your help. I just added here the template and the expected result. Can you please suggest a solution? A general approach?

@taia

Thanks for sharing the detail. Please do not use the form fields in the template document. We suggest you please use LINQ Reporting to populate the template document with data that comes from database. The LINQ Reporting Engine is a part of the Aspose.Words API that enables you to build reports using an extended set of reporting features. Please read about template syntax from here:
Template Syntax

@tahir.manzoor

Thank you for the help. I will read the documentation and start to implement using Linq Reporting.