Created
October 10, 2017 11:31
-
-
Save GautierT/3e07c5e613ba7bd93c685bf733df9b28 to your computer and use it in GitHub Desktop.
Merge two PDF files with ILovePDF API then send it to the Seeuletter API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Before, install Ilovepdf and Seeuletter with : | |
composer require ilovepdf/ilovepdf-php | |
and composer require seeuletter/seeuletter-php | |
*/ | |
require_once('vendor/autoload.php'); | |
use Ilovepdf\Ilovepdf; | |
// Get key here : https://www.seeuletter.com/ | |
$seeuletter = new \Seeuletter\Seeuletter('SEEULETTER_API_KEY'); | |
// Get keys here : https://developer.ilovepdf.com/ | |
$ilovepdf = new Ilovepdf('ILOVEPDF_PUBLIC_KEY','ILOVEPDF_SECRET_KEY'); | |
// Create a new task | |
$myTaskMerge = $ilovepdf->newTask('merge'); | |
// Add files to task for upload | |
$file1 = $myTaskMerge->addFile('test.pdf'); | |
$file2 = $myTaskMerge->addFile('test_2.pdf'); | |
// Execute the task | |
$myTaskMerge->execute(); | |
// Download the package files | |
$myTaskMerge->download(); | |
$to_address = array( | |
'name' => 'Seeuletter', | |
'address_line1' => '30 rue de rivoli', | |
'address_line2' => '', | |
'address_city' => 'Paris', | |
'address_country' => 'France', | |
'address_postalcode' => '75004' | |
); | |
$letter = $seeuletter->letters()->create(array( | |
'to' => $to_address, | |
'source_file' => '@./merged.pdf', | |
'description' => 'Test Letters', | |
'color' => 'bw', | |
'source_file_type' => 'file', | |
'postage_type' => 'verte' | |
)); | |
print_r($letter); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment