The DynamicPDF API PHP Client Library - Manual Import
The DynamicPDF API now offers a simple option for using the PHP Client Library using the require_once PHP directive with the newly added DpdfApi.php file in the client library's GitHub (php-client) project.
You can now use the DynamicPDF API PHP Client Library without using Composer. We have streamlined the installation process and made it easier for clients who cannot or do not wish to use Composer to install the client library.
Download the PHP client library from GitHub, unzip, and begin using it.
Installation
Follow these steps to install the client library.
- Download the zip file from GitHub (php-client).

- Unzip in the directory of your choice.
- Use the
require_oncedirective to use the library. - Test the results by executing the
PdfExample.php file(be certain to set your API key first).
All necessary DynamicPDF API PHP Client Library files are included when you require the DpdfApi.php file.

Example
In this example you create a single PHP page named GetImageInfo.php to obtain image information from the DynamicPDF API image-info endpoint.
- Download the PHP client library as a zip file and unzip to:
c:/temp/php-example. - Open the
php-examplefolder in Visual Studio Code.

- Open
PdfExample.phpand add your API Key.

- Run the application,
php PdfExample.phpand it should produce the PDF filephp-pdf-example-output.pdf. - Create another file named
GetImageInfo.phpand add the following code, replacing the API key with your own.
<?php
require_once 'src/DpdfApi.php';
use DynamicPDF\Api\ImageResource;
use DynamicPDF\Api\ImageInfo;
class GetImageInfo
{
public static function Run(string $apikey, string $inputPath)
{
$imageResource = new ImageResource($inputPath . "dynamicpdfLogo.png");
$imageInfo = new ImageInfo($imageResource);
$imageInfo->ApiKey = $apikey;
$response = $imageInfo->Process();
if($response->IsSuccessful)
{
echo ($response->JsonContent);
} else {
echo("Error: ");
echo($response->StatusCode);
echo($response->ErrorMessage);
}
}
}
GetImageInfo::Run("DP.--api-key--", "./");
Notice the added statement: require_once 'src/DpdfApi.php'; that ensures your PHP includes the DynamicPDF API PHP Client Library.
- Save the file and also add the file
dynamicpdfLogo.pngto the folder.
You can get the dynamicpdfLogo.png file from the php-client-examples GitHub project's resources/get-image-info-image-info-endpoint folder (dynamicPdfLogo.png).
- Run the PHP file
php GetImageInfo.phpand the image info appears as a JSON document.
[{"pageNumber":1,"width":262,"height":250,"horizondalDpi":300,"verticalDpi":300,"numberOfComponents":3,"bitsPerComponent":8,"colorSpace":"indexed"}]
