---
title: "Word template processing-to-PDF/UA conversion | Nutrient Python SDK"
canonical_url: "https://www.nutrient.io/guides/python/templates/word-template-to-pdf-ua/"
md_url: "https://www.nutrient.io/guides/python/templates/word-template-to-pdf-ua.md"
last_updated: "2026-05-26T07:56:07.483Z"
description: "Generate documents from Word templates with JSON data and convert to accessible PDF/UA format."
---

# Word template processing-to-PDF/UA conversion

Template-based document generation combined with PDF/UA compliance — whether for accessible invoices, compliant legal documents, or personalized educational materials — enables organizations to produce accessible, personalized documents at scale.

[Download sample](https://www.nutrient.io/downloads/samples/python/word-template-to-pdf-ua.zip)

## How Nutrient helps you achieve this

Nutrient Python SDK handles template processing with PDF/UA compliance. With the SDK, you don’t need to worry about:

- Parsing Word document internals

- Managing XML structures

- Handling style preservation

- Complex placeholder replacement logic

- PDF/UA tagging and accessibility compliance

Instead, Nutrient provides an API that handles all the complexity behind the scenes, letting you focus on your business logic.

## Complete implementation

Below is a complete working example that demonstrates Nutrient’s template processing with PDF/UA output. These lines set up the Python application. The import statements bring in all necessary classes from the Nutrient SDK:

```python

from nutrient_sdk import Document
from nutrient_sdk import WordEditor
from nutrient_sdk import PdfConformance
from nutrient_sdk import NutrientException

```

This line opens the Word template file. The [context manager](https://docs.python.org/3/reference/datamodel.html#context-managers) syntax ensures the document is automatically closed when you’re done, preventing resource leaks:

```python

def main():
    try:
        with Document.open("input_template.docx") as document:

```

Here, you create a `WordEditor` instance that will enable you to manipulate the document. This editor provides all the methods needed for template processing:

```python

            editor = WordEditor.edit(document)

```

This block reads the JSON data model. The try-except block handles potential file reading errors gracefully:

```python

            try:
                with open("input_template_model.json", "r") as f:
                    model = f.read()
            except IOError:
                print("Failed to read template model file")
                return

```

This block applies the template model, replacing all placeholders with actual data while preserving all formatting. It then saves and closes the editor:

```python

            editor.apply_template_model(model)
            editor.save()
            editor.close()

```

This block configures PDF/UA conformance and exports the document as an accessible PDF. The `PdfConformance.PDF_UA_1` setting ensures the output meets ISO 14289 accessibility standards. The try-except block handles potential errors using `NutrientException`:

```python

            # Configure PDF settings for PDF/UA conformance

            pdf_settings = document.settings.pdf_settings
            pdf_settings.set_conformance(PdfConformance.PDF_UA_1)

            document.export_as_pdf("output.pdf")
            print("Successfully generated accessible PDF from template")
    except NutrientException as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    main()

```

## Conclusion

The template processing logic with PDF/UA output consists of five steps:

1. Open the document.

2. Create an editor.

3. Apply the template model.

4. Configure PDF/UA conformance.

5. Export as PDF.

Nutrient handles complex document processing and accessibility compliance so you don’t need to understand Word’s internal structure, XML manipulation, or manual PDF tagging.

You can download [this ready-to-use sample package](https://www.nutrient.io/downloads/samples/python/word-template-to-pdf-ua.zip) that’s fully configured to help you get started with the Python SDK.
---

## Related pages

- [Nutrient Python SDK template guides](/guides/python/templates.md)
- [Word template generation and processing](/guides/python/templates/word-template-generation.md)

