-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImageConversion.php
58 lines (48 loc) · 2 KB
/
ImageConversion.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?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\ImageResource;
use DynamicPDF\Api\ImageInput;
use DynamicPDF\API\Align;
use DynamicPDF\Api\VAlign;
class ImageConversion
{
public static function Run(string $apikey, string $path, string $outputPath)
{
$pdf = new Pdf();
$pdf->ApiKey = $apikey;
$imageResource = new ImageResource($path . "testimage.tif");
$imageResource2 = new ImageResource($path . "dynamicpdfLogo.png" );
$imageInput = $pdf->AddImage($imageResource);
$imageInput2 = $pdf->AddImage($imageResource2);
$imageInput->VAlign = VAlign::Center;
$imageInput->Align = Align::Center;
$imageInput->PageHeight = 1008;
$imageInput->PageWidth = 612;
$imageInput->ExpandToFit = false;
$imageInput2->VAlign = VAlign::Center;
$imageInput2->Align = Align::Center;
$imageInput2->PageHeight = 612;
$imageInput2->PageWidth = 1008;
$imageInput2->ExpandToFit = true;
$imageInput->Align = Align::Center;
$imageInput2->VAlign = VAlign::Top;
$response = $pdf->Process();
if($response->IsSuccessful)
{
file_put_contents($outputPath . "image-conversion-output.pdf", $response->Content);
} else {
echo("Error: ");
echo($response->StatusCode);
echo($response->ErrorJson);
}
}
}
ImageConversion::Run(CLIENT_EXAMPLES_API_KEY, CLIENT_EXAMPLES_BASE_PATH . "image-conversion/", CLIENT_EXAMPLES_OUTPUT_PATH);