-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeletePages.php
34 lines (28 loc) · 951 Bytes
/
DeletePages.php
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
<?php
require __DIR__ . '/vendor/autoload.php';
include_once __DIR__ . '/DynamicPdfExamples.php';
use DynamicPDF\Api\Pdf;
use DynamicPDF\Api\PdfResource;
class DeletePages
{
public static function Run(string $apikey, string $path, string $output_path)
{
$pdf = new Pdf();
$pdf->ApiKey = $apikey;
$pdfInput = $pdf->AddPdf(new PdfResource($path . "pdfnumberedinput.pdf"));
$pdfInput->StartPage = 1;
$pdfInput->PageCount = 3;
$pdfInput2 = $pdf->AddPdf(new PdfResource($path . "pdfnumberedinput.pdf"));
$pdfInput2->StartPage = 6;
$pdfInput2->PageCount = 2;
$response = $pdf->Process();
if($response->IsSuccessful)
{
file_put_contents($output_path . "delete-pages-output.pdf", $response->Content);
} else {
echo("Error: ");
echo($response->StatusCode);
echo($response->ErrorJson);
}
}
}