Converting Word documents (DOCX) to PDF/UA — whether for accessibility compliance, inclusive document creation, or meeting ISO 14289 standards — ensures content is accessible to all users, including those using assistive technologies like screen readers.

How Nutrient helps you achieve this

Nutrient Python SDK handles DOCX-to-PDF/UA conversion. With the SDK, you don’t need to worry about:

  • Parsing Word document structures
  • Managing accessibility tagging
  • Handling PDF/UA conformance requirements
  • Complex rendering logic

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 DOCX-to-PDF/UA conversion. These lines set up the Python application. The import statements bring in all necessary classes from the Nutrient SDK:

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

This line opens the Word document. The context manager(opens in a new tab) syntax ensures the document is automatically closed when you’re done, preventing resource leaks. This block configures PDF/UA conformance. The PdfConformance.PDF_UA_1 setting ensures the output meets ISO 14289 accessibility standards:

def main():
try:
with Document.open("input.docx") as document:
# Configure PDF settings for PDF/UA conformance
pdf_settings = document.settings.pdf_settings
pdf_settings.set_conformance(PdfConformance.PDF_UA_1)

This block exports the document to PDF/UA format. The try-except block handles potential errors using NutrientException:

document.export_as_pdf("output.pdf")
print("Successfully converted to PDF/UA")
except NutrientException as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()

Conclusion

The conversion logic consists of three steps:

  1. Open the document.
  2. Configure PDF/UA conformance.
  3. Export as PDF.

Nutrient handles Word document parsing and accessibility compliance so you don’t need to understand document internals or manage PDF tagging manually.

You can download this ready-to-use sample package that’s fully configured to help you get started with the Python SDK.