Within "Document Generation from Template" is it possible to create re-usable components / snippets?

I am using the Apryse SDK for Linux v11.9.0

In working with a set of document templates from one of our clients, all of the documents have a common header, footer, and signature snippets. The templating system they are using today is HTML based, and allows them to cross-reference other segments, so that their templates look like:


{{header}}

.... document specific content in the middle...

{{signature_block}}

{{footer}}

Then the {{header}}, {{signature_block}}, and {footer}} tags reference other HTML blocks that are defined separately.

The benefit here is that this lets them define 1 standard layout for all documents, and then if they need to update the header, or update the footer, they can update it just once, and all of their document templates are updated.

Our client is really impressed with the “Document Generation from Template” capability and how they can use Word / DOCX files to create their templates. Unfortunately this {{header}}, {{footer}} notation that they use to define re-usable content components / snippets across all of their documents is a must-have for them.

Is something like this possible?

Hello, I’m AiRon, an automated tech support bot :robot:
While you wait for one of our customer support representatives, I can help you with your question.


The Apryse SDK does not natively support HTML-like templating for reusable components directly within DOCX templates, but you can achieve similar functionality by using a combination of Apryse’s document generation features and structured input. You can define reusable components in your DOCX templates and populate them dynamically with JSON data, effectively creating a modular template system.

Some things you can try:

  • Design your DOCX templates to include placeholders for common sections like headers, footers, and signature blocks.

  • Use Apryse SDK’s structured input capabilities to dynamically fill these placeholders with content defined in JSON, allowing you to update only the JSON data when changes are needed.

  • Leverage the fillTemplateJson method to insert these common sections into your templates at runtime, ensuring consistency across all documents.



Here are some resources that might help you:


Hopefully, this helps you solve your problem while you wait for a human to get back to you.

Hi Brian,

Just so I understand you correctly, is the main issue here that both your client’s system and the document generation uses the same start and end tag (specifically ‘{{’ and ‘}}’) which prevents them from using the two in conjunction with each other?

Hi @kmirsalehi ,

My apologies for the confusion. I re-used {{ }} to demonstrate the merge tags.
Their current templating framework uses a different tag indicator. << and >> specifically.
The point I was making is that all of their documents have <<header>> and <<footer>> at the top and bottom.

When their templating engine sees <<header>> and <<footer>>, it is able to look up a separate content block.

From what I’ve found with the Apryse document generation library, the closest I can see to that is Structured Input

I think what I’m looking for is a way to break apart a Word document into multiple independent pieces, like I see often in HTML templating engines.

Hi Brian,

We don’t have a method that’s as flexible as the way HTML blocks are defined. This is mostly due to the constraints of the PDF and Word format which means it’s not really possible to have a large, independent component. The closest we have are the document generation from a docx template and our content replacer which works directly in a PDF:

If both of those still miss the mark of what you’re trying to accomplish, then it might be better if you can provide sample input files with a demonstration of what you want the output to be.

1 Like

Thank you @kmirsalehi
We currently license and use your PDF Generation using Template (Server-side).

I believe the challenge that I have is the limitation on supported HTML tags in the Document Generation Structured Input | Apryse documentation capability.

I would love to be able to offer a <<header>> tag in my code that could represent an HTML content block replacement, but if that HTML content block contained unsupported HTML tags, the final rendering would not look correct.

1 Like

Thank you for the feedback. I have relayed this to the team as a feature request. Unfortunately, at this time, the only strings we support via the templating engine are the double parentheses.

If you have any further questions on this, please let me know.

1 Like

Thank you @swijeratne

To be clear, the tag replacement was just an example. That’s not specifically what I am looking for.

What I am looking for is a way to replace a “placeholder” in a docx file with a table

A related question: from this blog post

This shows how to search and replace text in the WebViewer UI. Is this capability also available in the server-sdk?

This could actually be what I am looking for
-Brian

1 Like

Thank you for the clarification. I understand that you would like to replace a placeholder section of the document with a whole table. While we do support adding tables with the templating API, the table structure needs to already be in the template file. I can relay this feedback to the team.

The find-replace API is available in the server-side SDK. Please refer to the guide here for more information. Please note, however, that the API cannot replace search terms with a whole table.