<?php include '../vendor/autoload.php'; use Pdftk\Pdftk; $sPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'pdfs' . DIRECTORY_SEPARATOR; $sOutputFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'example2output.pdf'; $oPDFTk = new Pdftk(); $oPDFTk->setInputFile(array("filename" => $sPath . 'example.pdf', 'start_page' => 1, "end_page" => 2))->setInputFile(array("filename" => $sPath . 'example.pdf', 'rotation' => 90))->setUserPassword("userpassword")->setOwnerPassword("ownerpassword")->setEncryptionLevel(40)->setOutputFile($sOutputFile)->_renderPdf(); echo 'Rendered to: ' . $sOutputFile . "\r\n";
<?php include '../vendor/autoload.php'; use Pdftk\Pdftk; $sPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'pdfs' . DIRECTORY_SEPARATOR; $oPDFTk = new Pdftk(); $oPDFTk->setInputFile(array("filename" => $sPath . 'example.pdf', 'start_page' => 2))->setInputFile(array("filename" => $sPath . 'example2.pdf', 'rotation' => 90))->setInputFile(array("filename" => $sPath . 'example2.pdf', 'password' => 'password', 'alternate' => 'odd')); header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="example1.pdf"'); echo $oPDFTk->_renderPdf();
<?php include '../vendor/autoload.php'; use Pdftk\Pdftk; $sPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'pdfs' . DIRECTORY_SEPARATOR; $pages = 2; for ($x = 1; $x <= $pages; $x++) { $oPDFTk = new Pdftk(); $oPDFTk->setInputFile(array("filename" => $sPath . 'example.pdf', 'start_page' => $x, "end_page" => $x))->setUserPassword("userpassword")->setOwnerPassword("ownerpassword")->setOutputFile(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'example2output-' . $x . '.pdf')->_renderPdf(); echo 'Saving PDF to: ' . sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'example2output-' . $x . '.pdf' . "\r\n"; }
<?php include '../vendor/autoload.php'; use Pdftk\Pdftk; $sPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'pdfs' . DIRECTORY_SEPARATOR; $oPDFTk = new Pdftk(); $oPDFTk->setInputFile(array('filename' => $sPath . 'example.pdf', 'start_page' => 2))->setInputFile(array('filename' => $sPath . 'example with spaces.pdf', 'password' => 'password'))->setInputFile(array('filename' => $sPath . 'example3.pdf', 'password' => 'password')); header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="example1.pdf"'); echo $oPDFTk->_renderPdf();
<?php include '../vendor/autoload.php'; use Pdftk\Pdftk; use Pdftk\File\Input; $sPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'pdfs' . DIRECTORY_SEPARATOR; $oTmp = new Input(array("filename" => $sPath . 'example.pdf', 'start_page' => 2)); $oPDFTk = new Pdftk(); $oPDFTk->setInputFile($oTmp)->setInputFile(array("filename" => $sPath . 'example2.pdf', 'rotation' => 90))->setInputFile(array("filename" => $sPath . 'example2.pdf', 'password' => 'password', 'alternate' => 'odd'))->setOutputFile("example3output.pdf")->downloadOutput();