How to apply a Word DOCX Template in PHP

composer require cloudmersive/cloudmersive_document_convert_api_client
<?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\ConvertTemplateApi(// 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);$input_file = "/path/to/file"; // \SplFileObject | Input file to perform the operation on.$template_definition = "template_definition_example"; // string | Template definition for the document, including what values to replacetry {$result = $apiInstance->convertTemplateApplyDocxTemplate($input_file, $template_definition);print_r($result);} catch (Exception $e) {echo 'Exception when calling ConvertTemplateApi->convertTemplateApplyDocxTemplate: ', $e->getMessage(), PHP_EOL;}?>

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Creating EFS File System And Mount Targets Using Terraform

Changes being made to Super Pepe Holders:

The True Value of Software

A Byte of Coding Issue #161

🌈☮️ PEACEVOID Roadtrip: Update v.1.0

Canary Deployment for AWS Lambda

Introduction of Amazon Web Services.

CS 371p Spring 2021 Week 2: Joshua Skadberg

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

Cloudmersive

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

More from Medium

pre_fetch_count in common cases in PHP

Customising Laravel Fortify 2FA methods

What is the htaccess file

Using Docker in PHP application