The PHP SDK provides a client for integrating PDFGate API endpoints into your PHP applications.
Source code: github.com/pdfgate/pdfgate-sdk-php
Package: packagist.org/packages/pdfgate/pdfgate-sdk-php
Install the package with Composer, then initialize the client with your API key.
1composer require pdfgate/pdfgate-sdk-phpThe example below generates a PDF from a URL and returns a pre-signed file URL.
1<?php23use PdfGate\PdfGateClient;45$client = new PdfGateClient('live_your_api_key');67$generated = $client->generatePdf([8 'url' => 'https://example.com',9 'pageSizeType' => 'a4',10 'preSignedUrlExpiresIn' => 120011]);1213echo $generated->getFileUrl();You can also generate a PDF directly from raw HTML and attach metadata to the resulting document.
1$client->generatePdf([2 'html' => '<h1>Hello</h1>',3 'pageSizeType' => 'a4',4 'metadata' => ['source' => 'sdk'],5]);Use getFile to retrieve the output stream and save it locally.
1$stream = $client->getFile($documentId);2$output = fopen('output.pdf', 'wb');3stream_copy_to_stream($stream, $output);4fclose($output);5fclose($stream);| Method | Purpose |
|---|---|
generatePdf | Generate a PDF from HTML or a public URL. |
uploadFile | Upload a PDF file for later transformations. |
getFile | Download the PDF stream for a stored document. |
getDocument | Retrieve document metadata and file URLs. |
flattenPdf | Flatten interactive PDF fields into a static document. |
compressPdf | Compress a PDF and return the resulting document record. |
protectPdf | Encrypt a PDF and apply access restrictions. |
watermarkPdf | Apply text or image watermarks to a document. |
extractPdfFormData | Read form field values from a fillable PDF. |
Use the SDK together with the main API documentation for request parameters, endpoint behavior, and workflow guides such as webhooks and PDF form fields.