Generating PDF/UA from PowerPoint templates
This guide explains how to generate a PowerPoint presentation from a template and convert the generated file to PDF/UA with Nutrient Python SDK.
Use this workflow for pitch decks, reports, résumés, and other presentations that use a fixed slide design with variable content. PDF/UA helps generated PDFs meet accessibility requirements for assistive technologies such as screen readers.
Download sampleGenerating a presentation and exporting PDF/UA
Nutrient Python SDK handles the template processing and PDF/UA export workflow. The sample performs the following tasks:
- Open a PowerPoint template.
- Load a JSON data model.
- Apply the data model to replace placeholders.
- Configure PDF/UA conformance.
- Export the generated document as a PDF.
Complete implementation
The following sections build the complete Python example. First, import the classes required for document processing, template editing, PDF conformance, and error handling:
from nutrient_sdk import Documentfrom nutrient_sdk import PresentationEditorfrom nutrient_sdk import PdfConformancefrom nutrient_sdk import NutrientExceptionOpen the PowerPoint template file. The context-manager(opens in a new tab) syntax closes the document when processing finishes:
def main(): try: with Document.open("input_presentation.pptx") as document:Create a PresentationEditor instance for template processing:
editor = PresentationEditor.edit(document)Read the JSON data model that contains the values for the template placeholders:
try: with open("input_presentation_model.json", "r") as f: model = f.read() except IOError: print("Failed to read template model file") returnApply the template model, save the generated presentation, and close the editor:
editor.apply_template_model(model) editor.save() editor.close()Configure PDF/UA conformance and export the document as an accessible PDF:
# Configure PDF settings for PDF/UA conformance pdf_settings = document.settings.pdf_settings pdf_settings.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 workflow consists of five steps:
- Open the PowerPoint template.
- Create a presentation editor.
- Apply the JSON template model.
- Configure PDF/UA conformance.
- Export the generated presentation as a PDF.
Use this pattern when you have a fixed PowerPoint design and variable content from a data model.
Download the sample package to run this example as-is.