Skip to content

Commit

Permalink
Correct calls for flatten layers and watermark PHP
Browse files Browse the repository at this point in the history
They both called the wrong route entirely
  • Loading branch information
datalogics-tsmith committed Nov 7, 2023
1 parent 7f2163c commit 3c1f9ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 51 deletions.
64 changes: 16 additions & 48 deletions PHP/Endpoint Examples/Multipart Payload/flattened-layers-pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,28 @@
$client = new Client(); // Create a new instance of the Guzzle HTTP client.

$headers = [
'Api-Key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' // Set the API key in the headers for authentication.
'Api-Key' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' // Set the API key in the headers for authentication.
];

$options = [
'multipart' => [
[
'name' => 'file',
'contents' => Utils::tryFopen('/path/to/file', 'r'), // Provide the path to the PDF file to be watermarked.
'filename' => '/path/to/file',
'headers' => [
'Content-Type' => '<Content-type header>' // Specify the Content-Type header for the PDF file.
]
],
[
'name' => 'watermark_text',
'contents' => 'Hello, watermarked world!' // Specify the text to be used as the watermark.
],
[
'name' => 'font',
'contents' => 'Arial' // Specify the font to be used for the watermark text.
],
[
'name' => 'text_size',
'contents' => '72' // Specify the font size of the watermark text.
],
[
'name' => 'text_color_rgb',
'contents' => '255,0,0' // Specify the RGB color (red, green, blue) of the watermark text.
],
[
'name' => 'opacity',
'contents' => '0.5' // Specify the opacity of the watermark (0.0 to 1.0).
],
[
'name' => 'x',
'contents' => '0' // Specify the x-coordinate of the watermark's position.
],
[
'name' => 'y',
'contents' => '0' // Specify the y-coordinate of the watermark's position.
],
[
'name' => 'rotation',
'contents' => '0' // Specify the rotation angle of the watermark (in degrees).
],
[
'name' => 'output',
'contents' => 'pdfrest_watermarked_pdf' // Specify the desired output format for the watermarked PDF.
]
'multipart' => [
[
'name' => 'file', // Specify the field name for the file.
'contents' => Utils::tryFopen('/path/to/file', 'r'), // Open the file specified by the '/path/to/file' for reading.
'filename' => '/path/to/file', // Set the filename for the file to be processed, in this case, '/path/to/file'.
'headers' => [
'Content-Type' => '<Content-type header>' // Set the Content-Type header for the file.
]
],
[
'name' => 'output', // Specify the field name for the output option.
'contents' => 'pdfrest_flattened_pdf' // Set the value for the output option (in this case, 'pdfrest_flattened_pdf').
]
]
];

$request = new Request('POST', 'https://api.pdfrest.com/watermarked-pdf', $headers); // Create a new HTTP POST request with the API endpoint and headers.
$request = new Request('POST', 'https://api.pdfrest.com/flattened-layers-pdf', $headers); // Create a new HTTP POST request with the API endpoint and headers.

$res = $client->sendAsync($request, $options)->wait(); // Send the asynchronous request and wait for the response.

echo $res->getBody(); // Output the response body, which contains the watermarked PDF.
echo $res->getBody(); // Output the response body, which contains the flattened layers PDF content.
10 changes: 7 additions & 3 deletions PHP/Endpoint Examples/Multipart Payload/watermarked-pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@
'Content-Type' => '<Content-type header>' // Set the Content-Type header for the file.
]
],
[
'name' => 'watermark_text', // Specify the field name for the output option.
'contents' => 'TEXT' // Set the value for the watermark_text option (in this case, 'TEXT').
]
[
'name' => 'output', // Specify the field name for the output option.
'contents' => 'pdfrest_flattened_pdf' // Set the value for the output option (in this case, 'pdfrest_flattened_pdf').
'contents' => 'pdfrest_watermarked_pdf' // Set the value for the output option (in this case, 'pdfrest_watermarked_pdf').
]
]
];

$request = new Request('POST', 'https://api.pdfrest.com/flattened-layers-pdf', $headers); // Create a new HTTP POST request with the API endpoint and headers.
$request = new Request('POST', 'https://api.pdfrest.com/watermarked-pdf', $headers); // Create a new HTTP POST request with the API endpoint and headers.

$res = $client->sendAsync($request, $options)->wait(); // Send the asynchronous request and wait for the response.

echo $res->getBody(); // Output the response body, which contains the flattened layers PDF content.
echo $res->getBody(); // Output the response body, which contains the watermarked PDF content.

0 comments on commit 3c1f9ff

Please sign in to comment.