By Isaac Maw | 2026 Jan 02

3 min
Tags
document generation
JSON
php
Summary: Using the Server SDK, easily set up a template using familiar Office tools, and replace content from a JSON file. Learn how in this blog post.
Automatically generated PDF Certificates are an important part of training, upskilling and education software, from K12 EdTech systems, to Higher education eLearning portals, to corporate Learning management systems (LMS). Easily generate professional, personalized PDF certificates for your users with Apryse document generation.
Apryse's office template generation framework enables the dynamic generation of PDFs from a template you design.
Apryse is the SDK of choice for generating PDF certificates. Here’s why:
First, we’ll need to get set up with Apryse Server SDK.
Apryse Server SDK is a robust document library that empowers server and desktop applications with accurate, reliable, and lightning-fast document processing capabilities. Pre-built samples are readily available for quick and hassle-free integration.
PHP for the Apryse SDK is supported on Linux and MacOS. Follow the steps in our documentation guide to initialize Server SDK for MacOS or Linux. The guide includes a free trial license key.
Now that we have Apryse Server SDK ready to go, we can use the Office template generation framework.
Apryse's office template generation framework enables the dynamic generation of PDFs:
You can try the template generation demo in your browser here.
The generation framework requires minimal code to get up and running. Simply initiate a normal Office conversion, but with the optional TemplateParamsJson parameter set:
Find full sample code using Apryse SDK to generate a PDF from an Office document template and a JSON string here.
The template sets how your certificate will appear. You can create the template from scratch, or easily prepare an existing DOCX file for use as a template.
Because our Apryse template generation framework can use any Office file as a template, you don’t need to create the template from scratch. If your organization already has a certificate template, simply mark using {{moustache tags}}. If your template is in PDF format, you can easily convert it to DOCX using the Server SDK.
The generation framework replaces {{tags}} in the template with strings from a supplied JSON file. You can design your certificate file using any formatting you like, and the string from the JSON will keep the formatting of the tag. For example:

Figure 1: The JSON string replaces the tag, while maintaining the template formatting.
Create your template using any familiar tool, such as Google Docs or Microsoft Word. You could also create the template using the Apryse DOCX Editor.
In addition to text strings, the framework can also replace images and table content. As tags are replaced, text will automatically reflow according to the rules set in your template file, such as columns and justification.
This JSON file contains data, such as student name, course completed, and date to be used to personalize the certificate template and generate the new PDF.
Text String
Can be one of:
Images
An image value is a JSON dictionary with the following required properties:
QR code
A QR code can be generated to encode alphanumeric data using the following properties:
Structured input
Structured input inserts document content that is more powerful than simple text replacement. It supports dynamic document structure, formatting, and styling. To insert structured input, use a JSON dictionary with one of the following properties:
Objects
The JSON data can also be organized into objects. The tag {{a.b}} will retrieve the value of property b in object a: {"a": {"b": "value"} }.
More Options
The data model supports other content values, such as loops, conditionals, and tables. However, these are not likely to be used in your certificates. To find these details, check out the documentation page.
In this post, we covered how to use the Apryse Server SDK to easily set up a DOCX template to generate personalized certificates using PHP, adding valuable automation for elearning, training or LMS platforms. If you’re not using PHP, you can visit the template generation documentation guide to try other languages, such as C++, Java, Javascript, and Python.
Check out our demo, start your free trial, and contact our sales team to get started.
How do I generate PDF certificates in PHP?
Using Apryse SDK with Document Generation, tags in a DOCX template file can be replaced with data from JSON. The Apryse SDK supports PHP.
Can I generate certificates from DOCX templates?
Yes, template files can be in DOCX format. The replaced string will retain the formatting (text color, bold, italic, font size, etc.) of the template.
Does PDF generation run entirely on my server?
Yes, Apryse Server SDK runs entirely server-side. For client-side processing, check out Apryse Web SDK.
What languages and frameworks does Apryse SDK support?
Apryse supports a large number of frameworks and languages, including React, Angular, and .NET, as well as popular languages like Javascript, C++, PHP and Python. For the full list, visit our Get Started page.
What data types can be replaced?
Our SDK supports text strings, images, QR codes, structured input such as formatting and styling, objects, and other content values such as loops, conditionals, and tables, allowing for sophisticated automation of your certificate generation process.
Tags
document generation
JSON
php

Isaac Maw
Technical Content Creator
Share this post
// Create a TemplateDocument object from an input office file.
$template_doc = Convert::CreateOfficeTemplate($input_path, NULL);
// Fill the template with data from a JSON string, producing a PDF document.
$pdfdoc = $template_doc->FillTemplateJson($json_data_string);
// Save the PDF to a file.
$pdfdoc->Save($output_path, SDFDoc::e_linearized, NULL);