Skip to content

Commit

Permalink
add samples
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleix Cabistany authored and Aleix Cabistany committed Mar 21, 2017
1 parent 3aa9d7d commit 34ae32c
Show file tree
Hide file tree
Showing 23 changed files with 476 additions and 12 deletions.
7 changes: 0 additions & 7 deletions samples/compress.php

This file was deleted.

30 changes: 30 additions & 0 deletions samples/compress_advanced.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');

use Ilovepdf\CompressTask;


//you can call task class directly
$myTask = new CompressTask("PUBLIC_KEY", "SECRET_KEY");

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.pdf');

// we can set rotate to file
$file->setRotation(90);

// set compression level
$myTask->setCompressionLevel('extreme');

// and set name for output file.
// the task will set the correct file extension for you.
$myTask->setOutputFilename('lowlow_compression');

// process files
// time var will have info about time spent in process
$time = $myTask->execute();

// and finally download file. If no path is set, it will be donwloaded on current folder
$myTask->download('path/to/download');
20 changes: 20 additions & 0 deletions samples/compress_basic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');

use Ilovepdf\CompressTask;


//you can call task class directly
$myTask = new CompressTask("PUBLIC_KEY", "SECRET_KEY");

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.pdf');

// process files
// time var will have info about time spent in process
$time = $myTask->execute();

// and finally download file. If no path is set, it will be donwloaded on current folder
$myTask->download();
31 changes: 31 additions & 0 deletions samples/merge_advanced.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');

use Ilovepdf\Ilovepdf;


// start the manager classy
$ilovepdf = new Ilovepdf("PUBLIC_KEY", "SECRET_KEY");

// and get the task tool
$myTask = $ilovepdf->newTask('merge');

// file var keeps info about server file id, name...
// it can be used latter to cancel a specific file
$fileA = $myTask->addFile('/path/to/file/document_a.pdf');
$fileB = $myTask->addFile('/path/to/file/document_b.pdf');

// set compression level
$myTask->setCompressionLevel('extreme');

// and set name for output file.
// the task will set the correct file extension for you.
$myTask->setOutputFilename('merged_filename');

// process files
// time var will have info about time spent in process
$time = $myTask->execute();

// and finally download file. If no path is set, it will be downloaded on current folder
$myTask->download('path/to/download');
24 changes: 24 additions & 0 deletions samples/merge_basic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');

use Ilovepdf\Ilovepdf;


// start the manager classy
$ilovepdf = new Ilovepdf("PUBLIC_KEY", "SECRET_KEY");

// and get the task tool
$myTask = $ilovepdf->newTask('merge');

// file var keeps info about server file id, name...
// it can be used latter to cancel a specific file
$fileA = $myTask->addFile('/path/to/file/document_a.pdf');
$fileB = $myTask->addFile('/path/to/file/document_b.pdf');

// process files
// time var will have info about time spent in process
$time = $myTask->execute();

// and finally download file. If no path is set, it will be downloaded on current folder
$myTask->download();
25 changes: 25 additions & 0 deletions samples/repair_advanced.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');

use Ilovepdf\RepairTask;


//you can call task class directly
$myTask = new RepairTask("PUBLIC_KEY", "SECRET_KEY");

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.pdf');


// and set name for output file.
// the task will set the correct file extension for you.
$myTask->setOutputFilename('repaired_file');

// process files
// time var will have info about time spent in process
$time = $myTask->execute();

// and finally download file. If no path is set, it will be donwloaded on current folder
$myTask->download('path/to/download');
20 changes: 20 additions & 0 deletions samples/repair_basic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');

use Ilovepdf\RepairTask;


//you can call task class directly
$myTask = new RepairTask("PUBLIC_KEY", "SECRET_KEY");

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.pdf');

// process files
// time var will have info about time spent in process
$time = $myTask->execute();

// and finally download file. If no path is set, it will be donwloaded on current folder
$myTask->download();
27 changes: 27 additions & 0 deletions samples/rotate_advanced.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');

use Ilovepdf\RotateTask;


//you can call task class directly
$myTask = new RotateTask("PUBLIC_KEY", "SECRET_KEY");

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.pdf');

// set the rotation, in degrees
$file->setRotation(90);

// and set name for output file.
// the task will set the correct file extension for you.
$myTask->setOutputFilename('rotated_file');

// process files
// time var will have info about time spent in process
$time = $myTask->execute();

// and finally download file. If no path is set, it will be donwloaded on current folder
$myTask->download('path/to/download');
23 changes: 23 additions & 0 deletions samples/rotate_basic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');

use Ilovepdf\RotateTask;


//you can call task class directly
$myTask = new RotateTask("PUBLIC_KEY", "SECRET_KEY");

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.pdf');

// set the rotation, in degrees
$file->setRotation(90);

// process files
// time var will have info about time spent in process
$time = $myTask->execute();

// and finally download file. If no path is set, it will be donwloaded on current folder
$myTask->download();
36 changes: 36 additions & 0 deletions samples/split_advanced.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');

use Ilovepdf\Ilovepdf;
use Ilovepdf\SplitTask;

// start the manager classy
$ilovepdf = new Ilovepdf("PUBLIC_KEY", "SECRET_KEY");
// and get the task tool
$myTask = $ilovepdf->newTask('split');

// or you can call task class directly, this set the same tool as before
$myTask = new SplitTask("PUBLIC_KEY", "SECRET_KEY");


// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.pdf');

// set ranges to split the document
$myTask->setRanges("2-4,6-8");

// and set name for output file.
// in this case it will output a zip file, so we set the package name.
$myTask->setPackagedFilename('split_documents');

// and name for splitted document (inside the zip file)
$myTask->setOutputFilename('split');

// process files
// time var will have info about time spent in process
$time = $myTask->execute();

// and finally download file. If no path is set, it will be donwloaded on current folder
$myTask->download('path/to/download');
35 changes: 35 additions & 0 deletions samples/split_advanced_merge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');

use Ilovepdf\Ilovepdf;
use Ilovepdf\SplitTask;

// start the manager classy
$ilovepdf = new Ilovepdf("PUBLIC_KEY", "SECRET_KEY");
// and get the task tool
$myTask = $ilovepdf->newTask('split');

// or you can call task class directly, this set the same tool as before
$myTask = new SplitTask("PUBLIC_KEY", "SECRET_KEY");


// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.pdf');

// set ranges to split the document
$myTask->setRanges("2-4,6-8");

// set we want splitted files to be merged in new one
$myTask->setMergeAfter(true);

// and name for merged document
$myTask->setOutputFilename('split');

// process files
// time var will have info about time spent in process
$time = $myTask->execute();

// and finally download file. If no path is set, it will be donwloaded on current folder
$myTask->download('path/to/download');
23 changes: 23 additions & 0 deletions samples/split_basic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');

use Ilovepdf\Ilovepdf;
use Ilovepdf\SplitTask;

// or you can call task class directly, this set the same tool as before
$myTask = new SplitTask("PUBLIC_KEY", "SECRET_KEY");

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.pdf');

// set ranges to split the document
$myTask->setRanges("2-4,6-8");

// process files
// time var will have info about time spent in process
$time = $myTask->execute();

// and finally download file. If no path is set, it will be donwloaded on current folder
$myTask->download();
27 changes: 27 additions & 0 deletions samples/unlock_advanced.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');

use Ilovepdf\UnlockTask;


//you can call task class directly
$myTask = new UnlockTask("PUBLIC_KEY", "SECRET_KEY");

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.pdf');

// set the password witch the document is locked
$file->setPassword('test');

// and set name for output file.
// the task will set the correct file extension for you.
$myTask->setOutputFilename('unlocked');

// process files
// time var will have info about time spent in process
$time = $myTask->execute();

// and finally download the unlocked file. If no path is set, it will be donwloaded on current folder
$myTask->download('path/to/download');
23 changes: 23 additions & 0 deletions samples/unlock_basic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
//include the autoloader
require_once('../vendor/autoload.php');

use Ilovepdf\UnlockTask;


//you can call task class directly
$myTask = new UnlockTask("PUBLIC_KEY", "SECRET_KEY");

// file var keeps info about server file id, name...
// it can be used latter to cancel file
$file = $myTask->addFile('/path/to/file/document.pdf');

// set the password witch the document is locked
$file->setPassword('test');

// process files
// time var will have info about time spent in process
$time = $myTask->execute();

// and finally download the unlocked file. If no path is set, it will be donwloaded on current folder
$myTask->download();
Loading

0 comments on commit 34ae32c

Please sign in to comment.