PHP Client Library
The DynamicPDF API provides a full‑featured client library for PHP that simplifies integration with the REST endpoints.
The PHP client library is the official SDK for integrating the DynamicPDF API into PHP applications and backend scripts. It provides straightforward PHP classes and methods that allow developers to generate PDF documents, convert HTML and images to PDF, merge existing files, extract text and metadata, and perform detailed PDF inspection without manually building cURL requests or handling low-level HTTP logic.Using this library, PHP developers can work with the full capabilities of the DynamicPDF API, including creating PDFs programmatically, merging or splitting documents, filling and flattening form fields, stamping text or images on pages, retrieving XMP and document information, rasterizing PDF pages as images, and applying encryption or other security features. The DynamicPDF API exposes a complete set of PDF focused endpoints that support creation, conversion, processing, analysis, and secure delivery of PDF content within modern PHP applications running in frameworks, CMS platforms, or standalone scripts.
The DynamicPDF API offers clean, intuitive wrappers around the following REST endpoints:
dlex-layoutfor creating dynamic PDF reports from DLEX templates and JSON data,image-infofor extracting detailed metadata from images,pdffor creating and manipulating PDFs, merging documents, and converting HTML, Word, and Excel files to PDF,pdf-infofor retrieving document information and metadata from existing PDFs,pdf-security-infofor obtaining PDF encryption details and security settings,pdf-textfor extracting text content from PDF pages, andpdf-xmpfor reading embedded XMP metadata from PDF files.
Installation
composer require dynamicpdf/api
Manual Installation
To manually install the client library, download the zip file from Github. Unzip the php-client-library on your local machine and then use the library in you local code by requiring the following file.
require_once '<path-to-client-library>/src/DpdfAPI.php'
A sample file, PdfExample.php is included in the zip file demonstrating its use.
Usage Example
public static function Extract(string $apikey){
$resource = new PdfResource("fw4.pdf");
$pdfText = new PdfText($resource);
$pdfText->ApiKey =$apikey;
$response = $pdfText->Process();
if($response->IsSuccessful)
{
echo ($response->JsonContent);
} else {
echo("Error: ");
echo($response->StatusCode);
echo($response->ErrorMessage);
}
}