Skip to content

Instantly share code, notes, and snippets.

@jonathanmaron
Last active September 10, 2023 05:03
Show Gist options
  • Save jonathanmaron/50d5066739229c7ada75841fa542072c to your computer and use it in GitHub Desktop.
Save jonathanmaron/50d5066739229c7ada75841fa542072c to your computer and use it in GitHub Desktop.
<?php
declare(strict_types=1);
include_once __DIR__ . '/vendor/autoload.php';
use TextControl\ReportingCloud\ReportingCloud;
use TextControl\ReportingCloud\Stdlib\ConsoleUtils;
use TextControl\ReportingCloud\Stdlib\Path;
$reportingCloud = new ReportingCloud([
'api_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
]);
$sourceFilename = sprintf('%s/test_template.docx', Path::resource());
$destinationFilename = 'test_template_merged.pdf';
$mergeData = [
'name' => 'Jemima Puddle-Duck',
'age' => 7,
];
$arrayOfBinaryData = $reportingCloud->mergeDocument(
$mergeData,
ReportingCloud::FILE_FORMAT_PDF,
null,
$sourceFilename
);
file_put_contents($destinationFilename, $arrayOfBinaryData[0]);
ConsoleUtils::writeLn('Written to "%s".', [$destinationFilename]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment