How to set PDF Metadata in PHP

Cloudmersive
1 min readApr 24, 2020

--

The typical process for setting up PDF metadata editing in PHP is a bit of a chore. But the method that I’m going to show you today is as easy as 1, 2, 3! Here’s a quick rundown.

  1. Install our API client, using the following command.
composer require cloudmersive/cloudmersive_document_convert_api_client

2. Call this function:

<?phprequire_once(__DIR__ . '/vendor/autoload.php');// Configure API key authorization: Apikey$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Apikey', 'YOUR_API_KEY');// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Apikey', 'Bearer');$apiInstance = new Swagger\Client\Api\EditPdfApi(// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.// This is optional, `GuzzleHttp\Client` will be used as default.new GuzzleHttp\Client(),$config);$request = new \Swagger\Client\Model\SetPdfMetadataRequest(); // \Swagger\Client\Model\SetPdfMetadataRequest |try {$result = $apiInstance->editPdfSetMetadata($request);print_r($result);} catch (Exception $e) {echo 'Exception when calling EditPdfApi->editPdfSetMetadata: ', $e->getMessage(), PHP_EOL;}?>

3. Input your desired PDF file and corresponding metadata into editPdfSetMetadata.

That’s it! Seriously, that’s the entire process. So easy!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet