-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMergePdfs.php
More file actions
40 lines (34 loc) · 1.4 KB
/
Copy pathMergePdfs.php
File metadata and controls
40 lines (34 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
// ========================================================================
// Author: DynamicPDF.COM CETE www.dynamicpdf.com
// Copyright: (c) 2021 DynamicPDF Cloud API
// License: MIT - for additional information see ./LICENSE in this project.
// Errors: Please report any errors in software to support@dynamicpdf.com
// ========================================================================
require __DIR__ . '/vendor/autoload.php';
include_once("constants.php");
use DynamicPDF\Api\Pdf;
use DynamicPDF\Api\PdfResource;
class MergePdfs
{
public static function Run(string $apikey, string $path, string $output_path)
{
$pdf = new Pdf();
$pdf->ApiKey = $apikey;
$pdfInput = $pdf->AddPdf(new PdfResource($path . "DocumentA.pdf"));
$pdfInput->StartPage = 1;
$pdfInput->PageCount = 1;
$pdf->AddPdf(new PdfResource($path . "DocumentB.pdf"));
$pdf->AddPdf("samples/merge-pdfs-pdf-endpoint/DocumentC.pdf");
$response = $pdf->Process();
if($response->IsSuccessful)
{
file_put_contents($output_path . "merge-pdfs-php-output.pdf", $response->Content);
} else {
echo("Error: ");
echo($response->StatusCode);
echo($response->ErrorJson);
}
}
}
MergePdfs::Run(CLIENT_EXAMPLES_API_KEY, CLIENT_EXAMPLES_BASE_PATH . "/merge-pdfs-pdf-endpoint/", CLIENT_EXAMPLES_OUTPUT_PATH);