diff --git a/public/demos/1-Core/actions/add-a-javascript/script.php b/public/demos/1-Core/actions/add-a-javascript/script.php index d34236d..e9bef0a 100644 --- a/public/demos/1-Core/actions/add-a-javascript/script.php +++ b/public/demos/1-Core/actions/add-a-javascript/script.php @@ -12,20 +12,20 @@ $path = displayFiles($files, false); // create a writer instance -$writer = new SetaPDF_Core_Writer_Http('AddJavaScript.pdf', false); +$writer = new \SetaPDF_Core_Writer_Http('AddJavaScript.pdf', false); // create a document instance -$document = SetaPDF_Core_Document::loadByFilename($path, $writer); +$document = \SetaPDF_Core_Document::loadByFilename($path, $writer); // this is our JavaScript we want to inject - we check for an // existing JavaScript variable in the document to show some logic. $js = 'var msg = typeof(SetaPDF) != "undefined" ? SetaPDF : "Hello from SetaPDF!"; app.alert(msg);'; // create an action -$jsAction = new SetaPDF_Core_Document_Action_JavaScript($js); +$jsAction = new \SetaPDF_Core_Document_Action_JavaScript($js); // get names $names = $document->getCatalog()->getNames(); // get the JavaScript name tree -$javaScriptTree = $names->getTree(SetaPDF_Core_Document_Catalog_Names::JAVA_SCRIPT, true); +$javaScriptTree = $names->getTree(\SetaPDF_Core_Document_Catalog_Names::JAVA_SCRIPT, true); // make sure we've an unique name $name = 'SetaPDF'; diff --git a/public/demos/1-Core/actions/delete-javascript/script.php b/public/demos/1-Core/actions/delete-javascript/script.php index 08962f5..345c9e3 100644 --- a/public/demos/1-Core/actions/delete-javascript/script.php +++ b/public/demos/1-Core/actions/delete-javascript/script.php @@ -12,12 +12,12 @@ $path = displayFiles($files); // create a document -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); // get names $names = $document->getCatalog()->getNames(); // get the JavaScript name tree -$javaScriptTree = $names->getTree(SetaPDF_Core_Document_Catalog_Names::JAVA_SCRIPT); +$javaScriptTree = $names->getTree(\SetaPDF_Core_Document_Catalog_Names::JAVA_SCRIPT); $out = ''; @@ -33,7 +33,7 @@ } if ($shouldSave) { - $writer = new SetaPDF_Core_Writer_Http(); + $writer = new \SetaPDF_Core_Writer_Http(); $document->setWriter($writer); $document->save()->finish(); die(); diff --git a/public/demos/1-Core/actions/get-javascript/script.php b/public/demos/1-Core/actions/get-javascript/script.php index 110d6d0..6ee79c9 100644 --- a/public/demos/1-Core/actions/get-javascript/script.php +++ b/public/demos/1-Core/actions/get-javascript/script.php @@ -12,15 +12,15 @@ $path = displayFiles($files); // create a document -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); // get names $names = $document->getCatalog()->getNames(); // get the JavaScript name tree -$javaScriptTree = $names->getTree(SetaPDF_Core_Document_Catalog_Names::JAVA_SCRIPT); +$javaScriptTree = $names->getTree(\SetaPDF_Core_Document_Catalog_Names::JAVA_SCRIPT); if ($javaScriptTree) { - $allJavaScripts = $javaScriptTree->getAll(false, SetaPDF_Core_Document_Action_JavaScript::class); + $allJavaScripts = $javaScriptTree->getAll(false, \SetaPDF_Core_Document_Action_JavaScript::class); foreach ($allJavaScripts as $name => $jsAction) { echo $name . '
------------------'; diff --git a/public/demos/1-Core/analyze/check-for-collection/script.php b/public/demos/1-Core/analyze/check-for-collection/script.php index 9501012..6412b86 100644 --- a/public/demos/1-Core/analyze/check-for-collection/script.php +++ b/public/demos/1-Core/analyze/check-for-collection/script.php @@ -13,7 +13,7 @@ $path = displayFiles($files); // create a document -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $catalog = $document->getCatalog(); $dictionary = $catalog->getDictionary(); diff --git a/public/demos/1-Core/analyze/check-for-digital-signatures/script.php b/public/demos/1-Core/analyze/check-for-digital-signatures/script.php index aeaa7bd..03ef6a6 100644 --- a/public/demos/1-Core/analyze/check-for-digital-signatures/script.php +++ b/public/demos/1-Core/analyze/check-for-digital-signatures/script.php @@ -14,7 +14,7 @@ $path = displayFiles($files); -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $terminalFields = $document->getCatalog()->getAcroForm()->getTerminalFieldsObjects(); $signatureFieldFound = false; @@ -22,17 +22,17 @@ foreach ($terminalFields as $fieldData) { $fieldData = $fieldData->ensure(); - $ft = SetaPDF_Core_Type_Dictionary_Helper::resolveAttribute($fieldData, 'FT'); + $ft = \SetaPDF_Core_Type_Dictionary_Helper::resolveAttribute($fieldData, 'FT'); if (!$ft || $ft->getValue() !== 'Sig') { continue; } - $fieldName = SetaPDF_Core_Document_Catalog_AcroForm::resolveFieldName($fieldData); + $fieldName = \SetaPDF_Core_Document_Catalog_AcroForm::resolveFieldName($fieldData); echo sprintf('Signature Field "%s" found! ', $fieldName); $signatureFieldFound = true; - $v = SetaPDF_Core_Type_Dictionary_Helper::resolveAttribute($fieldData, 'V'); - if (!$v || !$v->ensure() instanceof SetaPDF_Core_Type_Dictionary) { + $v = \SetaPDF_Core_Type_Dictionary_Helper::resolveAttribute($fieldData, 'V'); + if (!$v || !$v->ensure() instanceof \SetaPDF_Core_Type_Dictionary) { echo ' But not digital signed.

'; continue; } @@ -43,7 +43,7 @@ $signatureData = $v->ensure()->getValue('Contents')->ensure()->getValue(); $signatureData = rtrim($signatureData, "\0"); - echo 'asn1js | '; echo 'download
'; @@ -59,9 +59,9 @@ $propertyValue = $value->getValue($property)->ensure()->getValue(); if ($property === SetaPDF_Signer::PROP_TIME_OF_SIGNING) { - $propertyValue = SetaPDF_Core_DataStructure_Date::stringToDateTime($propertyValue); + $propertyValue = \SetaPDF_Core_DataStructure_Date::stringToDateTime($propertyValue); } else { - $propertyValue = SetaPDF_Core_Encoding::convertPdfString($propertyValue); + $propertyValue = \SetaPDF_Core_Encoding::convertPdfString($propertyValue); } $signatureProperties[$property] = $propertyValue; diff --git a/public/demos/1-Core/analyze/check-for-encryption/script.php b/public/demos/1-Core/analyze/check-for-encryption/script.php index 3b6f406..86da970 100644 --- a/public/demos/1-Core/analyze/check-for-encryption/script.php +++ b/public/demos/1-Core/analyze/check-for-encryption/script.php @@ -11,7 +11,7 @@ $path = displayFiles($files); -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); if (!$document->hasSecHandler()) { echo 'Document is not encrypted.'; @@ -21,53 +21,53 @@ $data = []; $secHandler = $document->getSecHandler(); -if ($secHandler instanceof SetaPDF_Core_SecHandler_PublicKey) { +if ($secHandler instanceof \SetaPDF_Core_SecHandler_PublicKey) { $data['Security Method'] = 'Public Key Security'; -} elseif ($secHandler instanceof SetaPDF_Core_SecHandler_Standard) { +} elseif ($secHandler instanceof \SetaPDF_Core_SecHandler_Standard) { $data['Security Method'] = 'Password Security'; $data['Document Open Password'] = ($secHandler->auth() ? 'No' : 'Yes'); - $data['Permissions Password'] = ($secHandler->getAuthMode() === SetaPDF_Core_SecHandler::OWNER ? 'No' : 'Yes'); + $data['Permissions Password'] = ($secHandler->getAuthMode() === \SetaPDF_Core_SecHandler::OWNER ? 'No' : 'Yes'); - if (!$secHandler->getPermission(SetaPDF_Core_SecHandler::PERM_PRINT)) { + if (!$secHandler->getPermission(\SetaPDF_Core_SecHandler::PERM_PRINT)) { $data['Printing'] = 'No'; - } elseif ($secHandler->getPermission(SetaPDF_Core_SecHandler::PERM_DIGITAL_PRINT)) { + } elseif ($secHandler->getPermission(\SetaPDF_Core_SecHandler::PERM_DIGITAL_PRINT)) { $data['Printing'] = 'High Resolution'; } else { $data['Printing'] = 'Low Resolution (150 dpi)'; } - $modify = $secHandler->getPermission(SetaPDF_Core_SecHandler::PERM_MODIFY); + $modify = $secHandler->getPermission(\SetaPDF_Core_SecHandler::PERM_MODIFY); $data['Changing the Document'] = $modify ? 'Allowed' : 'Not Allowed'; - $annot = $secHandler->getPermission(SetaPDF_Core_SecHandler::PERM_ANNOT); + $annot = $secHandler->getPermission(\SetaPDF_Core_SecHandler::PERM_ANNOT); $data['Commenting'] = $modify || $annot ? 'Allowed' : 'Not Allowed'; $data['Form Field Fill-in or Signing'] = ( $modify || $annot - || $secHandler->getPermission(SetaPDF_Core_SecHandler::PERM_FILL_FORM) + || $secHandler->getPermission(\SetaPDF_Core_SecHandler::PERM_FILL_FORM) ) ? 'Allowed' : 'Not Allowed'; $data['Document Assembly'] = - ($modify || $secHandler->getPermission(SetaPDF_Core_SecHandler::PERM_ASSEMBLE)) + ($modify || $secHandler->getPermission(\SetaPDF_Core_SecHandler::PERM_ASSEMBLE)) ? 'Allowed' : 'Not Allowed'; - $copy = $secHandler->getPermission(SetaPDF_Core_SecHandler::PERM_COPY); + $copy = $secHandler->getPermission(\SetaPDF_Core_SecHandler::PERM_COPY); $data['Content Copying'] = $copy ? 'Allowed' : 'Not Allowed'; $data['Content Accessibility Enabled'] = - ($copy || $secHandler->getPermission(SetaPDF_Core_SecHandler::PERM_ACCESSIBILITY)) + ($copy || $secHandler->getPermission(\SetaPDF_Core_SecHandler::PERM_ACCESSIBILITY)) ? 'Allowed' : 'Not Allowed'; $data['Page Extraction'] = - $secHandler->getAuthMode() === SetaPDF_Core_SecHandler::OWNER ? 'Allowed' : 'Not Allowed'; + $secHandler->getAuthMode() === \SetaPDF_Core_SecHandler::OWNER ? 'Allowed' : 'Not Allowed'; list($algorithm, $keyLength) = $secHandler->getStringAlgorithm(); - if ($algorithm & SetaPDF_Core_SecHandler::ARCFOUR) { + if ($algorithm & \SetaPDF_Core_SecHandler::ARCFOUR) { $data['Encryption Level'] = ($keyLength * 8) . '-bit RC4'; - } elseif ($algorithm & SetaPDF_Core_SecHandler::AES) { + } elseif ($algorithm & \SetaPDF_Core_SecHandler::AES) { $data['Encryption Level'] = ($keyLength * 8) . '-bit AES'; } } diff --git a/public/demos/1-Core/analyze/check-for-pdfa-information/script.php b/public/demos/1-Core/analyze/check-for-pdfa-information/script.php index 5be84ab..0c7f674 100644 --- a/public/demos/1-Core/analyze/check-for-pdfa-information/script.php +++ b/public/demos/1-Core/analyze/check-for-pdfa-information/script.php @@ -12,10 +12,10 @@ $path = displayFiles($files); -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $metadata = $document->getInfo()->getMetadata(); -$xpath = new DOMXPath($metadata); +$xpath = new \DOMXPath($metadata); $xpath->registerNamespace('x', 'adobe:ns:meta/'); $xpath->registerNamespace('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); $xpath->registerNamespace('pdfaid', 'http://www.aiim.org/pdfa/ns/id/'); diff --git a/public/demos/1-Core/analyze/check-for-text/script.php b/public/demos/1-Core/analyze/check-for-text/script.php index d41afd5..90fb4eb 100644 --- a/public/demos/1-Core/analyze/check-for-text/script.php +++ b/public/demos/1-Core/analyze/check-for-text/script.php @@ -19,7 +19,7 @@ require_once $classesDirectory . '/ContentStreamProcessor/TextProcessor.php'; // load a document instance -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); // get access to the pages object $pages = $document->getCatalog()->getPages(); diff --git a/public/demos/1-Core/analyze/check-for-transparency/script.php b/public/demos/1-Core/analyze/check-for-transparency/script.php index e0a1093..b19eb74 100644 --- a/public/demos/1-Core/analyze/check-for-transparency/script.php +++ b/public/demos/1-Core/analyze/check-for-transparency/script.php @@ -14,7 +14,7 @@ // require the text processor class require_once $classesDirectory . '/Inspector/TransparencyInspector.php'; -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $inspector = new TransparencyInspector($document); $transparencyElements = $inspector->process(); diff --git a/public/demos/1-Core/analyze/get-color-spaces/description.html b/public/demos/1-Core/analyze/get-color-spaces/description.html index 0d38db7..774341f 100644 --- a/public/demos/1-Core/analyze/get-color-spaces/description.html +++ b/public/demos/1-Core/analyze/get-color-spaces/description.html @@ -2,7 +2,7 @@ This script extracts all color related information from an existing PDF file.

- It makes use of the SetaPDF_Core_Parser_Content class which encapsulate a content stream, + It makes use of the \SetaPDF_Core_Parser_Content class which encapsulate a content stream, process it and call registered callback methods on specific operators.

diff --git a/public/demos/1-Core/analyze/get-color-spaces/script.php b/public/demos/1-Core/analyze/get-color-spaces/script.php index 3b6ae2a..9ef0d69 100644 --- a/public/demos/1-Core/analyze/get-color-spaces/script.php +++ b/public/demos/1-Core/analyze/get-color-spaces/script.php @@ -16,7 +16,7 @@ require_once $classesDirectory . '/ContentStreamProcessor/ColorProcessor.php'; require_once $classesDirectory . '/Inspector/ColorInspector.php'; -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $inspector = new ColorInspector($document); $colors = $inspector->getColors(); @@ -39,18 +39,18 @@ echo $color['colorSpace'] . ': ' . $className . "\n"; switch (true) { - case ($data instanceof SetaPDF_Core_ColorSpace_Separation): + case ($data instanceof \SetaPDF_Core_ColorSpace_Separation): echo ' Name: ' . $data->getName() . "\n"; echo ' Alt: ' . $data->getAlternateColorSpace()->getFamily() . "\n"; break; - case ($data instanceof SetaPDF_Core_ColorSpace_IccBased): + case ($data instanceof \SetaPDF_Core_ColorSpace_IccBased): $parser = $data->getIccProfileStream()->getParser(); echo ' Description: ' . $parser->getDescription() . "\n"; echo ' Number of components: ' . $parser->getNumberOfComponents() . "\n"; break; - case ($data instanceof SetaPDF_Core_ColorSpace_DeviceN): + case ($data instanceof \SetaPDF_Core_ColorSpace_DeviceN): echo ' Names: ' . implode(', ', $data->getNames()) . "\n"; echo ' Alt: ' . $data->getAlternateColorSpace()->getFamily() . "\n"; break; diff --git a/public/demos/1-Core/analyze/get-fonts/script.php b/public/demos/1-Core/analyze/get-fonts/script.php index 57c9fc0..1a8e2c9 100644 --- a/public/demos/1-Core/analyze/get-fonts/script.php +++ b/public/demos/1-Core/analyze/get-fonts/script.php @@ -20,7 +20,7 @@ foreach ($fontObjects AS $fontObject) { try { - $font = SetaPDF_Core_Font::get($fontObject); + $font = \SetaPDF_Core_Font::get($fontObject); } catch (Exception $e) { echo $e->getMessage(); continue; diff --git a/public/demos/1-Core/analyze/get-images-size-and-resolution/script.php b/public/demos/1-Core/analyze/get-images-size-and-resolution/script.php index ab7dc26..400a5f5 100644 --- a/public/demos/1-Core/analyze/get-images-size-and-resolution/script.php +++ b/public/demos/1-Core/analyze/get-images-size-and-resolution/script.php @@ -19,7 +19,7 @@ if (!isset($_GET['p'])) { // load a document instance - $document = SetaPDF_Core_Document::loadByFilename($path); + $document = \SetaPDF_Core_Document::loadByFilename($path); // get access to the pages object $pages = $document->getCatalog()->getPages(); @@ -60,8 +60,8 @@ } else { // let's create a writer and document instance - $writer = new SetaPDF_Core_Writer_Http('marked.pdf', true); - $document = SetaPDF_Core_Document::loadByFilename($path, $writer); + $writer = new \SetaPDF_Core_Writer_Http('marked.pdf', true); + $document = \SetaPDF_Core_Document::loadByFilename($path, $writer); // get access to the pages object $pages = $document->getCatalog()->getPages(); @@ -70,8 +70,8 @@ $page = $pages->getPage($_GET['p']); // set an open action, so that the page is shown when opened (requires support of the reader application) - $dest = SetaPDF_Core_Document_Destination::createByPage($page); - $document->getCatalog()->setOpenAction(new SetaPDF_Core_Document_Action_GoTo($dest)); + $dest = \SetaPDF_Core_Document_Destination::createByPage($page); + $document->getCatalog()->setOpenAction(new \SetaPDF_Core_Document_Action_GoTo($dest)); // get access to the pages canvas $canvas = $page->getCanvas(); diff --git a/public/demos/1-Core/annotations/add-link/script.php b/public/demos/1-Core/annotations/add-link/script.php index d663fd0..8c414ec 100644 --- a/public/demos/1-Core/annotations/add-link/script.php +++ b/public/demos/1-Core/annotations/add-link/script.php @@ -3,30 +3,30 @@ // load and register the autoload function require_once '../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('link.pdf', true); -$document = new SetaPDF_Core_Document($writer); +$writer = new \SetaPDF_Core_Writer_Http('link.pdf', true); +$document = new \SetaPDF_Core_Document($writer); // get access to the pages $pages = $document->getCatalog()->getPages(); // create a new page -$page = $pages->create(SetaPDF_Core_PageFormats::A4); +$page = $pages->create(\SetaPDF_Core_PageFormats::A4); // access its canvas $canvas = $page->getCanvas(); // create a font instance -$font = SetaPDF_Core_Font_Standard_Helvetica::create($document); +$font = \SetaPDF_Core_Font_Standard_Helvetica::create($document); // use the text block helper to draw the text -$text = new SetaPDF_Core_Text_Block($font, 12); +$text = new \SetaPDF_Core_Text_Block($font, 12); $text->setText('This is a link to www.setasign.com!'); $x = $page->getWidth() / 2 - $text->getWidth() / 2; $y = $page->getHeight() - 100; $text->draw($canvas, $x, $y); // create the link annotation -$link = new SetaPDF_Core_Document_Page_Annotation_Link( +$link = new \SetaPDF_Core_Document_Page_Annotation_Link( [$x, $y, $x + $text->getWidth(), $y + $text->getHeight()], - new SetaPDF_Core_Document_Action_Uri('https://www.setasign.com') + new \SetaPDF_Core_Document_Action_Uri('https://www.setasign.com') ); // and add it $page->getAnnotations()->add($link); diff --git a/public/demos/1-Core/annotations/add-push-buttons/script.php b/public/demos/1-Core/annotations/add-push-buttons/script.php index 6aa6265..f94f213 100644 --- a/public/demos/1-Core/annotations/add-push-buttons/script.php +++ b/public/demos/1-Core/annotations/add-push-buttons/script.php @@ -7,10 +7,10 @@ // if we have a post request, just dump the data if (count($_POST) > 0) { - $writer = new SetaPDF_Core_Writer_Http(); - $document = new SetaPDF_Core_Document($writer); + $writer = new \SetaPDF_Core_Writer_Http(); + $document = new \SetaPDF_Core_Document($writer); $canvas = $document->getCatalog()->getPages()->create('a4')->getCanvas(); - $text = new SetaPDF_Core_Text_Block(SetaPDF_Core_Font_Standard_Courier::create($document), 12); + $text = new \SetaPDF_Core_Text_Block(\SetaPDF_Core_Font_Standard_Courier::create($document), 12); $text->setText(print_r($_POST, true)); $text->draw($canvas, 0, $canvas->getHeight() - $text->getHeight()); $document->save()->finish(); @@ -29,8 +29,8 @@ //$pdfFile = $assetsDirectory . '/pdfs/tektown/Order-Form.pdf'; $pdfFile = $assetsDirectory . '/pdfs/tektown/Subscription-tekMag.pdf'; -$writer = new SetaPDF_Core_Writer_Http('push-buttons.pdf', false); -$document = SetaPDF_Core_Document::loadByFilename($pdfFile, $writer); +$writer = new \SetaPDF_Core_Writer_Http('push-buttons.pdf', false); +$document = \SetaPDF_Core_Document::loadByFilename($pdfFile, $writer); // let's get the page to which we want to add the button to $pages = $document->getCatalog()->getPages(); @@ -47,13 +47,13 @@ $pb->setCaption('Submit'); $pb->setFontSize(12); $pb->setTextColor([0]); -$font = SetaPDF_Core_Font_Standard_Helvetica::create($document); +$font = \SetaPDF_Core_Font_Standard_Helvetica::create($document); $pb->setFont($font); // Define the border and style $pb->getBorderStyle() ->setWidth(1) - ->setStyle(SetaPDF_Core_Document_Page_Annotation_BorderStyle::BEVELED); + ->setStyle(\SetaPDF_Core_Document_Page_Annotation_BorderStyle::BEVELED); // Set some appearance characteristics $pb->getAppearanceCharacteristics(true) @@ -62,10 +62,10 @@ // Create a SubmitForm action $target = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; -$action = new SetaPDF_Core_Document_Action_SubmitForm($target); +$action = new \SetaPDF_Core_Document_Action_SubmitForm($target); $action->setFlags( - SetaPDF_Core_Document_Action_SubmitForm::FLAG_EXPORT_FORMAT | /* HTTP POST */ - SetaPDF_Core_Document_Action_SubmitForm::FLAG_INCLUDE_NO_VALUE_FIELDS /* Send also empty fields */ + \SetaPDF_Core_Document_Action_SubmitForm::FLAG_EXPORT_FORMAT | /* HTTP POST */ + \SetaPDF_Core_Document_Action_SubmitForm::FLAG_INCLUDE_NO_VALUE_FIELDS /* Send also empty fields */ ); // Attach the action to the button $pb->setAction($action); @@ -92,7 +92,7 @@ // Define the border and style $pb->getBorderStyle() ->setWidth(1) - ->setStyle(SetaPDF_Core_Document_Page_Annotation_BorderStyle::BEVELED); + ->setStyle(\SetaPDF_Core_Document_Page_Annotation_BorderStyle::BEVELED); // Set some appearance characteristics $pb->getAppearanceCharacteristics(true) @@ -128,7 +128,7 @@ JS; // create the action -$action = new SetaPDF_Core_Document_Action_JavaScript($javaScript); +$action = new \SetaPDF_Core_Document_Action_JavaScript($javaScript); // add it to the button $pb->setAction($action); diff --git a/public/demos/1-Core/annotations/add-stamp-annotation/script.php b/public/demos/1-Core/annotations/add-stamp-annotation/script.php index 281ac38..1940627 100644 --- a/public/demos/1-Core/annotations/add-stamp-annotation/script.php +++ b/public/demos/1-Core/annotations/add-stamp-annotation/script.php @@ -1,6 +1,6 @@ getCatalog()->getPages()->create(SetaPDF_Core_PageFormats::A4); +$page = $document->getCatalog()->getPages()->create(\SetaPDF_Core_PageFormats::A4); -$stampAppearances = SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/stamps.pdf'); +$stampAppearances = \SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/stamps.pdf'); $appearancePageNo = $iconNameToPageNo[$iconName]; if (isset($appearancePageNo)) { $appearance = $stampAppearances->getCatalog()->getPages()->getPage($appearancePageNo)->toXObject($document); diff --git a/public/demos/1-Core/annotations/add-text-fields/script.php b/public/demos/1-Core/annotations/add-text-fields/script.php index 8e0a0a4..4b4d083 100644 --- a/public/demos/1-Core/annotations/add-text-fields/script.php +++ b/public/demos/1-Core/annotations/add-text-fields/script.php @@ -8,12 +8,12 @@ // require the text field class require_once('../../../../../classes/Annotation/Widget/TextField.php'); -$writer = new SetaPDF_Core_Writer_Http('TextFields.pdf', true); -$document = new SetaPDF_Core_Document($writer); +$writer = new \SetaPDF_Core_Writer_Http('TextFields.pdf', true); +$document = new \SetaPDF_Core_Document($writer); // let's create a page to which we want to add the fields to $pages = $document->getCatalog()->getPages(); -$page = $pages->create(SetaPDF_Core_PageFormats::A4); +$page = $pages->create(\SetaPDF_Core_PageFormats::A4); // prepare some variables we need later $acroForm = $document->getCatalog()->getAcroForm(); @@ -40,11 +40,11 @@ ]; $borderStyles = [ - SetaPDF_Core_Document_Page_Annotation_BorderStyle::BEVELED, - SetaPDF_Core_Document_Page_Annotation_BorderStyle::DASHED, - SetaPDF_Core_Document_Page_Annotation_BorderStyle::INSET, - SetaPDF_Core_Document_Page_Annotation_BorderStyle::SOLID, - SetaPDF_Core_Document_Page_Annotation_BorderStyle::UNDERLINE + \SetaPDF_Core_Document_Page_Annotation_BorderStyle::BEVELED, + \SetaPDF_Core_Document_Page_Annotation_BorderStyle::DASHED, + \SetaPDF_Core_Document_Page_Annotation_BorderStyle::INSET, + \SetaPDF_Core_Document_Page_Annotation_BorderStyle::SOLID, + \SetaPDF_Core_Document_Page_Annotation_BorderStyle::UNDERLINE ]; $borderSizes = [1, 2, 3, 4]; @@ -52,9 +52,9 @@ $fontSizes = [0, 5, 8, 10, 12, 18, 24]; $aligns = [ - SetaPDF_Core_Text::ALIGN_LEFT, - SetaPDF_Core_Text::ALIGN_CENTER, - SetaPDF_Core_Text::ALIGN_RIGHT + \SetaPDF_Core_Text::ALIGN_LEFT, + \SetaPDF_Core_Text::ALIGN_CENTER, + \SetaPDF_Core_Text::ALIGN_RIGHT ]; // let's define the postion of the first field @@ -62,7 +62,7 @@ $y = $page->getCropBox()->getUrY() - 5; // we use the same font for all fields -$font = SetaPDF_Core_Font_Standard_Helvetica::create($document); +$font = \SetaPDF_Core_Font_Standard_Helvetica::create($document); // let's create 18 text fields with random properties for ($i = 0; $i < 18; $i++) { diff --git a/public/demos/1-Core/annotations/flatten/script.php b/public/demos/1-Core/annotations/flatten/script.php index 04e05a6..1446dcb 100644 --- a/public/demos/1-Core/annotations/flatten/script.php +++ b/public/demos/1-Core/annotations/flatten/script.php @@ -17,13 +17,13 @@ $path = displayFiles($files); -$writer = new SetaPDF_Core_Writer_Http('flatten-annotations.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename($path, $writer); +$writer = new \SetaPDF_Core_Writer_Http('flatten-annotations.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename($path, $writer); $pages = $document->getCatalog()->getPages(); $pageCount = $pages->count(); -function flattenAnnotation(SetaPDF_Core_Document_Page $page, SetaPDF_Core_Document_Page_Annotation $annotation) +function flattenAnnotation(\SetaPDF_Core_Document_Page $page, \SetaPDF_Core_Document_Page_Annotation $annotation) { $appearance = $annotation->getAppearance(); if ( @@ -46,12 +46,12 @@ function flattenAnnotation(SetaPDF_Core_Document_Page $page, SetaPDF_Core_Docume $matrix = $appearance->getMatrix(); if ($matrix === false) { - $matrix = new SetaPDF_Core_Geometry_Matrix(); + $matrix = new \SetaPDF_Core_Geometry_Matrix(); } - $t = new SetaPDF_Core_Geometry_Rectangle( - SetaPDF_Core_Geometry_Vector::byPoint($bbox->getLl())->multiply($matrix)->toPoint(), - SetaPDF_Core_Geometry_Vector::byPoint($bbox->getUr())->multiply($matrix)->toPoint() + $t = new \SetaPDF_Core_Geometry_Rectangle( + \SetaPDF_Core_Geometry_Vector::byPoint($bbox->getLl())->multiply($matrix)->toPoint(), + \SetaPDF_Core_Geometry_Vector::byPoint($bbox->getUr())->multiply($matrix)->toPoint() ); if (empty($t->getHeight()) || empty($t->getWidth())) { @@ -60,8 +60,8 @@ function flattenAnnotation(SetaPDF_Core_Document_Page $page, SetaPDF_Core_Docume $ll = $rect->getLl(); - $m = new SetaPDF_Core_Geometry_Matrix(1, 0, 0, 1, $ll->getX(), $ll->getY()); - $scaleMatrix = new SetaPDF_Core_Geometry_Matrix( + $m = new \SetaPDF_Core_Geometry_Matrix(1, 0, 0, 1, $ll->getX(), $ll->getY()); + $scaleMatrix = new \SetaPDF_Core_Geometry_Matrix( ($rect->getWidth()) / ($t->getWidth()), 0, 0, @@ -70,7 +70,7 @@ function flattenAnnotation(SetaPDF_Core_Document_Page $page, SetaPDF_Core_Docume 0 ); $m = $scaleMatrix->multiply($m); - $translateMatrix2 = new SetaPDF_Core_Geometry_Matrix(1, 0, 0, 1, -$t->getLl()->getX(), -$t->getLl()->getY()); + $translateMatrix2 = new \SetaPDF_Core_Geometry_Matrix(1, 0, 0, 1, -$t->getLl()->getX(), -$t->getLl()->getY()); $m = $translateMatrix2->multiply($m); $canvas->addCurrentTransformationMatrix( @@ -94,7 +94,7 @@ function flattenAnnotation(SetaPDF_Core_Document_Page $page, SetaPDF_Core_Docume $allAnnotations = $annotations->getAll(); foreach ($allAnnotations as $k => $annotation) { - if ($annotation instanceof SetaPDF_Core_Document_Page_Annotation_Widget) { + if ($annotation instanceof \SetaPDF_Core_Document_Page_Annotation_Widget) { continue; } diff --git a/public/demos/1-Core/annotations/get-form-fields-information/script.php b/public/demos/1-Core/annotations/get-form-fields-information/script.php index accef07..07ad902 100644 --- a/public/demos/1-Core/annotations/get-form-fields-information/script.php +++ b/public/demos/1-Core/annotations/get-form-fields-information/script.php @@ -14,7 +14,7 @@ $path = displayFiles($files); // create a document instance -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); // Get the pages helper $pages = $document->getCatalog()->getPages(); @@ -26,12 +26,12 @@ // get the annotation helper $annotationsHelper = $page->getAnnotations(); - $widgetAnnotations = $annotationsHelper->getAll(SetaPDF_Core_Document_Page_Annotation::TYPE_WIDGET); + $widgetAnnotations = $annotationsHelper->getAll(\SetaPDF_Core_Document_Page_Annotation::TYPE_WIDGET); echo '

' . count($widgetAnnotations) . ' widget annotations found.

'; - /* @var SetaPDF_Core_Document_Page_Annotation_Widget $widgetAnnotation */ + /* @var \SetaPDF_Core_Document_Page_Annotation_Widget $widgetAnnotation */ foreach ($widgetAnnotations AS $widgetAnnotation) { - $fieldName = SetaPDF_Core_Document_Catalog_AcroForm::resolveFieldName( + $fieldName = \SetaPDF_Core_Document_Catalog_AcroForm::resolveFieldName( $widgetAnnotation->getIndirectObject()->ensure() ); @@ -46,11 +46,11 @@ echo ' height: ' . $rect->getHeight() . "\n"; // get the field value - $value = SetaPDF_Core_Type_Dictionary_Helper::resolveAttribute($widgetAnnotation->getDictionary(), 'V'); + $value = \SetaPDF_Core_Type_Dictionary_Helper::resolveAttribute($widgetAnnotation->getDictionary(), 'V'); // limited to string values for demonstration purpose - if ($value instanceof SetaPDF_Core_Type_StringValue) { + if ($value instanceof \SetaPDF_Core_Type_StringValue) { echo ' value: '; - echo SetaPDF_Core_Encoding::convertPdfString($value->getValue()); + echo \SetaPDF_Core_Encoding::convertPdfString($value->getValue()); } echo "
"; diff --git a/public/demos/1-Core/annotations/get-link-annotations/script.php b/public/demos/1-Core/annotations/get-link-annotations/script.php index 96d1140..d6c978c 100644 --- a/public/demos/1-Core/annotations/get-link-annotations/script.php +++ b/public/demos/1-Core/annotations/get-link-annotations/script.php @@ -14,7 +14,7 @@ $path = displayFiles($files); // create a document -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); // Get the pages helper $pages = $document->getCatalog()->getPages(); @@ -23,17 +23,17 @@ $linksFound = false; for ($pageNo = 1, $pageCount = $pages->count(); $pageNo <= $pageCount; $pageNo++) { $page = $pages->getPage($pageNo); - $linkAnnotations = $page->getAnnotations()->getAll(SetaPDF_Core_Document_Page_Annotation::TYPE_LINK); + $linkAnnotations = $page->getAnnotations()->getAll(\SetaPDF_Core_Document_Page_Annotation::TYPE_LINK); - /** @var SetaPDF_Core_Document_Page_Annotation_Link $linkAnnotation */ + /** @var \SetaPDF_Core_Document_Page_Annotation_Link $linkAnnotation */ foreach ($linkAnnotations AS $linkAnnotation) { $action = $linkAnnotation->getAction(); $destination = $linkAnnotation->getDestination(); if ($action || $destination) { echo 'Link Annotation on Page #' . $pageNo . "\n"; - if ($action instanceof SetaPDF_Core_Document_Action_Uri) { + if ($action instanceof \SetaPDF_Core_Document_Action_Uri) { echo ' URI: ' . htmlspecialchars($action->getUri()); - } elseif ($action instanceof SetaPDF_Core_Document_Action_GoTo) { + } elseif ($action instanceof \SetaPDF_Core_Document_Action_GoTo) { $destination = $action->getDestination($document); } diff --git a/public/demos/1-Core/annotations/on-rotated-page/script.php b/public/demos/1-Core/annotations/on-rotated-page/script.php index 1fec9b0..4bae834 100644 --- a/public/demos/1-Core/annotations/on-rotated-page/script.php +++ b/public/demos/1-Core/annotations/on-rotated-page/script.php @@ -1,15 +1,15 @@ getCatalog()->setPageLayout(SetaPDF_Core_Document_PageLayout::SINGLE_PAGE); +$writer = new \SetaPDF_Core_Writer_Http('rotated.pdf', true); +$document = new \SetaPDF_Core_Document($writer); +$document->getCatalog()->setPageLayout(\SetaPDF_Core_Document_PageLayout::SINGLE_PAGE); // let's create a dummy page with the expected format and rotation $page = $document->getCatalog()->getPages()->create($pageConfigs[$pageConfig][2]); @@ -41,7 +41,7 @@ $rotation = $page->getRotation(); // let's get an appearance by using a page of an existing PDF -$stampAppearances = SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/stamps.pdf') +$stampAppearances = \SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/stamps.pdf') ->getCatalog()->getPages()->getPage(1)->toXObject($document); $height = $stampAppearances->getHeight($width); @@ -51,7 +51,7 @@ // depending on the rotation value we need to prepare a graphic state for the position on the page $box = $page->getBoundary(); -$pageGs = new SetaPDF_Core_Canvas_GraphicState(); +$pageGs = new \SetaPDF_Core_Canvas_GraphicState(); switch ($rotation) { case 90: $pageGs->translate($box->getWidth(), 0); @@ -69,7 +69,7 @@ // let's create a helper function to translate coordinates into vectors by using the page graphic state $f = static function($x, $y) use ($pageGs) { - $v = new SetaPDF_Core_Geometry_Vector($x, $y); + $v = new \SetaPDF_Core_Geometry_Vector($x, $y); return $v->multiply($pageGs->getCurrentTransformationMatrix()); }; @@ -80,7 +80,7 @@ $annotation->setIconName(StampAnnotation::ICON_APPROVED); // now we create a new form XObject where we draw the final appearance into -$appearance = SetaPDF_Core_XObject_Form::create($document, [0, 0, $annotation->getWidth(), $annotation->getHeight()]); +$appearance = \SetaPDF_Core_XObject_Form::create($document, [0, 0, $annotation->getWidth(), $annotation->getHeight()]); $canvas = $appearance->getCanvas(); $canvas->saveGraphicState(); diff --git a/public/demos/1-Core/annotations/replace-link-targets/script.php b/public/demos/1-Core/annotations/replace-link-targets/script.php index 2308f5d..f6f3b54 100644 --- a/public/demos/1-Core/annotations/replace-link-targets/script.php +++ b/public/demos/1-Core/annotations/replace-link-targets/script.php @@ -14,9 +14,9 @@ $path = displayFiles($files); // create a writer -$writer = new SetaPDF_Core_Writer_Http('links-replaced.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('links-replaced.pdf', true); // create a document -$document = SetaPDF_Core_Document::loadByFilename($path, $writer); +$document = \SetaPDF_Core_Document::loadByFilename($path, $writer); // Get the pages helper $pages = $document->getCatalog()->getPages(); @@ -24,12 +24,12 @@ $linksFound = false; for ($pageNo = 1, $pageCount = $pages->count(); $pageNo <= $pageCount; $pageNo++) { $page = $pages->getPage($pageNo); - $linkAnnotations = $page->getAnnotations()->getAll(SetaPDF_Core_Document_Page_Annotation::TYPE_LINK); + $linkAnnotations = $page->getAnnotations()->getAll(\SetaPDF_Core_Document_Page_Annotation::TYPE_LINK); - /** @var SetaPDF_Core_Document_Page_Annotation_Link $linkAnnotation */ + /** @var \SetaPDF_Core_Document_Page_Annotation_Link $linkAnnotation */ foreach ($linkAnnotations AS $linkAnnotation) { $action = $linkAnnotation->getAction(); - if ($action && $action instanceof SetaPDF_Core_Document_Action_Uri) { + if ($action && $action instanceof \SetaPDF_Core_Document_Action_Uri) { // simply set the new URI $action->setUri('https://www.setasign.com'); $linksFound = true; diff --git a/public/demos/1-Core/canvas/transparency/script.php b/public/demos/1-Core/canvas/transparency/script.php index 38dcf16..c3e93ea 100644 --- a/public/demos/1-Core/canvas/transparency/script.php +++ b/public/demos/1-Core/canvas/transparency/script.php @@ -4,22 +4,22 @@ require_once '../../../../../bootstrap.php'; // create a writer instance -$writer = new SetaPDF_Core_Writer_Http('transparency.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('transparency.pdf', true); // create a document instance -$document = new SetaPDF_Core_Document($writer); +$document = new \SetaPDF_Core_Document($writer); $pages = $document->getCatalog()->getPages(); -$page = $pages->create(SetaPDF_Core_PageFormats::A4); +$page = $pages->create(\SetaPDF_Core_PageFormats::A4); -$image = SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/fuchslocher/green-morning.jpg')->toXObject($document); +$image = \SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/fuchslocher/green-morning.jpg')->toXObject($document); $canvas = $page->getCanvas(); $image->draw($canvas, 30, 600, 250); // create a graphic state with opacity set to 0.7 -$gs = new SetaPDF_Core_Resource_ExtGState(); +$gs = new \SetaPDF_Core_Resource_ExtGState(); $gs->setConstantOpacity(.7); $gs->setConstantOpacityNonStroking(.7); $gs->getIndirectObject($document); @@ -31,7 +31,7 @@ $canvas->restoreGraphicState(); // create a graphic state with opacity set to 0.4 -$gs = new SetaPDF_Core_Resource_ExtGState(); +$gs = new \SetaPDF_Core_Resource_ExtGState(); $gs->setConstantOpacity(.4); $gs->setConstantOpacityNonStroking(.4); $gs->getIndirectObject($document); @@ -43,7 +43,7 @@ $canvas->restoreGraphicState(); // create a graphic state with opacity set to 0.1 -$gs = new SetaPDF_Core_Resource_ExtGState(); +$gs = new \SetaPDF_Core_Resource_ExtGState(); $gs->setConstantOpacity(.1); $gs->setConstantOpacityNonStroking(.1); $gs->getIndirectObject($document); diff --git a/public/demos/1-Core/document/encrypt-with-password/script.php b/public/demos/1-Core/document/encrypt-with-password/script.php index 9805be4..a6b6876 100644 --- a/public/demos/1-Core/document/encrypt-with-password/script.php +++ b/public/demos/1-Core/document/encrypt-with-password/script.php @@ -13,18 +13,18 @@ $path = displayFiles($files, false); // create a writer instance -$writer = new SetaPDF_Core_Writer_Http('encrypted.pdf'); +$writer = new \SetaPDF_Core_Writer_Http('encrypted.pdf'); // create a document instance -$document = SetaPDF_Core_Document::loadByFilename($path, $writer); +$document = \SetaPDF_Core_Document::loadByFilename($path, $writer); // create a security handler instance -$secHandler = SetaPDF_Core_SecHandler_Standard_Aes256::factory( +$secHandler = \SetaPDF_Core_SecHandler_Standard_Aes256::factory( $document, 'owner', 'user', // allow the user to print the document in high quality - SetaPDF_Core_SecHandler::PERM_PRINT | SetaPDF_Core_SecHandler::PERM_DIGITAL_PRINT + \SetaPDF_Core_SecHandler::PERM_PRINT | \SetaPDF_Core_SecHandler::PERM_DIGITAL_PRINT ); // pass it to the document instance diff --git a/public/demos/1-Core/document/extract-attachments/script.php b/public/demos/1-Core/document/extract-attachments/script.php index 6fedfa0..6fa5d29 100644 --- a/public/demos/1-Core/document/extract-attachments/script.php +++ b/public/demos/1-Core/document/extract-attachments/script.php @@ -12,7 +12,7 @@ $path = displayFiles($files); // create a document -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); // get names $names = $document->getCatalog()->getNames(); @@ -22,7 +22,7 @@ // extract the file if (isset($_GET['name'])) { $file = $embeddedFiles->get($_GET['name']); - if ($file instanceof SetaPDF_Core_FileSpecification) { + if ($file instanceof \SetaPDF_Core_FileSpecification) { // resolve the filename $filename = $file->getFileSpecification(); // resolve the file stream @@ -36,7 +36,7 @@ // pass the file to the client $stream = $embeddedFileStream->getStream(); header('Content-Type: ' . $contentType); - header('Content-Disposition: attachment; ' . SetaPDF_Core_Writer_Http::encodeFilenameForHttpHeader($filename)); + header('Content-Disposition: attachment; ' . \SetaPDF_Core_Writer_Http::encodeFilenameForHttpHeader($filename)); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . strlen($stream)); echo $stream; @@ -51,8 +51,8 @@ $size = null; $params = $file->getEmbeddedFileStream()->getParams(); - if (isset($params[SetaPDF_Core_EmbeddedFileStream::PARAM_SIZE])) { - $size = $params[SetaPDF_Core_EmbeddedFileStream::PARAM_SIZE]; + if (isset($params[\SetaPDF_Core_EmbeddedFileStream::PARAM_SIZE])) { + $size = $params[\SetaPDF_Core_EmbeddedFileStream::PARAM_SIZE]; } echo ''; diff --git a/public/demos/1-Core/document/get-metadata/script.php b/public/demos/1-Core/document/get-metadata/script.php index cfc8252..7cc4dce 100644 --- a/public/demos/1-Core/document/get-metadata/script.php +++ b/public/demos/1-Core/document/get-metadata/script.php @@ -14,7 +14,7 @@ $path = displayFiles($files); // create a document instance -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); // get the documents info dictionary helper $info = $document->getInfo(); diff --git a/public/demos/1-Core/document/multiple-pages-per-sheet/script.php b/public/demos/1-Core/document/multiple-pages-per-sheet/script.php index 8fe8741..864a9f9 100644 --- a/public/demos/1-Core/document/multiple-pages-per-sheet/script.php +++ b/public/demos/1-Core/document/multiple-pages-per-sheet/script.php @@ -30,7 +30,7 @@ } // load the original document -$originalDocument = SetaPDF_Core_Document::loadByFilename($path); +$originalDocument = \SetaPDF_Core_Document::loadByFilename($path); // get the pages instance of the original document $originalPages = $originalDocument->getCatalog()->getPages(); @@ -43,10 +43,10 @@ $shortSide = array_keys($pageSize, min($pageSize))[0]; // create a new writer for the new document -$writer = new SetaPDF_Core_Writer_Http(basename($path), true); +$writer = new \SetaPDF_Core_Writer_Http(basename($path), true); // create a new document -$newDocument = new SetaPDF_Core_Document($writer); +$newDocument = new \SetaPDF_Core_Document($writer); // get the pages instance of the new document $newPages = $newDocument->getCatalog()->getPages(); @@ -66,7 +66,7 @@ // create the new pages for ($newPageNumber = 1; $newPageNumber <= $finalPageCount; $newPageNumber++) { // create a new page - $newPage = $newPages->create($newPageSize, SetaPDF_Core_PageFormats::ORIENTATION_AUTO); + $newPage = $newPages->create($newPageSize, \SetaPDF_Core_PageFormats::ORIENTATION_AUTO); // prepare an offset to access the pages of the original document $pageOffset = ($newPageNumber - 1) * $perSheet; @@ -95,7 +95,7 @@ ); $pos[0] -= $pageSize[0]; - if ($pos[0] < SetaPDF_Core::FLOAT_COMPARISON_PRECISION) { + if ($pos[0] < \SetaPDF_Core::FLOAT_COMPARISON_PRECISION) { $pos[1] += $pageSize[1]; $pos[0] = $newPageSize[0]; } diff --git a/public/demos/1-Core/document/remove-digital-signatures/script.php b/public/demos/1-Core/document/remove-digital-signatures/script.php index ee73cf4..c74aacc 100644 --- a/public/demos/1-Core/document/remove-digital-signatures/script.php +++ b/public/demos/1-Core/document/remove-digital-signatures/script.php @@ -12,19 +12,19 @@ $path = displayFiles($files, false); -$writer = new SetaPDF_Core_Writer_Http(basename($path)); -$document = SetaPDF_Core_Document::loadByFilename($path, $writer); +$writer = new \SetaPDF_Core_Writer_Http(basename($path)); +$document = \SetaPDF_Core_Document::loadByFilename($path, $writer); // get all terminal fields $terminalFields = $document->getCatalog()->getAcroForm()->getTerminalFieldsObjects(); // iterate over the fields foreach ($terminalFields AS $fieldData) { - /** @var SetaPDF_Core_Type_Dictionary $fieldData */ + /** @var \SetaPDF_Core_Type_Dictionary $fieldData */ $fieldData = $fieldData->ensure(); // ensure that the field is a signature field - $ft = SetaPDF_Core_Type_Dictionary_Helper::resolveAttribute($fieldData, 'FT'); + $ft = \SetaPDF_Core_Type_Dictionary_Helper::resolveAttribute($fieldData, 'FT'); if (!$ft || $ft->getValue() !== 'Sig') { continue; } @@ -43,11 +43,11 @@ continue; } - /** @var SetaPDF_Core_Type_Dictionary $ap */ + /** @var \SetaPDF_Core_Type_Dictionary $ap */ $ap = $ap->ensure(); $n = $ap->getValue('N'); if ($n) { - /** @var SetaPDF_Core_Type_Stream $n */ + /** @var \SetaPDF_Core_Type_Stream $n */ $n = $n->ensure(); $n->setStream('%% Blank'); } diff --git a/public/demos/1-Core/document/remove-usage-rights/script.php b/public/demos/1-Core/document/remove-usage-rights/script.php index d170c30..8d63c5f 100644 --- a/public/demos/1-Core/document/remove-usage-rights/script.php +++ b/public/demos/1-Core/document/remove-usage-rights/script.php @@ -12,7 +12,7 @@ $path = displayFiles($files, false); // create a document -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $permissions = $document->getCatalog()->getPermissions(); @@ -22,7 +22,7 @@ $permissions->removeUsageRights(); // save the document - $document->setWriter(new SetaPDF_Core_Writer_Http('no-usage-rights.pdf')); + $document->setWriter(new \SetaPDF_Core_Writer_Http('no-usage-rights.pdf')); $document->save()->finish(); } else { echo 'No usage rights found.'; diff --git a/public/demos/1-Core/document/set-metadata/script.php b/public/demos/1-Core/document/set-metadata/script.php index e0ee66a..3ee5007 100644 --- a/public/demos/1-Core/document/set-metadata/script.php +++ b/public/demos/1-Core/document/set-metadata/script.php @@ -13,9 +13,9 @@ $path = displayFiles($files); // create a writer instance -$writer = new SetaPDF_Core_Writer_Http('updated-metadata.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('updated-metadata.pdf', true); // create a document instance -$document = SetaPDF_Core_Document::loadByFilename($path, $writer); +$document = \SetaPDF_Core_Document::loadByFilename($path, $writer); // get the info helper object $info = $document->getInfo(); diff --git a/public/demos/1-Core/document/tile-page/script.php b/public/demos/1-Core/document/tile-page/script.php index 0cdbfd6..d297669 100644 --- a/public/demos/1-Core/document/tile-page/script.php +++ b/public/demos/1-Core/document/tile-page/script.php @@ -32,21 +32,21 @@ // determine the orientation of the new document if ($gridSizeX === $gridSizeY) { - $orientation = SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT; + $orientation = \SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT; } else { - $orientation = SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE; + $orientation = \SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE; } // load the original document -$originalDocument = SetaPDF_Core_Document::loadByFilename($path); +$originalDocument = \SetaPDF_Core_Document::loadByFilename($path); // get the pages instance of the original document $originalPages = $originalDocument->getCatalog()->getPages(); // create a new writer for the new document -$writer = new SetaPDF_Core_Writer_Http(basename($path), true); +$writer = new \SetaPDF_Core_Writer_Http(basename($path), true); // create a new document -$newDocument = new SetaPDF_Core_Document($writer); +$newDocument = new \SetaPDF_Core_Document($writer); // get the pages instance of the new document $newPages = $newDocument->getCatalog()->getPages(); @@ -59,7 +59,7 @@ $pageXObject = $originalPage->toXObject($newDocument); // get the width and height in the correct orientation -$pageFormat = SetaPDF_Core_PageFormats::getFormat($originalPage->getWidthAndHeight(), $orientation); +$pageFormat = \SetaPDF_Core_PageFormats::getFormat($originalPage->getWidthAndHeight(), $orientation); // calculate the new width and height for the XObject. $objectWidth = $pageFormat['width'] * $gridSizeX; @@ -93,5 +93,5 @@ } } -$newDocument->getCatalog()->setPageLayout(SetaPDF_Core_Document_PageLayout::TWO_COLUMN_LEFT); +$newDocument->getCatalog()->setPageLayout(\SetaPDF_Core_Document_PageLayout::TWO_COLUMN_LEFT); $newDocument->save()->finish(); \ No newline at end of file diff --git a/public/demos/1-Core/images/add-image/script.php b/public/demos/1-Core/images/add-image/script.php index 638d09c..727b476 100644 --- a/public/demos/1-Core/images/add-image/script.php +++ b/public/demos/1-Core/images/add-image/script.php @@ -25,8 +25,8 @@ $imgPath = displayFiles($files)['path']; -$writer = new SetaPDF_Core_Writer_Http('result.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('result.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/Fact-Sheet-without-personalization.pdf', $writer ); @@ -47,7 +47,7 @@ $canvas->normalizeRotationAndOrigin($pageOne->getRotation(), $pageOne->getBoundary()); // create an image instance -$image = SetaPDF_Core_Image::getByPath($imgPath)->toXObject($document); +$image = \SetaPDF_Core_Image::getByPath($imgPath)->toXObject($document); // let's use a fixed height $height = 40; diff --git a/public/demos/1-Core/images/image-to-pdf/script.php b/public/demos/1-Core/images/image-to-pdf/script.php index 70ff5c7..d5fa566 100644 --- a/public/demos/1-Core/images/image-to-pdf/script.php +++ b/public/demos/1-Core/images/image-to-pdf/script.php @@ -9,17 +9,17 @@ $imgPath = displayFiles($files); // create a writer -$writer = new SetaPDF_Core_Writer_Http('ImgToPdf.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('ImgToPdf.pdf', true); // create a document -$document = new SetaPDF_Core_Document($writer); +$document = new \SetaPDF_Core_Document($writer); -$img = SetaPDF_Core_Image::getByPath($imgPath); +$img = \SetaPDF_Core_Image::getByPath($imgPath); $xObject = $img->toXObject($document); $pages = $document->getCatalog()->getPages(); $page = $pages->create( [$xObject->getWidth(), $xObject->getHeight()], - SetaPDF_Core_PageFormats::ORIENTATION_AUTO + \SetaPDF_Core_PageFormats::ORIENTATION_AUTO ); $canvas = $page->getCanvas(); diff --git a/public/demos/1-Core/images/image-with-resolution/script.php b/public/demos/1-Core/images/image-with-resolution/script.php index c0fbd3b..fcc3f9b 100644 --- a/public/demos/1-Core/images/image-with-resolution/script.php +++ b/public/demos/1-Core/images/image-with-resolution/script.php @@ -18,11 +18,11 @@ $imgData = displayFiles($files, true); // create a writer -$writer = new SetaPDF_Core_Writer_Http('ImgInSpecificResolution.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('ImgInSpecificResolution.pdf', true); // create a document -$document = new SetaPDF_Core_Document($writer); +$document = new \SetaPDF_Core_Document($writer); -$img = SetaPDF_Core_Image::getByPath($imgData['path']); +$img = \SetaPDF_Core_Image::getByPath($imgData['path']); $xObject = $img->toXObject($document); $width = $xObject->getWidth(); $height = $xObject->getHeight(); @@ -36,7 +36,7 @@ $pages = $document->getCatalog()->getPages(); $page = $pages->create( [$width, $height], - SetaPDF_Core_PageFormats::ORIENTATION_AUTO + \SetaPDF_Core_PageFormats::ORIENTATION_AUTO ); $canvas = $page->getCanvas(); $xObject->draw($canvas, 0, 0, $width, $height); diff --git a/public/demos/1-Core/images/replace-images/script.php b/public/demos/1-Core/images/replace-images/script.php index de21428..05f78ba 100644 --- a/public/demos/1-Core/images/replace-images/script.php +++ b/public/demos/1-Core/images/replace-images/script.php @@ -13,14 +13,14 @@ require_once $classesDirectory . '/ContentStreamProcessor/ImageProcessor.php'; // load a document instance -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); // get access to the pages object $pages = $document->getCatalog()->getPages(); // define the replacement images -$portraitImage = SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/portrait.jpg'); +$portraitImage = \SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/portrait.jpg'); $portraitXObject = $portraitImage->toXObject($document); -$landscapeImage = SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/landscape.jpg'); +$landscapeImage = \SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/landscape.jpg'); $landscapeXObject = $landscapeImage->toXObject($document); // walk through the pages @@ -44,6 +44,6 @@ } // save and finish -$document->setWriter(new SetaPDF_Core_Writer_Http('replaced-images.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('replaced-images.pdf', true)); $document->save()->finish(); diff --git a/public/demos/1-Core/outline/add-outline-item/script.php b/public/demos/1-Core/outline/add-outline-item/script.php index b424e03..7feb026 100644 --- a/public/demos/1-Core/outline/add-outline-item/script.php +++ b/public/demos/1-Core/outline/add-outline-item/script.php @@ -3,20 +3,20 @@ // load and register the autoload function require_once '../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('Brand-Guide.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('Brand-Guide.pdf', true); // create a document instance -$document = SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/Brand-Guide.pdf', $writer); +$document = \SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/Brand-Guide.pdf', $writer); // get the outlines helper $outlines = $document->getCatalog()->getOutlines(); // create an item instance -$item = SetaPDF_Core_Document_OutlinesItem::create($document, '© Setasign'); +$item = \SetaPDF_Core_Document_OutlinesItem::create($document, '© Setasign'); // make it bold $item->setBold(true); // create an Uri action -$action = new SetaPDF_Core_Document_Action_Uri('https://www.setasign.com'); +$action = new \SetaPDF_Core_Document_Action_Uri('https://www.setasign.com'); // add the action to the item $item->setAction($action); @@ -24,7 +24,7 @@ $outlines->appendChild($item); // show the outline panel -$document->getCatalog()->setPageMode(SetaPDF_Core_Document_PageMode::USE_OUTLINES); +$document->getCatalog()->setPageMode(\SetaPDF_Core_Document_PageMode::USE_OUTLINES); // save and finish the document instance $document->save()->finish(); diff --git a/public/demos/1-Core/outline/get-outline/script.php b/public/demos/1-Core/outline/get-outline/script.php index 53f75ec..590fc9c 100644 --- a/public/demos/1-Core/outline/get-outline/script.php +++ b/public/demos/1-Core/outline/get-outline/script.php @@ -12,9 +12,9 @@ $path = displayFiles($files); // create a reader -$reader = new SetaPDF_Core_Reader_File($path); +$reader = new \SetaPDF_Core_Reader_File($path); // create a document -$document = SetaPDF_Core_Document::load($reader); +$document = \SetaPDF_Core_Document::load($reader); // get the outlines helper $outlines = $document->getCatalog()->getOutlines(); @@ -49,23 +49,23 @@ $destionationOrAction = $action->getType() . ' Action'; switch (true) { // handle GoTo Actions - case $action instanceof SetaPDF_Core_Document_Action_GoTo: + case $action instanceof \SetaPDF_Core_Document_Action_GoTo: $destination = $action->getDestination($document); $destionationOrAction .= ': Destination on Page ' . $destination->getPageNo($document); break; // handle Named Actions - case $action instanceof SetaPDF_Core_Document_Action_Named: + case $action instanceof \SetaPDF_Core_Document_Action_Named: $destionationOrAction .= ': ' . $action->getName(); break; // handle JavaScript actions - case $action instanceof SetaPDF_Core_Document_Action_JavaScript: + case $action instanceof \SetaPDF_Core_Document_Action_JavaScript: $destionationOrAction .= ': ' . substr($action->getJavaScript(), 0, 100); break; // handle URI actions - case $action instanceof SetaPDF_Core_Document_Action_Uri: + case $action instanceof \SetaPDF_Core_Document_Action_Uri: $destionationOrAction .= ': ' . $action->getUri(); break; } diff --git a/public/demos/1-Core/pages/add-pages/script.php b/public/demos/1-Core/pages/add-pages/script.php index 3d6481e..39492fd 100644 --- a/public/demos/1-Core/pages/add-pages/script.php +++ b/public/demos/1-Core/pages/add-pages/script.php @@ -12,22 +12,22 @@ $path = displayFiles($files); // create a reader -$reader = new SetaPDF_Core_Reader_File($path); +$reader = new \SetaPDF_Core_Reader_File($path); // create a writer -$writer = new SetaPDF_Core_Writer_Http('add-pages.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('add-pages.pdf', true); // create a document -$document = SetaPDF_Core_Document::load($reader, $writer); +$document = \SetaPDF_Core_Document::load($reader, $writer); // Get the pages helper $pages = $document->getCatalog()->getPages(); // create a new blank last page and automatically append it -$newLastPage = $pages->create(SetaPDF_Core_PageFormats::A4); +$newLastPage = $pages->create(\SetaPDF_Core_PageFormats::A4); /* create a new blank page in landscape format and pass * false to the $append parameter so we can prepend it afterwards. */ -$newFirstPage = $pages->create(SetaPDF_Core_PageFormats::A4, SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE, false); +$newFirstPage = $pages->create(\SetaPDF_Core_PageFormats::A4, \SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE, false); $pages->prepend($newFirstPage); // remove the OpenAction diff --git a/public/demos/1-Core/pages/count-pages/script.php b/public/demos/1-Core/pages/count-pages/script.php index 78ad4ba..8765c5b 100644 --- a/public/demos/1-Core/pages/count-pages/script.php +++ b/public/demos/1-Core/pages/count-pages/script.php @@ -11,7 +11,7 @@ $path = displayFiles($files); -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $pages = $document->getCatalog()->getPages(); $pageCount = $pages->count(); diff --git a/public/demos/1-Core/pages/crop-page/script.php b/public/demos/1-Core/pages/crop-page/script.php index 8cd2b7c..2c16235 100644 --- a/public/demos/1-Core/pages/crop-page/script.php +++ b/public/demos/1-Core/pages/crop-page/script.php @@ -13,10 +13,10 @@ $rectColor = displaySelect('Crop to:', $rectColors); // create a writer instance -$writer = new SetaPDF_Core_Writer_Http('cropped.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('cropped.pdf', true); // create a document instance -$document = SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/misc/4-rects.pdf', $writer); +$document = \SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/misc/4-rects.pdf', $writer); // get the pages helper $pages = $document->getCatalog()->getPages(); @@ -35,7 +35,7 @@ ]; // resize all available page boxes -foreach (SetaPDF_Core_PageBoundaries::$all AS $boxName) { +foreach (\SetaPDF_Core_PageBoundaries::$all AS $boxName) { $box = $page->getBoundary($boxName, false); if ($box === false) { continue; diff --git a/public/demos/1-Core/pages/delete-pages/script.php b/public/demos/1-Core/pages/delete-pages/script.php index 6519437..9b1715c 100644 --- a/public/demos/1-Core/pages/delete-pages/script.php +++ b/public/demos/1-Core/pages/delete-pages/script.php @@ -12,11 +12,11 @@ $path = displayFiles($files); // create a reader -$reader = new SetaPDF_Core_Reader_File($path); +$reader = new \SetaPDF_Core_Reader_File($path); // create a writer -$writer = new SetaPDF_Core_Writer_Http('delete-pages.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('delete-pages.pdf', true); // create a document -$document = SetaPDF_Core_Document::load($reader, $writer); +$document = \SetaPDF_Core_Document::load($reader, $writer); // get the pages helper $pages = $document->getCatalog()->getPages(); diff --git a/public/demos/1-Core/pages/fit-pages/script.php b/public/demos/1-Core/pages/fit-pages/script.php index fd3e881..f17cccd 100644 --- a/public/demos/1-Core/pages/fit-pages/script.php +++ b/public/demos/1-Core/pages/fit-pages/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // create a string writer for a temporary result -$writer = new SetaPDF_Core_Writer_String(); +$writer = new \SetaPDF_Core_Writer_String(); // create a document -$document = new SetaPDF_Core_Document($writer); +$document = new \SetaPDF_Core_Document($writer); // the wanted format $wantedFormat = [200, 100]; @@ -15,13 +15,13 @@ $pages = $document->getCatalog()->getPages(); // create a new font -$font = SetaPDF_Core_Font_Standard_Courier::create($document); +$font = \SetaPDF_Core_Font_Standard_Courier::create($document); // create an array with different formats $formats = [ [ // 1 - SetaPDF_Core_PageFormats::A4, - "A4\n" . SetaPDF_Core_PageFormats::A4, + \SetaPDF_Core_PageFormats::A4, + "A4\n" . \SetaPDF_Core_PageFormats::A4, 0, 70, ], @@ -112,10 +112,10 @@ ); // create a new text block - $text = new SetaPDF_Core_Text_Block($font, $fontSize); + $text = new \SetaPDF_Core_Text_Block($font, $fontSize); // set the align - $text->setAlign(SetaPDF_Core_Text::ALIGN_CENTER); + $text->setAlign(\SetaPDF_Core_Text::ALIGN_CENTER); // set the text of the text block $text->setText($formatName); @@ -126,7 +126,7 @@ $text->draw($canvas, $x, $y); // create an annotation for demonstration purpose - $annotation = new SetaPDF_Core_Document_Page_Annotation_Square( + $annotation = new \SetaPDF_Core_Document_Page_Annotation_Square( [$x, $y, $x + $text->getWidth(), $y + $text->getHeight()] ); @@ -141,9 +141,9 @@ $document->save()->finish(); // transfer the document into a new instance -$fittedDocument = SetaPDF_Core_Document::load( - new SetaPDF_Core_Reader_String($writer), - new SetaPDF_Core_Writer_Http('fit.pdf', true) +$fittedDocument = \SetaPDF_Core_Document::load( + new \SetaPDF_Core_Reader_String($writer), + new \SetaPDF_Core_Writer_Http('fit.pdf', true) ); // get the pages object @@ -158,10 +158,10 @@ $page = $pages->getPage($pageNumber); // sanitize the current page format - $format = SetaPDF_Core_PageFormats::getFormat($page->getWidthAndHeight(), SetaPDF_Core_PageFormats::ORIENTATION_AUTO); + $format = \SetaPDF_Core_PageFormats::getFormat($page->getWidthAndHeight(), \SetaPDF_Core_PageFormats::ORIENTATION_AUTO); // check if the format of the current page is the desired format - if (SetaPDF_Core_PageFormats::is($wantedFormat, $format)) { + if (\SetaPDF_Core_PageFormats::is($wantedFormat, $format)) { continue; } @@ -169,7 +169,7 @@ $orientation = $page->getOrientation(); // align the wanted format to the page orientation - $wantedFormatArray = SetaPDF_Core_PageFormats::getFormat($wantedFormat, $orientation); + $wantedFormatArray = \SetaPDF_Core_PageFormats::getFormat($wantedFormat, $orientation); // check if the page is rotated $rotated = ($page->getRotation() / 90) % 2; @@ -199,7 +199,7 @@ $cropBox = $page->getBoundary(); // calculate the scaling - $rect = new SetaPDF_Core_Geometry_Rectangle( + $rect = new \SetaPDF_Core_Geometry_Rectangle( $cropBox->getLlx() * $scale, $cropBox->getLly() * $scale, $cropBox->getUrx() * $scale, @@ -231,7 +231,7 @@ $canvas->restoreGraphicState(); // let's adjust the boundary boxes - $boxes = SetaPDF_Core_PageBoundaries::$all; + $boxes = \SetaPDF_Core_PageBoundaries::$all; // reverse the boxes order to pass valid boxes to the page if ($scale < 1) { $boxes = array_reverse($boxes); @@ -245,7 +245,7 @@ } // create a new boundary box - $box = SetaPDF_Core_DataStructure_Rectangle::byArray( + $box = \SetaPDF_Core_DataStructure_Rectangle::byArray( [ $_box->getLlx(), $_box->getLly(), @@ -266,10 +266,10 @@ // the size of a popup annotation has to be handled individually // we just use the scale and translate values which were calculated before - if ($annotation instanceof SetaPDF_Core_Document_Page_Annotation_Popup) { + if ($annotation instanceof \SetaPDF_Core_Document_Page_Annotation_Popup) { $_rect = $annotation->getRect(); - $rect = SetaPDF_Core_DataStructure_Rectangle::byArray([ + $rect = \SetaPDF_Core_DataStructure_Rectangle::byArray([ $_rect->getLlx() * $scale + $translateX, $_rect->getLly() * $scale + $translateY + $_rect->getHeight(), $_rect->getLlx() * $scale + $translateX + $_rect->getWidth(), @@ -280,7 +280,7 @@ } $_rect = $annotation->getRect(); - $rect = SetaPDF_Core_DataStructure_Rectangle::byArray([ + $rect = \SetaPDF_Core_DataStructure_Rectangle::byArray([ $_rect->getLlx() * $scale + $translateX, $_rect->getLly() * $scale + $translateY, $_rect->getUrx() * $scale + $translateX, diff --git a/public/demos/1-Core/pages/get-information/script.php b/public/demos/1-Core/pages/get-information/script.php index cb52082..4834ace 100644 --- a/public/demos/1-Core/pages/get-information/script.php +++ b/public/demos/1-Core/pages/get-information/script.php @@ -12,7 +12,7 @@ $path = displayFiles($files); // create a document instance -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); // get the pages helper $pages = $document->getCatalog()->getPages(); @@ -25,7 +25,7 @@ $page = $pages->getPage($pageNo); // print all page boundaries - foreach (SetaPDF_Core_PageBoundaries::$all AS $boxName) { + foreach (\SetaPDF_Core_PageBoundaries::$all AS $boxName) { $box = $page->getBoundary($boxName); echo $boxName; vprintf(' = [llx: %.3F, lly: %.3F, urx: %.3F, ury: %.3F]
', $box->toPhp()); diff --git a/public/demos/1-Core/pages/resize-pages/script.php b/public/demos/1-Core/pages/resize-pages/script.php index 3e28b01..689166b 100644 --- a/public/demos/1-Core/pages/resize-pages/script.php +++ b/public/demos/1-Core/pages/resize-pages/script.php @@ -12,9 +12,9 @@ $path = displayFiles($files); // create a writer instance -$writer = new SetaPDF_Core_Writer_Http('resize-pages.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('resize-pages.pdf', true); // create a document instance -$document = SetaPDF_Core_Document::loadByFilename($path, $writer); +$document = \SetaPDF_Core_Document::loadByFilename($path, $writer); // get the pages helper $pages = $document->getCatalog()->getPages(); @@ -26,7 +26,7 @@ $page = $pages->getPage($pageNo); // resize all available page boxes - foreach (SetaPDF_Core_PageBoundaries::$all AS $boxName) { + foreach (\SetaPDF_Core_PageBoundaries::$all AS $boxName) { $box = $page->getBoundary($boxName, false); if ($box === false) { continue; diff --git a/public/demos/1-Core/pages/rotate-pages/script.php b/public/demos/1-Core/pages/rotate-pages/script.php index d33edc9..d27a03a 100644 --- a/public/demos/1-Core/pages/rotate-pages/script.php +++ b/public/demos/1-Core/pages/rotate-pages/script.php @@ -12,9 +12,9 @@ $path = displayFiles($files); // create a file writer -$writer = new SetaPDF_Core_Writer_Http('rotated.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('rotated.pdf', true); // load document by filename -$document = SetaPDF_Core_Document::loadByFilename($path, $writer); +$document = \SetaPDF_Core_Document::loadByFilename($path, $writer); // get pages object $pages = $document->getCatalog()->getPages(); diff --git a/public/demos/2-Extractor/1-strategies/1-plain-text/script.php b/public/demos/2-Extractor/1-strategies/1-plain-text/script.php index 2355526..971d831 100644 --- a/public/demos/2-Extractor/1-strategies/1-plain-text/script.php +++ b/public/demos/2-Extractor/1-strategies/1-plain-text/script.php @@ -12,7 +12,7 @@ $path = displayFiles($files); -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $extractor = new SetaPDF_Extractor($document); // The plain text strategy is the default strategy, so we don't need to do this: diff --git a/public/demos/2-Extractor/1-strategies/2-glyph/script.php b/public/demos/2-Extractor/1-strategies/2-glyph/script.php index b3c4381..639ea63 100644 --- a/public/demos/2-Extractor/1-strategies/2-glyph/script.php +++ b/public/demos/2-Extractor/1-strategies/2-glyph/script.php @@ -12,7 +12,7 @@ $path = displayFiles($files); -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $extractor = new SetaPDF_Extractor($document); $strategy = new SetaPDF_Extractor_Strategy_Glyph(); diff --git a/public/demos/2-Extractor/1-strategies/3-exact-plain-text/script.php b/public/demos/2-Extractor/1-strategies/3-exact-plain-text/script.php index d2833dd..d112138 100644 --- a/public/demos/2-Extractor/1-strategies/3-exact-plain-text/script.php +++ b/public/demos/2-Extractor/1-strategies/3-exact-plain-text/script.php @@ -12,7 +12,7 @@ $path = displayFiles($files); -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $extractor = new SetaPDF_Extractor($document); $strategy = new SetaPDF_Extractor_Strategy_ExactPlain(); diff --git a/public/demos/2-Extractor/1-strategies/4-word/script.php b/public/demos/2-Extractor/1-strategies/4-word/script.php index e2c2632..a180150 100644 --- a/public/demos/2-Extractor/1-strategies/4-word/script.php +++ b/public/demos/2-Extractor/1-strategies/4-word/script.php @@ -12,7 +12,7 @@ $path = displayFiles($files); -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $extractor = new SetaPDF_Extractor($document); $strategy = new SetaPDF_Extractor_Strategy_Word(); diff --git a/public/demos/2-Extractor/1-strategies/5-word-with-glyphs/script.php b/public/demos/2-Extractor/1-strategies/5-word-with-glyphs/script.php index ed6754e..cbd6640 100644 --- a/public/demos/2-Extractor/1-strategies/5-word-with-glyphs/script.php +++ b/public/demos/2-Extractor/1-strategies/5-word-with-glyphs/script.php @@ -12,7 +12,7 @@ $path = displayFiles($files); -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $extractor = new SetaPDF_Extractor($document); $strategy = new SetaPDF_Extractor_Strategy_Word(); diff --git a/public/demos/2-Extractor/1-strategies/6-word-group/script.php b/public/demos/2-Extractor/1-strategies/6-word-group/script.php index 0b7773a..691ecf2 100644 --- a/public/demos/2-Extractor/1-strategies/6-word-group/script.php +++ b/public/demos/2-Extractor/1-strategies/6-word-group/script.php @@ -12,7 +12,7 @@ $path = displayFiles($files); -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $extractor = new SetaPDF_Extractor($document); $strategy = new SetaPDF_Extractor_Strategy_WordGroup(); diff --git a/public/demos/2-Extractor/filter/by-annotations/script.php b/public/demos/2-Extractor/filter/by-annotations/script.php index d980211..cc3eb66 100644 --- a/public/demos/2-Extractor/filter/by-annotations/script.php +++ b/public/demos/2-Extractor/filter/by-annotations/script.php @@ -11,7 +11,7 @@ $path = displayFiles($files); // create a document instance -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); // initate an extractor instance $extractor = new SetaPDF_Extractor($document); @@ -30,12 +30,12 @@ // get the annotations $annotations = array_filter( $page->getAnnotations()->getAll(), - static function (SetaPDF_Core_Document_Page_Annotation $annotation) { + static function (\SetaPDF_Core_Document_Page_Annotation $annotation) { switch ($annotation->getType()) { - case SetaPDF_Core_Document_Page_Annotation::TYPE_HIGHLIGHT: - case SetaPDF_Core_Document_Page_Annotation::TYPE_STRIKE_OUT: - case SetaPDF_Core_Document_Page_Annotation::TYPE_CARET: - case SetaPDF_Core_Document_Page_Annotation::TYPE_UNDERLINE: + case \SetaPDF_Core_Document_Page_Annotation::TYPE_HIGHLIGHT: + case \SetaPDF_Core_Document_Page_Annotation::TYPE_STRIKE_OUT: + case \SetaPDF_Core_Document_Page_Annotation::TYPE_CARET: + case \SetaPDF_Core_Document_Page_Annotation::TYPE_UNDERLINE: return true; } @@ -53,14 +53,14 @@ static function (SetaPDF_Core_Document_Page_Annotation $annotation) { // iterate over all highlight annotations foreach ($annotations AS $tmpId => $annotation) { /** - * @var SetaPDF_Core_Document_Page_Annotation_TextMarkup $annotation + * @var \SetaPDF_Core_Document_Page_Annotation_TextMarkup $annotation */ $name = 'P#' . $pageNo . '/TMA#' . $tmpId; if ($annotation->getName()) { $name .= ' (' . $annotation->getName() . ')'; } - if ($annotation instanceof SetaPDF_Core_Document_Page_Annotation_TextMarkup) { + if ($annotation instanceof \SetaPDF_Core_Document_Page_Annotation_TextMarkup) { // iterate over the quad points to setup our filter instances $quadpoints = $annotation->getQuadPoints(); for ($pos = 0, $c = count($quadpoints); $pos < $c; $pos += 8) { @@ -77,7 +77,7 @@ static function (SetaPDF_Core_Document_Page_Annotation $annotation) { // Add a new rectangle filter to the multi filter instance $filter->addFilter( new SetaPDF_Extractor_Filter_Rectangle( - new SetaPDF_Core_Geometry_Rectangle($llx, $lly, $urx, $ury), + new \SetaPDF_Core_Geometry_Rectangle($llx, $lly, $urx, $ury), SetaPDF_Extractor_Filter_Rectangle::MODE_CONTACT, $name ) diff --git a/public/demos/2-Extractor/filter/by-bold-font/script.php b/public/demos/2-Extractor/filter/by-bold-font/script.php index 7976a34..3493503 100644 --- a/public/demos/2-Extractor/filter/by-bold-font/script.php +++ b/public/demos/2-Extractor/filter/by-bold-font/script.php @@ -4,7 +4,7 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // create a document instance -$document = SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/Fuchslocher-Example.pdf'); +$document = \SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/Fuchslocher-Example.pdf'); // create an extractor instance $extractor = new SetaPDF_Extractor($document); diff --git a/public/demos/2-Extractor/filter/by-font-size/script.php b/public/demos/2-Extractor/filter/by-font-size/script.php index 9ebc7f6..430ab71 100644 --- a/public/demos/2-Extractor/filter/by-font-size/script.php +++ b/public/demos/2-Extractor/filter/by-font-size/script.php @@ -12,7 +12,7 @@ $fontSize = displaySelect('Filter by:', $data); // create a document instance -$document = SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/Brand-Guide.pdf'); +$document = \SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/Brand-Guide.pdf'); // create an extractor instance $extractor = new SetaPDF_Extractor($document); diff --git a/public/demos/2-Extractor/filter/by-form-fields/script.php b/public/demos/2-Extractor/filter/by-form-fields/script.php index f844c45..645bb4a 100644 --- a/public/demos/2-Extractor/filter/by-form-fields/script.php +++ b/public/demos/2-Extractor/filter/by-form-fields/script.php @@ -5,7 +5,7 @@ // Let's load a template in which we'd drawn simple form fields to get the names and // coordinates of the areas we want to extract -$template = SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/Subscription-tekMag-form-template.pdf'); +$template = \SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/Subscription-tekMag-form-template.pdf'); $pages = $template->getCatalog()->getPages(); // group the found fields by pages @@ -17,9 +17,9 @@ $annotations = $page->getAnnotations(); // get all widget annotations - $widgetAnnotations = $annotations->getAll(SetaPDF_Core_Document_Page_Annotation::TYPE_WIDGET); + $widgetAnnotations = $annotations->getAll(\SetaPDF_Core_Document_Page_Annotation::TYPE_WIDGET); foreach ($widgetAnnotations AS $widgetAnnotation) { - $fieldName = SetaPDF_Core_Document_Catalog_AcroForm::resolveFieldName($widgetAnnotation->getDictionary()); + $fieldName = \SetaPDF_Core_Document_Catalog_AcroForm::resolveFieldName($widgetAnnotation->getDictionary()); $fieldsPerPage[$pageNo][$fieldName] = $widgetAnnotation->getRect()->getRectangle(); } } @@ -38,7 +38,7 @@ echo '

' . htmlspecialchars(substr($path, strlen($assetsDirectory . '/pdfs/'))) . '

'; // load the document - $document = SetaPDF_Core_Document::loadByFilename($path); + $document = \SetaPDF_Core_Document::loadByFilename($path); // create a plain strategy $strategy = new SetaPDF_Extractor_Strategy_Plain(); diff --git a/public/demos/2-Extractor/filter/get-and-mark-words-at-specific-location/script.php b/public/demos/2-Extractor/filter/get-and-mark-words-at-specific-location/script.php index 7c333b7..d6216fe 100644 --- a/public/demos/2-Extractor/filter/get-and-mark-words-at-specific-location/script.php +++ b/public/demos/2-Extractor/filter/get-and-mark-words-at-specific-location/script.php @@ -7,7 +7,7 @@ $path = displayFiles($files); -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); // initiate an extractor instance $extractor = new SetaPDF_Extractor($document); @@ -17,14 +17,14 @@ // define filter areas $invoicingPartyFilter = new SetaPDF_Extractor_Filter_Rectangle( - new SetaPDF_Core_Geometry_Rectangle(40, 705, 220, 720), + new \SetaPDF_Core_Geometry_Rectangle(40, 705, 220, 720), SetaPDF_Extractor_Filter_Rectangle::MODE_CONTACT, 'invoicingParty' ); // define filter areas $invoiceNoFilter = new SetaPDF_Extractor_Filter_Rectangle( - new SetaPDF_Core_Geometry_Rectangle(512, 520, 580, 540), + new \SetaPDF_Core_Geometry_Rectangle(512, 520, 580, 540), SetaPDF_Extractor_Filter_Rectangle::MODE_CONTACT, 'invoiceNo' ); @@ -70,5 +70,5 @@ } } -$document->setWriter(new SetaPDF_Core_Writer_Http('document.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('document.pdf', true)); $document->save()->finish(); diff --git a/public/demos/2-Extractor/filter/interactive-gui/script.php b/public/demos/2-Extractor/filter/interactive-gui/script.php index bd2b4ea..3ee1ee9 100644 --- a/public/demos/2-Extractor/filter/interactive-gui/script.php +++ b/public/demos/2-Extractor/filter/interactive-gui/script.php @@ -71,7 +71,7 @@ } $file = $files[$_GET['file']]; - $document = SetaPDF_Core_Document::loadByFilename($file); + $document = \SetaPDF_Core_Document::loadByFilename($file); $pages = $document->getCatalog()->getPages(); $pageCount = $pages->count(); $pageFormats = []; @@ -113,7 +113,7 @@ $y2 = $_GET['data']['y2']; // load the document - $document = SetaPDF_Core_Document::loadByFilename($file); + $document = \SetaPDF_Core_Document::loadByFilename($file); // get access to its pages $pages = $document->getCatalog()->getPages(); @@ -125,7 +125,7 @@ $strategy = new SetaPDF_Extractor_Strategy_ExactPlain(); // pass a rectangle filter to the strategy $strategy->setFilter(new SetaPDF_Extractor_Filter_Rectangle( - new SetaPDF_Core_Geometry_Rectangle($x1, $y1, $x2, $y2), + new \SetaPDF_Core_Geometry_Rectangle($x1, $y1, $x2, $y2), SetaPDF_Extractor_Filter_Rectangle::MODE_CONTACT )); $extractor->setStrategy($strategy); diff --git a/public/demos/2-Extractor/filter/invoice-recipients-and-numbers/script.php b/public/demos/2-Extractor/filter/invoice-recipients-and-numbers/script.php index f3b32f2..3455cce 100644 --- a/public/demos/2-Extractor/filter/invoice-recipients-and-numbers/script.php +++ b/public/demos/2-Extractor/filter/invoice-recipients-and-numbers/script.php @@ -10,7 +10,7 @@ foreach ($files AS $file) { // initiate a document instance - $document = SetaPDF_Core_Document::loadByFilename($file); + $document = \SetaPDF_Core_Document::loadByFilename($file); // initiate an extractor instance $extractor = new SetaPDF_Extractor($document); @@ -20,14 +20,14 @@ // define a rectangle filter for the invoice recipient name $recipientNameFilter = new SetaPDF_Extractor_Filter_Rectangle( - new SetaPDF_Core_Geometry_Rectangle(40, 665, 260, 700), + new \SetaPDF_Core_Geometry_Rectangle(40, 665, 260, 700), SetaPDF_Extractor_Filter_Rectangle::MODE_CONTACT, 'recipient' ); // define another rectangle filter for the invoice number $invoiceNofilter = new SetaPDF_Extractor_Filter_Rectangle( - new SetaPDF_Core_Geometry_Rectangle(512, 520, 580, 540), + new \SetaPDF_Core_Geometry_Rectangle(512, 520, 580, 540), SetaPDF_Extractor_Filter_Rectangle::MODE_CONTACT, 'invoiceNo' ); diff --git a/public/demos/2-Extractor/various/add-image-above-placeholder/script.php b/public/demos/2-Extractor/various/add-image-above-placeholder/script.php index 99c04ec..a59015f 100644 --- a/public/demos/2-Extractor/various/add-image-above-placeholder/script.php +++ b/public/demos/2-Extractor/various/add-image-above-placeholder/script.php @@ -3,7 +3,7 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/tektown/Laboratory-Report - with-sig-placeholders.pdf' ); @@ -19,7 +19,7 @@ // define a mapping of placeholders to images $images = [ - 'SIGNATURE' => SetaPDF_Core_Image::getByPath( + 'SIGNATURE' => \SetaPDF_Core_Image::getByPath( $assetsDirectory . '/images/Handwritten-Signature.png' )->toXObject($document) ]; @@ -89,10 +89,10 @@ // draw a white rectangle $canvas->draw() ->setNonStrokingColor(1) - ->rect($x, $y, $width, $height, SetaPDF_Core_Canvas_Draw::STYLE_FILL); + ->rect($x, $y, $width, $height, \SetaPDF_Core_Canvas_Draw::STYLE_FILL); /** - * @var SetaPDF_Core_XObject_Image $image + * @var \SetaPDF_Core_XObject_Image $image */ $image = $images[$name]; // draw the image onto the canvas @@ -100,5 +100,5 @@ } // save and finish the document -$document->setWriter(new SetaPDF_Core_Writer_Http('document.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('document.pdf', true)); $document->save()->finish(); diff --git a/public/demos/2-Extractor/various/create-link-annotations/script.php b/public/demos/2-Extractor/various/create-link-annotations/script.php index 9225295..08461cb 100644 --- a/public/demos/2-Extractor/various/create-link-annotations/script.php +++ b/public/demos/2-Extractor/various/create-link-annotations/script.php @@ -10,8 +10,8 @@ $file = displayFiles($files); -$writer = new SetaPDF_Core_Writer_Http('with-links.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename($file, $writer); +$writer = new \SetaPDF_Core_Writer_Http('with-links.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename($file, $writer); $pages = $document->getCatalog()->getPages(); @@ -107,7 +107,7 @@ $ur = $bounds[0]->getUr(); // ...add a link annotation - $annotation = new SetaPDF_Core_Document_Page_Annotation_Link( + $annotation = new \SetaPDF_Core_Document_Page_Annotation_Link( [$ll->getX(), $ll->getY(), $ur->getX(), $ur->getY()], $link ); @@ -116,7 +116,7 @@ $annotation->setColor([1, 0, 0]); $annotation->getBorderStyle() ->setWidth(1) - ->setStyle(SetaPDF_Core_Document_Page_Annotation_BorderStyle::DASHED) + ->setStyle(\SetaPDF_Core_Document_Page_Annotation_BorderStyle::DASHED) ->setDashPattern([2, 2]); $annotations->add($annotation); @@ -161,7 +161,7 @@ $ur = $bounds[0]->getUr(); // ...add a link annotation - $annotation = new SetaPDF_Core_Document_Page_Annotation_Link( + $annotation = new \SetaPDF_Core_Document_Page_Annotation_Link( [$ll->getX(), $ll->getY(), $ur->getX(), $ur->getY()], 'mailto:' . $email ); @@ -170,7 +170,7 @@ $annotation->setColor([0, 1, 0]); $annotation->getBorderStyle() ->setWidth(1) - ->setStyle(SetaPDF_Core_Document_Page_Annotation_BorderStyle::DASHED) + ->setStyle(\SetaPDF_Core_Document_Page_Annotation_BorderStyle::DASHED) ->setDashPattern([2, 2]); $annotations->add($annotation); diff --git a/public/demos/2-Extractor/various/create-links-in-table-of-contents/script.php b/public/demos/2-Extractor/various/create-links-in-table-of-contents/script.php index a209e8c..c39dc56 100644 --- a/public/demos/2-Extractor/various/create-links-in-table-of-contents/script.php +++ b/public/demos/2-Extractor/various/create-links-in-table-of-contents/script.php @@ -3,9 +3,9 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/Brand-Guide-without-links.pdf', - new SetaPDF_Core_Writer_Http('document.pdf', true) + new \SetaPDF_Core_Writer_Http('document.pdf', true) ); $extractor = new SetaPDF_Extractor($document); @@ -82,13 +82,13 @@ $linkToPageNo = $m[1]; - $action = new SetaPDF_Core_Document_Action_GoTo( - SetaPDF_Core_Document_Destination::createByPage($pages->getPage($linkToPageNo + $offset)) + $action = new \SetaPDF_Core_Document_Action_GoTo( + \SetaPDF_Core_Document_Destination::createByPage($pages->getPage($linkToPageNo + $offset)) ); $bounds = $line->getBounds(); $ll = $bounds[0]->getLl(); $ur = $bounds[0]->getUr(); - $annotation = new SetaPDF_Core_Document_Page_Annotation_Link( + $annotation = new \SetaPDF_Core_Document_Page_Annotation_Link( [$ll->getX(), $ll->getY(), $ur->getX(), $ur->getY()], $action ); diff --git a/public/demos/2-Extractor/various/create-named-destinations/script.php b/public/demos/2-Extractor/various/create-named-destinations/script.php index b0af85e..407cf4c 100644 --- a/public/demos/2-Extractor/various/create-named-destinations/script.php +++ b/public/demos/2-Extractor/various/create-named-destinations/script.php @@ -3,9 +3,9 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/misc/Chapters.pdf', - new SetaPDF_Core_Writer_Http('result.pdf', true) + new \SetaPDF_Core_Writer_Http('result.pdf', true) ); $extractor = new SetaPDF_Extractor($document); @@ -25,7 +25,7 @@ // get access to the named destination tree $names = $document->getCatalog()->getNames()->getTree( - SetaPDF_Core_Document_Catalog_Names::DESTS, true + \SetaPDF_Core_Document_Catalog_Names::DESTS, true ); for ($pageNo = 1; $pageNo <= $pages->count(); $pageNo++) { @@ -52,10 +52,10 @@ // get the coordinates of the word $bounds = $word->getBounds()[0]; // create a destination - $destination = SetaPDF_Core_Document_Destination::createByPageNo( + $destination = \SetaPDF_Core_Document_Destination::createByPageNo( $document, $pageNo, - SetaPDF_Core_Document_Destination::FIT_MODE_FIT_BH, + \SetaPDF_Core_Document_Destination::FIT_MODE_FIT_BH, $bounds->getUl()->getY() ); @@ -68,7 +68,7 @@ try { // add the named destination to the name tree $names->add($name, $destination->getPdfValue()); - } catch (SetaPDF_Core_DataStructure_Tree_KeyAlreadyExistsException $e) { + } catch (\SetaPDF_Core_DataStructure_Tree_KeyAlreadyExistsException $e) { echo 'The destination name "' . $name . "\" is not unique.
"; die(); } diff --git a/public/demos/2-Extractor/various/highlight-words-via-html/script.php b/public/demos/2-Extractor/various/highlight-words-via-html/script.php index 6268a42..b168a75 100644 --- a/public/demos/2-Extractor/various/highlight-words-via-html/script.php +++ b/public/demos/2-Extractor/various/highlight-words-via-html/script.php @@ -32,7 +32,7 @@ } } -$document = SetaPDF_Core_Document::loadByFilename($file); +$document = \SetaPDF_Core_Document::loadByFilename($file); $page = $document->getCatalog()->getPages()->getPage($pageNo); $extractor = new SetaPDF_Extractor($document); @@ -50,7 +50,7 @@ $rotation = $page->getRotation(); // now we create a graphic state instance -$gs = new SetaPDF_Core_Canvas_GraphicState(); +$gs = new \SetaPDF_Core_Canvas_GraphicState(); // scale it by the DPI factor $gs->scale($dpiFactor, $dpiFactor); @@ -74,8 +74,8 @@ } // this little helper applies the graphic state to a given point -$f = static function(SetaPDF_Core_Geometry_Point $p) use ($gs) { - $v = new SetaPDF_Core_Geometry_Vector($p->getX(), $p->getY(), 0); +$f = static function(\SetaPDF_Core_Geometry_Point $p) use ($gs) { + $v = new \SetaPDF_Core_Geometry_Vector($p->getX(), $p->getY(), 0); return $v->multiply($gs->getCurrentTransformationMatrix())->toPoint(); }; @@ -86,7 +86,7 @@ foreach ($words as $word) { foreach ($word->getBounds() as $bounds) { // create a rectangle with ordered vertices (because e.g. Ll will not be lower left after a rotation) - $rect = new SetaPDF_Core_Geometry_Rectangle( + $rect = new \SetaPDF_Core_Geometry_Rectangle( $f($bounds->getLl()), $f($bounds->getUr()) ); diff --git a/public/demos/2-Extractor/various/highlight-words/script.php b/public/demos/2-Extractor/various/highlight-words/script.php index b861a75..a5f542a 100644 --- a/public/demos/2-Extractor/various/highlight-words/script.php +++ b/public/demos/2-Extractor/various/highlight-words/script.php @@ -14,9 +14,9 @@ ]); // load the document -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/tektown/Terms-and-Conditions.pdf', - new SetaPDF_Core_Writer_Http('document.pdf', true) + new \SetaPDF_Core_Writer_Http('document.pdf', true) ); // initate an extractor instance @@ -71,10 +71,10 @@ // if a match occurs, create a highlight annotation and add it to the pages annotations instance $bounds = $_word['bounds']; foreach ($bounds AS $bound) { - $rect = new SetaPDF_Core_Geometry_Rectangle($bound->getLl(), $bound->getUr()); - $rect = SetaPDF_Core_DataStructure_Rectangle::byRectangle($rect); + $rect = new \SetaPDF_Core_Geometry_Rectangle($bound->getLl(), $bound->getUr()); + $rect = \SetaPDF_Core_DataStructure_Rectangle::byRectangle($rect); - $annotation = new SetaPDF_Core_Document_Page_Annotation_Highlight($rect); + $annotation = new \SetaPDF_Core_Document_Page_Annotation_Highlight($rect); $annotation->setColor([1, 1, 0]); $annotation->setContents('Match #' . (++$found)); $annotation->setPrintFlag(); diff --git a/public/demos/2-Extractor/various/phrase-search/script.php b/public/demos/2-Extractor/various/phrase-search/script.php index 210a210..5728530 100644 --- a/public/demos/2-Extractor/various/phrase-search/script.php +++ b/public/demos/2-Extractor/various/phrase-search/script.php @@ -10,9 +10,9 @@ return preg_quote($part, '/'); }, preg_split('/\s/', trim($text)))) . '/ui'; -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/Brand-Guide.pdf', - new SetaPDF_Core_Writer_Http('search.pdf', true) + new \SetaPDF_Core_Writer_Http('search.pdf', true) ); if ($regex !== '//ui') { diff --git a/public/demos/2-Extractor/various/the-boundary-box-parameter/script.php b/public/demos/2-Extractor/various/the-boundary-box-parameter/script.php index 54dd75e..bb2282c 100644 --- a/public/demos/2-Extractor/various/the-boundary-box-parameter/script.php +++ b/public/demos/2-Extractor/various/the-boundary-box-parameter/script.php @@ -4,18 +4,18 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; $boxes = [ - SetaPDF_Core_PageBoundaries::MEDIA_BOX, - SetaPDF_Core_PageBoundaries::CROP_BOX, - SetaPDF_Core_PageBoundaries::BLEED_BOX, - SetaPDF_Core_PageBoundaries::TRIM_BOX, - SetaPDF_Core_PageBoundaries::ART_BOX, + \SetaPDF_Core_PageBoundaries::MEDIA_BOX, + \SetaPDF_Core_PageBoundaries::CROP_BOX, + \SetaPDF_Core_PageBoundaries::BLEED_BOX, + \SetaPDF_Core_PageBoundaries::TRIM_BOX, + \SetaPDF_Core_PageBoundaries::ART_BOX, ]; $boundaryBox = displaySelect('Page Boundary box:', $boxes); $path = $assetsDirectory . '/pdfs/misc/Page-Boundaries.pdf'; -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $extractor = new SetaPDF_Extractor($document); diff --git a/public/demos/3-FormFiller/field-types/1-text-fields/script.php b/public/demos/3-FormFiller/field-types/1-text-fields/script.php index bda68a2..0f88966 100644 --- a/public/demos/3-FormFiller/field-types/1-text-fields/script.php +++ b/public/demos/3-FormFiller/field-types/1-text-fields/script.php @@ -3,9 +3,9 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/tektown/Subscription-tekMag.pdf', - new SetaPDF_Core_Writer_Http('filled.pdf', true) + new \SetaPDF_Core_Writer_Http('filled.pdf', true) ); $formFiller = new SetaPDF_FormFiller($document); diff --git a/public/demos/3-FormFiller/field-types/2-multiline-text-fields/script.php b/public/demos/3-FormFiller/field-types/2-multiline-text-fields/script.php index c39c4ea..6a0e9c8 100644 --- a/public/demos/3-FormFiller/field-types/2-multiline-text-fields/script.php +++ b/public/demos/3-FormFiller/field-types/2-multiline-text-fields/script.php @@ -3,9 +3,9 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/forms/Customizer-Example.pdf', - new SetaPDF_Core_Writer_Http('filled.pdf', true) + new \SetaPDF_Core_Writer_Http('filled.pdf', true) ); $formFiller = new SetaPDF_FormFiller($document); diff --git a/public/demos/3-FormFiller/field-types/3-check-boxes/script.php b/public/demos/3-FormFiller/field-types/3-check-boxes/script.php index 729fe6b..5543bbb 100644 --- a/public/demos/3-FormFiller/field-types/3-check-boxes/script.php +++ b/public/demos/3-FormFiller/field-types/3-check-boxes/script.php @@ -3,9 +3,9 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/forms/Customizer-Example.pdf', - new SetaPDF_Core_Writer_Http('filled.pdf', true) + new \SetaPDF_Core_Writer_Http('filled.pdf', true) ); $formFiller = new SetaPDF_FormFiller($document); diff --git a/public/demos/3-FormFiller/field-types/4-radio-button-groups/script.php b/public/demos/3-FormFiller/field-types/4-radio-button-groups/script.php index ee96b36..fea66f5 100644 --- a/public/demos/3-FormFiller/field-types/4-radio-button-groups/script.php +++ b/public/demos/3-FormFiller/field-types/4-radio-button-groups/script.php @@ -3,9 +3,9 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/forms/Customizer-Example.pdf', - new SetaPDF_Core_Writer_Http('filled.pdf', true) + new \SetaPDF_Core_Writer_Http('filled.pdf', true) ); $formFiller = new SetaPDF_FormFiller($document); diff --git a/public/demos/3-FormFiller/field-types/5-list-fields/script.php b/public/demos/3-FormFiller/field-types/5-list-fields/script.php index bb0a0fe..274dc12 100644 --- a/public/demos/3-FormFiller/field-types/5-list-fields/script.php +++ b/public/demos/3-FormFiller/field-types/5-list-fields/script.php @@ -3,9 +3,9 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/forms/Sunnysunday-Example.pdf', - new SetaPDF_Core_Writer_Http('filled.pdf', true) + new \SetaPDF_Core_Writer_Http('filled.pdf', true) ); $formFiller = new SetaPDF_FormFiller($document); diff --git a/public/demos/3-FormFiller/field-types/6-combo-boxes/script.php b/public/demos/3-FormFiller/field-types/6-combo-boxes/script.php index 78adcd8..d7f4b20 100644 --- a/public/demos/3-FormFiller/field-types/6-combo-boxes/script.php +++ b/public/demos/3-FormFiller/field-types/6-combo-boxes/script.php @@ -3,9 +3,9 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/forms/Customizer-Example.pdf', - new SetaPDF_Core_Writer_Http('filled.pdf', true) + new \SetaPDF_Core_Writer_Http('filled.pdf', true) ); $formFiller = new SetaPDF_FormFiller($document); diff --git a/public/demos/3-FormFiller/field-types/7-signature-and-push-button-fields/script.php b/public/demos/3-FormFiller/field-types/7-signature-and-push-button-fields/script.php index aaabd42..5192d59 100644 --- a/public/demos/3-FormFiller/field-types/7-signature-and-push-button-fields/script.php +++ b/public/demos/3-FormFiller/field-types/7-signature-and-push-button-fields/script.php @@ -3,9 +3,9 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/etown/Order-Form.pdf', - new SetaPDF_Core_Writer_Http('flatten.pdf', true) + new \SetaPDF_Core_Writer_Http('flatten.pdf', true) ); $formFiller = new SetaPDF_FormFiller($document); diff --git a/public/demos/3-FormFiller/field-types/8-fill-all-field-types/script.php b/public/demos/3-FormFiller/field-types/8-fill-all-field-types/script.php index e657349..2fc076b 100644 --- a/public/demos/3-FormFiller/field-types/8-fill-all-field-types/script.php +++ b/public/demos/3-FormFiller/field-types/8-fill-all-field-types/script.php @@ -12,9 +12,9 @@ $dataId = displaySelect('Select file:', $files, true, 'displayValue'); $data = $files[$dataId]; -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $data['file'], - new SetaPDF_Core_Writer_Http('filled.pdf', true) + new \SetaPDF_Core_Writer_Http('filled.pdf', true) ); $formFiller = new SetaPDF_FormFiller($document); diff --git a/public/demos/3-FormFiller/various/1-get-field-names-and-types/script.php b/public/demos/3-FormFiller/various/1-get-field-names-and-types/script.php index 74bc9d9..ab7b85b 100644 --- a/public/demos/3-FormFiller/various/1-get-field-names-and-types/script.php +++ b/public/demos/3-FormFiller/various/1-get-field-names-and-types/script.php @@ -12,7 +12,7 @@ $path = displayFiles($files); -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $formFiller = new SetaPDF_FormFiller($document); diff --git a/public/demos/3-FormFiller/various/1.1-get-field-information/script.php b/public/demos/3-FormFiller/various/1.1-get-field-information/script.php index 70dcee8..1c42782 100644 --- a/public/demos/3-FormFiller/various/1.1-get-field-information/script.php +++ b/public/demos/3-FormFiller/various/1.1-get-field-information/script.php @@ -25,7 +25,7 @@ function drawPropertyTable($caption, $data) { } // create the document instance -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); // now get an instance of the form filler $formFiller = new SetaPDF_FormFiller($document); diff --git a/public/demos/3-FormFiller/various/2-access-same-named-fields/script.php b/public/demos/3-FormFiller/various/2-access-same-named-fields/script.php index 94359d5..bb736ff 100644 --- a/public/demos/3-FormFiller/various/2-access-same-named-fields/script.php +++ b/public/demos/3-FormFiller/various/2-access-same-named-fields/script.php @@ -3,8 +3,8 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('filled.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('filled.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/etown/Terms-and-Conditions.pdf', $writer ); diff --git a/public/demos/3-FormFiller/various/3-flatten-fields/script.php b/public/demos/3-FormFiller/various/3-flatten-fields/script.php index f83d4d8..bb40a24 100644 --- a/public/demos/3-FormFiller/various/3-flatten-fields/script.php +++ b/public/demos/3-FormFiller/various/3-flatten-fields/script.php @@ -24,9 +24,9 @@ $fieldToFlatten = displaySelect('Flatten:', $options); -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/forms/Sunnysunday-Example.pdf', - new SetaPDF_Core_Writer_Http('flatten.pdf', true) + new \SetaPDF_Core_Writer_Http('flatten.pdf', true) ); $formFiller = new SetaPDF_FormFiller($document); diff --git a/public/demos/3-FormFiller/various/4-fill-field-with-image-or-pdf-page/script.php b/public/demos/3-FormFiller/various/4-fill-field-with-image-or-pdf-page/script.php index 662ae58..cd69e67 100644 --- a/public/demos/3-FormFiller/various/4-fill-field-with-image-or-pdf-page/script.php +++ b/public/demos/3-FormFiller/various/4-fill-field-with-image-or-pdf-page/script.php @@ -9,9 +9,9 @@ ]); // get the main document isntance -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/Fact-Sheet-form.pdf', - new SetaPDF_Core_Writer_Http('Fact-Sheet.pdf', true) + new \SetaPDF_Core_Writer_Http('Fact-Sheet.pdf', true) ); // get an instance of the form filler @@ -42,27 +42,27 @@ // create a form xobject to which we are going to write the image // this form xobject will be the resulting appearance of our form field -$xobject = SetaPDF_Core_XObject_Form::create($document, [0, 0, $width, $height]); +$xobject = \SetaPDF_Core_XObject_Form::create($document, [0, 0, $width, $height]); // get the canvas for this xobject $canvas = $xobject->getCanvas(); if ($imageOrPdf === 'image') { // let's create an image xobject - $image = SetaPDF_Core_Image::getByPath( + $image = \SetaPDF_Core_Image::getByPath( $assetsDirectory . '/pdfs/tektown/Logo.png' )->toXObject($document); // or e.g. through base64 encoded image data: //$data = base64_decode('iVBORw0KGgoAAAANSUhEUgAABJYAAAEmCAYAAAAwZRqhAAAgAElEQVR4Xu.../w+l98Lb9eaTFwAAAABJRU5ErkJggg=='); - //$image = SetaPDF_Core_Image::get(new SetaPDF_Core_Reader_String($data))->toXObject($document); + //$image = \SetaPDF_Core_Image::get(new \SetaPDF_Core_Reader_String($data))->toXObject($document); } else { // let's use an existing PDF page as the logo appearance - $logoDoc = SetaPDF_Core_Document::loadByFilename( + $logoDoc = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/tektown/Logo.pdf' ); $image = $logoDoc->getCatalog()->getPages()->getPage(1)->toXObject( - $document, SetaPDF_Core_PageBoundaries::ART_BOX + $document, \SetaPDF_Core_PageBoundaries::ART_BOX ); } diff --git a/public/demos/3-FormFiller/various/5-individual-font-and-color-space/script.php b/public/demos/3-FormFiller/various/5-individual-font-and-color-space/script.php index 74ecb48..e3e2897 100644 --- a/public/demos/3-FormFiller/various/5-individual-font-and-color-space/script.php +++ b/public/demos/3-FormFiller/various/5-individual-font-and-color-space/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // get the main document instance -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/tektown/Order-Form-without-Signaturefield.pdf', - new SetaPDF_Core_Writer_Http('OwnFontAndTextColor.pdf', true) + new \SetaPDF_Core_Writer_Http('OwnFontAndTextColor.pdf', true) ); // now get an instance of the form filler @@ -16,27 +16,27 @@ $fields = $formFiller->getFields(); // create a spot color/space -$colorSpace = SetaPDF_Core_ColorSpace_Separation::createSpotColor($document, 'HKS 27 N', .3, 1, 0, 0); -$color = new SetaPDF_Core_DataStructure_Color_Special(1); +$colorSpace = \SetaPDF_Core_ColorSpace_Separation::createSpotColor($document, 'HKS 27 N', .3, 1, 0, 0); +$color = new \SetaPDF_Core_DataStructure_Color_Special(1); // let's create a font instance DejaVu Sans Condensed as a TrueType font subset -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSansCondensed-Oblique.ttf' ); // Or as a CID font with true type outlines which allows you to use more than 255 characters /* -$font = new SetaPDF_Core_Font_Type0_Subset( +$font = new \SetaPDF_Core_Font_Type0_Subset( $document, $assetsDirectory . '/fonts/dDejaVu/ttf/DejaVuSansCondensed-Oblique.ttf' );*/ /* NOT RECOMMENDED: alternatively you can create an instance with a font which will not be embedded.*/ -/* $font = SetaPDF_Core_Font_TrueType::create( +/* $font = \SetaPDF_Core_Font_TrueType::create( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSansCondensed-Oblique.ttf', - SetaPDF_Core_Encoding::WIN_ANSI, + \SetaPDF_Core_Encoding::WIN_ANSI, 'auto', false // <-- don't embedded );*/ diff --git a/public/demos/3-FormFiller/various/6-fill-one-template-several-times/script.php b/public/demos/3-FormFiller/various/6-fill-one-template-several-times/script.php index 3c90ea5..9d54942 100644 --- a/public/demos/3-FormFiller/various/6-fill-one-template-several-times/script.php +++ b/public/demos/3-FormFiller/various/6-fill-one-template-several-times/script.php @@ -20,8 +20,8 @@ // not iterate through the data and create PDFs foreach ($participants as $participant) { - $writer = new SetaPDF_Core_Writer_String(); - $document = SetaPDF_Core_Document::loadByFilename( + $writer = new \SetaPDF_Core_Writer_String(); + $document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/Name-Badge.pdf', $writer ); diff --git a/public/demos/3-FormFiller/various/7-fill-with-rich-text-styling/script.php b/public/demos/3-FormFiller/various/7-fill-with-rich-text-styling/script.php index c4277dc..3eb4696 100644 --- a/public/demos/3-FormFiller/various/7-fill-with-rich-text-styling/script.php +++ b/public/demos/3-FormFiller/various/7-fill-with-rich-text-styling/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // get the main document isntance -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/Fact-Sheet-form.pdf', - new SetaPDF_Core_Writer_Http('Fact-Sheet.pdf', true) + new \SetaPDF_Core_Writer_Http('Fact-Sheet.pdf', true) ); // get an instance of the form filler @@ -26,7 +26,7 @@ // create a form xobject to which we are going to write the rich-text block // this form xobject will be the resulting appearance of our form field -$xobject = SetaPDF_Core_XObject_Form::create($document, [0, 0, $width, $height]); +$xobject = \SetaPDF_Core_XObject_Form::create($document, [0, 0, $width, $height]); // get the canvas for this xobject $canvas = $xobject->getCanvas(); @@ -38,13 +38,13 @@ $fontLoader = new \com\setasign\SetaPDF\Demos\FontLoader($assetsDirectory); // create a rich-text block instance -$textBlock = new SetaPDF_Core_Text_RichTextBlock($document); +$textBlock = new \SetaPDF_Core_Text_RichTextBlock($document); $textBlock->registerFontLoader($fontLoader); $textBlock->setTextWidth($width - 4); $textBlock->setPadding(2); $textBlock->setDefaultFontFamily('DejaVuSans'); $textBlock->setDefaultFontSize(10); -$textBlock->setAlign(SetaPDF_Core_Text::ALIGN_JUSTIFY); +$textBlock->setAlign(\SetaPDF_Core_Text::ALIGN_JUSTIFY); // define and set its text $text = <<Lorem ipsum dolor sit amet, consetetur sadipscing elitr diff --git a/public/demos/3-FormFiller/xfa/1-fill-dynamic-xfa-form/script.php b/public/demos/3-FormFiller/xfa/1-fill-dynamic-xfa-form/script.php index bebb112..e52eea9 100644 --- a/public/demos/3-FormFiller/xfa/1-fill-dynamic-xfa-form/script.php +++ b/public/demos/3-FormFiller/xfa/1-fill-dynamic-xfa-form/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // get the document isntance -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/forms/xfa/Badge.pdf', - new SetaPDF_Core_Writer_Http('dynamic-xfa-form.pdf') + new \SetaPDF_Core_Writer_Http('dynamic-xfa-form.pdf') ); // now get an instance of the form filler diff --git a/public/demos/3-FormFiller/xfa/2-fill-static-xfa-form/script.php b/public/demos/3-FormFiller/xfa/2-fill-static-xfa-form/script.php index c135260..50270e6 100644 --- a/public/demos/3-FormFiller/xfa/2-fill-static-xfa-form/script.php +++ b/public/demos/3-FormFiller/xfa/2-fill-static-xfa-form/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // get the document isntance -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/forms/xfa/CheckRequest.pdf', - new SetaPDF_Core_Writer_Http('static-xfa-form.pdf', true) + new \SetaPDF_Core_Writer_Http('static-xfa-form.pdf', true) ); // now get an instance of the form filler diff --git a/public/demos/3-FormFiller/xfa/3-remove-xfa-package/script.php b/public/demos/3-FormFiller/xfa/3-remove-xfa-package/script.php index 82ed54b..cfbc9be 100644 --- a/public/demos/3-FormFiller/xfa/3-remove-xfa-package/script.php +++ b/public/demos/3-FormFiller/xfa/3-remove-xfa-package/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // get the document isntance -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/forms/xfa/CheckRequest.pdf', - new SetaPDF_Core_Writer_Http('normal-acro-form.pdf', true) + new \SetaPDF_Core_Writer_Http('normal-acro-form.pdf', true) ); // now get an instance of the form filler diff --git a/public/demos/4-Merger/default-merge-processes/1-merge-several-pdf-files/script.php b/public/demos/4-Merger/default-merge-processes/1-merge-several-pdf-files/script.php index 71a2323..7171156 100644 --- a/public/demos/4-Merger/default-merge-processes/1-merge-several-pdf-files/script.php +++ b/public/demos/4-Merger/default-merge-processes/1-merge-several-pdf-files/script.php @@ -22,6 +22,6 @@ // get access to the document instance $document = $merger->getDocument(); // set a writer instance -$document->setWriter(new SetaPDF_Core_Writer_Http('merged.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('merged.pdf', true)); // and save the result to the writer $document->save()->finish(); diff --git a/public/demos/4-Merger/default-merge-processes/2-merge-document-instances/script.php b/public/demos/4-Merger/default-merge-processes/2-merge-document-instances/script.php index bb9e3c5..0d7aded 100644 --- a/public/demos/4-Merger/default-merge-processes/2-merge-document-instances/script.php +++ b/public/demos/4-Merger/default-merge-processes/2-merge-document-instances/script.php @@ -14,7 +14,7 @@ foreach ($paths as $path) { // ...for demonstration we initiate the document instances from a string variable $pdfString = file_get_contents($path); - $document = SetaPDF_Core_Document::loadByString($pdfString); + $document = \SetaPDF_Core_Document::loadByString($pdfString); $merger->addDocument($document); } @@ -24,6 +24,6 @@ // get access to the document instance $document = $merger->getDocument(); // set a writer instance -$document->setWriter(new SetaPDF_Core_Writer_Http('merged.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('merged.pdf', true)); // and save the result to the writer $document->save()->finish(); diff --git a/public/demos/4-Merger/default-merge-processes/3-individual-page-ranges/script.php b/public/demos/4-Merger/default-merge-processes/3-individual-page-ranges/script.php index dac88b0..adc77f4 100644 --- a/public/demos/4-Merger/default-merge-processes/3-individual-page-ranges/script.php +++ b/public/demos/4-Merger/default-merge-processes/3-individual-page-ranges/script.php @@ -33,6 +33,6 @@ // get access to the document instance $document = $merger->getDocument(); // set a writer instance -$document->setWriter(new SetaPDF_Core_Writer_Http('merged.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('merged.pdf', true)); // and save the result to the writer $document->save()->finish(); diff --git a/public/demos/4-Merger/default-merge-processes/4-add-named-destinations/script.php b/public/demos/4-Merger/default-merge-processes/4-add-named-destinations/script.php index b203ce8..b3d7a76 100644 --- a/public/demos/4-Merger/default-merge-processes/4-add-named-destinations/script.php +++ b/public/demos/4-Merger/default-merge-processes/4-add-named-destinations/script.php @@ -47,6 +47,6 @@ // get access to the document instance $document = $merger->getDocument(); // set a writer instance -$document->setWriter(new SetaPDF_Core_Writer_Http('merged-with-named-destinations.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('merged-with-named-destinations.pdf', true)); // and save the result to the writer $document->save()->finish(); diff --git a/public/demos/4-Merger/default-merge-processes/5-append-pages/script.php b/public/demos/4-Merger/default-merge-processes/5-append-pages/script.php index c1c86cc..9bf229b 100644 --- a/public/demos/4-Merger/default-merge-processes/5-append-pages/script.php +++ b/public/demos/4-Merger/default-merge-processes/5-append-pages/script.php @@ -4,10 +4,10 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // create a http writer object -$writer = new SetaPDF_Core_Writer_Http('append.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('append.pdf', true); // load the inital document -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Order-Form.pdf', $writer ); diff --git a/public/demos/4-Merger/default-merge-processes/6-repeat-a-single-page/script.php b/public/demos/4-Merger/default-merge-processes/6-repeat-a-single-page/script.php index 03a333b..2d5c2fe 100644 --- a/public/demos/4-Merger/default-merge-processes/6-repeat-a-single-page/script.php +++ b/public/demos/4-Merger/default-merge-processes/6-repeat-a-single-page/script.php @@ -14,7 +14,7 @@ $merger->addFile($path, 1); } else { // load the inital document - $document = SetaPDF_Core_Document::loadByFilename($path); + $document = \SetaPDF_Core_Document::loadByFilename($path); $merger->addDocument($document, 1); } } @@ -23,7 +23,7 @@ $merger->merge(); $document = $merger->getDocument(); -$document->setWriter(new SetaPDF_Core_Writer_Http('repeated.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('repeated.pdf', true)); // save and finish the initial document $document->save()->finish(); diff --git a/public/demos/4-Merger/default-merge-processes/7-insert-pages/script.php b/public/demos/4-Merger/default-merge-processes/7-insert-pages/script.php index c8d4dca..5baf8a2 100644 --- a/public/demos/4-Merger/default-merge-processes/7-insert-pages/script.php +++ b/public/demos/4-Merger/default-merge-processes/7-insert-pages/script.php @@ -42,5 +42,5 @@ $documentA = $merger->getDocumentByFileName($main); $document->getInfo()->setAll($documentA->getInfo()->getAll()); -$document->setWriter(new SetaPDF_Core_Writer_Http('insert-pages.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('insert-pages.pdf', true)); $document->save()->finish(); diff --git a/public/demos/4-Merger/document-outlines/1-outline-item-per-document/script.php b/public/demos/4-Merger/document-outlines/1-outline-item-per-document/script.php index a86b490..998384a 100644 --- a/public/demos/4-Merger/document-outlines/1-outline-item-per-document/script.php +++ b/public/demos/4-Merger/document-outlines/1-outline-item-per-document/script.php @@ -30,7 +30,7 @@ $document = $merger->getDocument(); // show outlines when document opens -$document->getCatalog()->setPageMode(SetaPDF_Core_Document_PageMode::USE_OUTLINES); +$document->getCatalog()->setPageMode(\SetaPDF_Core_Document_PageMode::USE_OUTLINES); -$document->setWriter(new SetaPDF_Core_Writer_Http('simple-bookmark-outline.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('simple-bookmark-outline.pdf', true)); $document->save()->finish(); diff --git a/public/demos/4-Merger/document-outlines/2-style-outline-items/script.php b/public/demos/4-Merger/document-outlines/2-style-outline-items/script.php index d109d93..91883ea 100644 --- a/public/demos/4-Merger/document-outlines/2-style-outline-items/script.php +++ b/public/demos/4-Merger/document-outlines/2-style-outline-items/script.php @@ -38,7 +38,7 @@ $document = $merger->getDocument(); // show outlines when document opens -$document->getCatalog()->setPageMode(SetaPDF_Core_Document_PageMode::USE_OUTLINES); +$document->getCatalog()->setPageMode(\SetaPDF_Core_Document_PageMode::USE_OUTLINES); -$document->setWriter(new SetaPDF_Core_Writer_Http('styled-bookmark-outline.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('styled-bookmark-outline.pdf', true)); $document->save()->finish(); diff --git a/public/demos/4-Merger/document-outlines/3-structure-ouline-items/script.php b/public/demos/4-Merger/document-outlines/3-structure-ouline-items/script.php index 7662e76..4ea6166 100644 --- a/public/demos/4-Merger/document-outlines/3-structure-ouline-items/script.php +++ b/public/demos/4-Merger/document-outlines/3-structure-ouline-items/script.php @@ -3,14 +3,14 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$document = new SetaPDF_Core_Document(); -$document->setWriter(new SetaPDF_Core_Writer_Http('structured-bookmark-outline.pdf', true)); +$document = new \SetaPDF_Core_Document(); +$document->setWriter(new \SetaPDF_Core_Writer_Http('structured-bookmark-outline.pdf', true)); // show outlines when document opens -$document->getCatalog()->setPageMode(SetaPDF_Core_Document_PageMode::USE_OUTLINES); +$document->getCatalog()->setPageMode(\SetaPDF_Core_Document_PageMode::USE_OUTLINES); // create a root outline item $outlines = $document->getCatalog()->getOutlines(); -$root = SetaPDF_Core_Document_OutlinesItem::create($document, 'Products'); +$root = \SetaPDF_Core_Document_OutlinesItem::create($document, 'Products'); $outlines->appendChild($root); // initiate the merger with the prepared document instance diff --git a/public/demos/4-Merger/document-outlines/4-import-outlines-to-root/script.php b/public/demos/4-Merger/document-outlines/4-import-outlines-to-root/script.php index 3d6c95b..fe1ba7d 100644 --- a/public/demos/4-Merger/document-outlines/4-import-outlines-to-root/script.php +++ b/public/demos/4-Merger/document-outlines/4-import-outlines-to-root/script.php @@ -26,7 +26,7 @@ $document = $merger->getDocument(); // show outlines when document opens -$document->getCatalog()->setPageMode(SetaPDF_Core_Document_PageMode::USE_OUTLINES); +$document->getCatalog()->setPageMode(\SetaPDF_Core_Document_PageMode::USE_OUTLINES); -$document->setWriter(new SetaPDF_Core_Writer_Http('outlines-in-root.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('outlines-in-root.pdf', true)); $document->save()->finish(); diff --git a/public/demos/4-Merger/document-outlines/5-import-outlines-for-each-document/script.php b/public/demos/4-Merger/document-outlines/5-import-outlines-for-each-document/script.php index 35de9e4..e772835 100644 --- a/public/demos/4-Merger/document-outlines/5-import-outlines-for-each-document/script.php +++ b/public/demos/4-Merger/document-outlines/5-import-outlines-for-each-document/script.php @@ -28,7 +28,7 @@ $document = $merger->getDocument(); // show outlines when document opens -$document->getCatalog()->setPageMode(SetaPDF_Core_Document_PageMode::USE_OUTLINES); +$document->getCatalog()->setPageMode(\SetaPDF_Core_Document_PageMode::USE_OUTLINES); // we also going to items in the root node $iterator = $document->getCatalog()->getOutlines()->getIterator(); @@ -37,5 +37,5 @@ $item->close(); } -$document->setWriter(new SetaPDF_Core_Writer_Http('oultines-as-childs.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('oultines-as-childs.pdf', true)); $document->save()->finish(); diff --git a/public/demos/4-Merger/pdf-portfolios/1-create-a-simple-portfolio/script.php b/public/demos/4-Merger/pdf-portfolios/1-create-a-simple-portfolio/script.php index 0d8fde7..b615953 100644 --- a/public/demos/4-Merger/pdf-portfolios/1-create-a-simple-portfolio/script.php +++ b/public/demos/4-Merger/pdf-portfolios/1-create-a-simple-portfolio/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // create a document as the cover sheet -$writer = new SetaPDF_Core_Writer_Http('simple-portfolio.pdf'); -$document = new SetaPDF_Core_Document($writer); -$document->getCatalog()->getPages()->create(SetaPDF_Core_PageFormats::A4); +$writer = new \SetaPDF_Core_Writer_Http('simple-portfolio.pdf'); +$document = new \SetaPDF_Core_Document($writer); +$document->getCatalog()->getPages()->create(\SetaPDF_Core_PageFormats::A4); // we leave it empty for demonstration purpose... // create a collection instance @@ -22,7 +22,7 @@ // add a dynamically created text file $textFile = 'A simple text content'; $collection->addFile( - new SetaPDF_Core_Reader_String($textFile), + new \SetaPDF_Core_Reader_String($textFile), 'text-file.txt', 'The description of the text file.' ); diff --git a/public/demos/4-Merger/pdf-portfolios/2-create-portfolio-with-folders/script.php b/public/demos/4-Merger/pdf-portfolios/2-create-portfolio-with-folders/script.php index 9f8ae7a..52948be 100644 --- a/public/demos/4-Merger/pdf-portfolios/2-create-portfolio-with-folders/script.php +++ b/public/demos/4-Merger/pdf-portfolios/2-create-portfolio-with-folders/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // create a document as the cover sheet -$writer = new SetaPDF_Core_Writer_Http('portfolio-with-folders.pdf'); -$document = new SetaPDF_Core_Document($writer); -$document->getCatalog()->getPages()->create(SetaPDF_Core_PageFormats::A4); +$writer = new \SetaPDF_Core_Writer_Http('portfolio-with-folders.pdf'); +$document = new \SetaPDF_Core_Document($writer); +$document->getCatalog()->getPages()->create(\SetaPDF_Core_PageFormats::A4); // we leave it empty for demonstration purpose... // create a collection instance diff --git a/public/demos/4-Merger/pdf-portfolios/3-create-porfolio-with-dynamic-files-and-metadata/script.php b/public/demos/4-Merger/pdf-portfolios/3-create-porfolio-with-dynamic-files-and-metadata/script.php index f1bc099..f419a2a 100644 --- a/public/demos/4-Merger/pdf-portfolios/3-create-porfolio-with-dynamic-files-and-metadata/script.php +++ b/public/demos/4-Merger/pdf-portfolios/3-create-porfolio-with-dynamic-files-and-metadata/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // create a document as the cover sheet -$writer = new SetaPDF_Core_Writer_Http('dynamic-portfolio.pdf'); -$document = new SetaPDF_Core_Document($writer); -$document->getCatalog()->getPages()->create(SetaPDF_Core_PageFormats::A4); +$writer = new \SetaPDF_Core_Writer_Http('dynamic-portfolio.pdf'); +$document = new \SetaPDF_Core_Document($writer); +$document->getCatalog()->getPages()->create(\SetaPDF_Core_PageFormats::A4); // we leave it empty for demonstration purpose... // create a collection instance @@ -15,16 +15,16 @@ // add a dynamically created text file $textFile = 'A simple text content'; $collection->addFile( - new SetaPDF_Core_Reader_String($textFile), + new \SetaPDF_Core_Reader_String($textFile), 'text-file.txt', 'The description of the text file.', [ // an optional check sum - SetaPDF_Core_EmbeddedFileStream::PARAM_CHECK_SUM => md5($textFile, true), + \SetaPDF_Core_EmbeddedFileStream::PARAM_CHECK_SUM => md5($textFile, true), // modification and creation date are default columns and set automatically // to the current date time. If you want to define them manually: - SetaPDF_Core_EmbeddedFileStream::PARAM_MODIFICATION_DATE => new DateTime('yesterday'), - SetaPDF_Core_EmbeddedFileStream::PARAM_CREATION_DATE => new DateTime('-1 week') + \SetaPDF_Core_EmbeddedFileStream::PARAM_MODIFICATION_DATE => new DateTime('yesterday'), + \SetaPDF_Core_EmbeddedFileStream::PARAM_CREATION_DATE => new DateTime('-1 week') ], 'text/plain' ); @@ -32,7 +32,7 @@ // add another dynamically created text file $textFile = 'Another simple text content'; $name = $collection->addFile( - new SetaPDF_Core_Reader_String($textFile), + new \SetaPDF_Core_Reader_String($textFile), 'another-text-file.txt', 'The description of the other text file.', [], @@ -43,9 +43,9 @@ // get the embedded file stream and add additional parameters $fileSpecification->getEmbeddedFileStream()->setParams([ - SetaPDF_Core_EmbeddedFileStream::PARAM_CHECK_SUM => md5($textFile, true), - SetaPDF_Core_EmbeddedFileStream::PARAM_MODIFICATION_DATE => new DateTime('yesterday'), - SetaPDF_Core_EmbeddedFileStream::PARAM_CREATION_DATE => new DateTime('last Wednesday') + \SetaPDF_Core_EmbeddedFileStream::PARAM_CHECK_SUM => md5($textFile, true), + \SetaPDF_Core_EmbeddedFileStream::PARAM_MODIFICATION_DATE => new DateTime('yesterday'), + \SetaPDF_Core_EmbeddedFileStream::PARAM_CREATION_DATE => new DateTime('last Wednesday') ], false); // save and finish diff --git a/public/demos/4-Merger/pdf-portfolios/4-create-portfolio-with-schema/script.php b/public/demos/4-Merger/pdf-portfolios/4-create-portfolio-with-schema/script.php index 2c375d2..c27f4a0 100644 --- a/public/demos/4-Merger/pdf-portfolios/4-create-portfolio-with-schema/script.php +++ b/public/demos/4-Merger/pdf-portfolios/4-create-portfolio-with-schema/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // create a document as the cover sheet -$writer = new SetaPDF_Core_Writer_Http('portfolio-with-schema.pdf'); -$document = new SetaPDF_Core_Document($writer); -$document->getCatalog()->getPages()->create(SetaPDF_Core_PageFormats::A4); +$writer = new \SetaPDF_Core_Writer_Http('portfolio-with-schema.pdf'); +$document = new \SetaPDF_Core_Document($writer); +$document->getCatalog()->getPages()->create(\SetaPDF_Core_PageFormats::A4); // we leave it empty for demonstration purpose... // create a collection instance @@ -61,7 +61,7 @@ [], 'application/pdf', [ - 'company' => SetaPDF_Core_Encoding::toPdfString('tektown'), + 'company' => \SetaPDF_Core_Encoding::toPdfString('tektown'), 'order' => 3 ] ); @@ -73,7 +73,7 @@ [], 'application/pdf', [ - 'company' => SetaPDF_Core_Encoding::toPdfString('etown'), + 'company' => \SetaPDF_Core_Encoding::toPdfString('etown'), 'order' => 2 ] ); @@ -85,7 +85,7 @@ [], 'application/pdf', [ - 'company' => SetaPDF_Core_Encoding::toPdfString('lenstown'), + 'company' => \SetaPDF_Core_Encoding::toPdfString('lenstown'), 'order' => 4 ] ); @@ -109,7 +109,7 @@ [], 'image/png', [ - 'company' => SetaPDF_Core_Encoding::toPdfString('tektown'), + 'company' => \SetaPDF_Core_Encoding::toPdfString('tektown'), 'order' => 3 ] ); @@ -121,7 +121,7 @@ [], 'image/png', [ - 'company' => SetaPDF_Core_Encoding::toPdfString('etown'), + 'company' => \SetaPDF_Core_Encoding::toPdfString('etown'), 'order' => 2 ] ); @@ -133,7 +133,7 @@ [], 'image/png', [ - 'company' => SetaPDF_Core_Encoding::toPdfString('lenstown'), + 'company' => \SetaPDF_Core_Encoding::toPdfString('lenstown'), 'order' => 1 ] ); diff --git a/public/demos/4-Merger/pdf-portfolios/5-extract-files/script.php b/public/demos/4-Merger/pdf-portfolios/5-extract-files/script.php index 331d156..6ae5b2b 100644 --- a/public/demos/4-Merger/pdf-portfolios/5-extract-files/script.php +++ b/public/demos/4-Merger/pdf-portfolios/5-extract-files/script.php @@ -4,7 +4,7 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // create a document -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/tektown/products/All-Portfolio.pdf' ); @@ -42,7 +42,7 @@ $stream = $embeddedFileStream->getStream(); header('Content-Type: ' . $contentType); header('Content-Disposition: attachment; ' . - SetaPDF_Core_Writer_Http::encodeFilenameForHttpHeader($filename) + \SetaPDF_Core_Writer_Http::encodeFilenameForHttpHeader($filename) ); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . strlen($stream)); diff --git a/public/demos/4-Merger/pdf-portfolios/6-extract-files-from-folders/script.php b/public/demos/4-Merger/pdf-portfolios/6-extract-files-from-folders/script.php index ed343c6..db29cce 100644 --- a/public/demos/4-Merger/pdf-portfolios/6-extract-files-from-folders/script.php +++ b/public/demos/4-Merger/pdf-portfolios/6-extract-files-from-folders/script.php @@ -4,7 +4,7 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // create a document -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/Logos-Portfolio.pdf' ); @@ -13,7 +13,7 @@ if (isset($_GET['name'])) { $file = $collection->getFile($_GET['name']); - if ($file instanceof SetaPDF_Core_FileSpecification) { + if ($file instanceof \SetaPDF_Core_FileSpecification) { // resolve the filename $filename = $file->getFileSpecification(); // resolve the file stream @@ -27,7 +27,7 @@ $stream = $embeddedFileStream->getStream(); header('Content-Type: ' . $contentType); header('Content-Disposition: attachment; ' . - SetaPDF_Core_Writer_Http::encodeFilenameForHttpHeader($filename) + \SetaPDF_Core_Writer_Http::encodeFilenameForHttpHeader($filename) ); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . strlen($stream)); diff --git a/public/demos/4-Merger/various/1-merge-encrypted-pdfs/script.php b/public/demos/4-Merger/various/1-merge-encrypted-pdfs/script.php index c28cb0e..9b94338 100644 --- a/public/demos/4-Merger/various/1-merge-encrypted-pdfs/script.php +++ b/public/demos/4-Merger/various/1-merge-encrypted-pdfs/script.php @@ -18,7 +18,7 @@ // now create an instance manually $filename = $assetsDirectory . '/pdfs/Fuchslocher-Example (owner-pw setasign).pdf'; -$encryptedDocument = SetaPDF_Core_Document::loadByFilename($filename); +$encryptedDocument = \SetaPDF_Core_Document::loadByFilename($filename); if ($encryptedDocument->hasSecHandler()) { $secHanlder = $encryptedDocument->getSecHandler(); $secHanlder->auth('setasign'); @@ -31,5 +31,5 @@ $merger->merge(); $document = $merger->getDocument(); -$document->setWriter(new SetaPDF_Core_Writer_Http('result.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('result.pdf', true)); $document->save()->finish(); diff --git a/public/demos/4-Merger/various/2-encrypt-resulting-pdf/script.php b/public/demos/4-Merger/various/2-encrypt-resulting-pdf/script.php index 5d71b1c..cc88fd4 100644 --- a/public/demos/4-Merger/various/2-encrypt-resulting-pdf/script.php +++ b/public/demos/4-Merger/various/2-encrypt-resulting-pdf/script.php @@ -15,16 +15,16 @@ * copy (for the user - need to be respected by the viewer application) * and do not encrypt metadata. */ -$secHandler = SetaPDF_Core_SecHandler_Standard_Aes256::factory( +$secHandler = \SetaPDF_Core_SecHandler_Standard_Aes256::factory( $document, 'the-owner-password', 'the-user-password', - SetaPDF_Core_SecHandler::PERM_PRINT | SetaPDF_Core_SecHandler::PERM_COPY, + \SetaPDF_Core_SecHandler::PERM_PRINT | \SetaPDF_Core_SecHandler::PERM_COPY, false ); // attach the handler to the document instance $document->setSecHandler($secHandler); -$document->setWriter(new SetaPDF_Core_Writer_Http('encrypted.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('encrypted.pdf', true)); $document->save()->finish(); diff --git a/public/demos/4-Merger/various/3-merge-with-layers/script.php b/public/demos/4-Merger/various/3-merge-with-layers/script.php index 1a5c5ce..966b6db 100644 --- a/public/demos/4-Merger/various/3-merge-with-layers/script.php +++ b/public/demos/4-Merger/various/3-merge-with-layers/script.php @@ -19,12 +19,12 @@ // copy the same document a 2nd time but also copy layer information (default behavior) $merger->addDocument( - SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/layers/rect+circle+triangle.pdf') + \SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/layers/rect+circle+triangle.pdf') ); $merger->merge(); $document = $merger->getDocument(); -$document->setWriter(new SetaPDF_Core_Writer_Http('layers.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('layers.pdf', true)); $document->save()->finish(); diff --git a/public/demos/4-Merger/various/4-split/script.php b/public/demos/4-Merger/various/4-split/script.php index 387dced..8815c27 100644 --- a/public/demos/4-Merger/various/4-split/script.php +++ b/public/demos/4-Merger/various/4-split/script.php @@ -11,7 +11,7 @@ $zip->open($zipName, ZipArchive::CREATE); // load the "in"-document -$inDocument = SetaPDF_Core_Document::loadByFilename($pdfPath); +$inDocument = \SetaPDF_Core_Document::loadByFilename($pdfPath); // to prevent multiple object resolving set this to true $inDocument->setCacheReferencedObjects(true); // keep read objects for reusage for other pages @@ -32,7 +32,7 @@ $merger->merge(); // create a writer which we can pass to the ZipArchive instance - $writer = new SetaPDF_Core_Writer_String(); + $writer = new \SetaPDF_Core_Writer_String(); // get the resulting document instance $resDocument = $merger->getDocument(); @@ -60,7 +60,7 @@ header('Content-Length: ' . filesize($zipName)); header('Content-Disposition: attachment; ' . - SetaPDF_Core_Writer_Http::encodeFilenameForHttpHeader(basename($pdfPath, '.pdf') . '.zip') + \SetaPDF_Core_Writer_Http::encodeFilenameForHttpHeader(basename($pdfPath, '.pdf') . '.zip') ); readfile($zipName); diff --git a/public/demos/4-Merger/various/5-merge-pdfs-and-images/script.php b/public/demos/4-Merger/various/5-merge-pdfs-and-images/script.php index 06da741..d648f37 100644 --- a/public/demos/4-Merger/various/5-merge-pdfs-and-images/script.php +++ b/public/demos/4-Merger/various/5-merge-pdfs-and-images/script.php @@ -15,9 +15,9 @@ $image = getimagesize($path); if ($image !== false) { // now create an empty document instance - $imageDocument = new SetaPDF_Core_Document(); + $imageDocument = new \SetaPDF_Core_Document(); // load the image - $imgage = SetaPDF_Core_Image::getByPath($path); + $imgage = \SetaPDF_Core_Image::getByPath($path); // convert it into an XObject $xObject = $imgage->toXObject($imageDocument); @@ -29,7 +29,7 @@ $pages = $imageDocument->getCatalog()->getPages(); $page = $pages->create( [$width, $height], - SetaPDF_Core_PageFormats::ORIENTATION_AUTO + \SetaPDF_Core_PageFormats::ORIENTATION_AUTO ); // draw the image onto the page @@ -38,7 +38,7 @@ // JPEG images could be rotated by flags in their EXIF headers. To support these flags, // simply rotate the page accordingly: - if ($imgage instanceof SetaPDF_Core_Image_Jpeg && function_exists('exif_read_data')) { + if ($imgage instanceof \SetaPDF_Core_Image_Jpeg && function_exists('exif_read_data')) { $exifData = exif_read_data($path); if (isset($exifData['Orientation'])) { switch ($exifData['Orientation']) { @@ -70,5 +70,5 @@ $document = $merger->getDocument(); -$document->setWriter(new SetaPDF_Core_Writer_Http('PDFs-and-Images.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('PDFs-and-Images.pdf', true)); $document->save()->finish(); diff --git a/public/demos/4-Merger/various/6-merge-and-write-footnote/script.php b/public/demos/4-Merger/various/6-merge-and-write-footnote/script.php index 85bdb1e..8abb7db 100644 --- a/public/demos/4-Merger/various/6-merge-and-write-footnote/script.php +++ b/public/demos/4-Merger/various/6-merge-and-write-footnote/script.php @@ -32,7 +32,7 @@ $document = $merger->getDocument(); // we need a font instance -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); @@ -54,7 +54,7 @@ $canvas->normalizeRotationAndOrigin($page->getRotation(), $page->getBoundary()); // create a text block - $textBlock = new SetaPDF_Core_Text_Block($font, 5); + $textBlock = new \SetaPDF_Core_Text_Block($font, 5); $textBlock->setText(basename($path)); // and draw it onto the canvas $textBlock->draw($canvas, $page->getWidth() - $textBlock->getWidth() - 5, 5); @@ -64,6 +64,6 @@ } // set a writer instance -$document->setWriter(new SetaPDF_Core_Writer_Http('merged-with-footnotes.pdf', true)); +$document->setWriter(new \SetaPDF_Core_Writer_Http('merged-with-footnotes.pdf', true)); // and save the result to the writer $document->save()->finish(); diff --git a/public/demos/5-Signer/1-standard-signatures/1-create-and-add-a-signature-field/script.php b/public/demos/5-Signer/1-standard-signatures/1-create-and-add-a-signature-field/script.php index 2b57cb9..683eddc 100644 --- a/public/demos/5-Signer/1-standard-signatures/1-create-and-add-a-signature-field/script.php +++ b/public/demos/5-Signer/1-standard-signatures/1-create-and-add-a-signature-field/script.php @@ -3,13 +3,13 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('signature-fields.pdf'); -$document = new SetaPDF_Core_Document($writer); +$writer = new \SetaPDF_Core_Writer_Http('signature-fields.pdf'); +$document = new \SetaPDF_Core_Document($writer); // create an empty document with some pages $pages = $document->getCatalog()->getPages(); -$pages->create(SetaPDF_Core_PageFormats::A4); -$pages->create(SetaPDF_Core_PageFormats::A4, SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE); +$pages->create(\SetaPDF_Core_PageFormats::A4); +$pages->create(\SetaPDF_Core_PageFormats::A4, \SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE); // by default the signer component will add an invisible field. You can do this manually, this way: $fieldA = SetaPDF_Signer_SignatureField::add($document, 'MyInvisibleSignature'); diff --git a/public/demos/5-Signer/1-standard-signatures/2-create-a-simple-digital-signature/script.php b/public/demos/5-Signer/1-standard-signatures/2-create-a-simple-digital-signature/script.php index b783f35..713b8fc 100644 --- a/public/demos/5-Signer/1-standard-signatures/2-create-a-simple-digital-signature/script.php +++ b/public/demos/5-Signer/1-standard-signatures/2-create-a-simple-digital-signature/script.php @@ -3,8 +3,8 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('signed.pdf'); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('signed.pdf'); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $writer ); diff --git a/public/demos/5-Signer/1-standard-signatures/3-use-a-pfx-or-p12-file/script.php b/public/demos/5-Signer/1-standard-signatures/3-use-a-pfx-or-p12-file/script.php index d335c67..22c13ad 100644 --- a/public/demos/5-Signer/1-standard-signatures/3-use-a-pfx-or-p12-file/script.php +++ b/public/demos/5-Signer/1-standard-signatures/3-use-a-pfx-or-p12-file/script.php @@ -3,8 +3,8 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('signed.pdf'); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('signed.pdf'); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $writer ); diff --git a/public/demos/5-Signer/1-standard-signatures/4-create-certification-signature/script.php b/public/demos/5-Signer/1-standard-signatures/4-create-certification-signature/script.php index d342272..3b880a2 100644 --- a/public/demos/5-Signer/1-standard-signatures/4-create-certification-signature/script.php +++ b/public/demos/5-Signer/1-standard-signatures/4-create-certification-signature/script.php @@ -14,8 +14,8 @@ 'SetaPDF_Signer::CERTIFICATION_LEVEL_FORM_FILLING_AND_ANNOTATIONS' ], false); -$writer = new SetaPDF_Core_Writer_Http('certified.pdf'); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('certified.pdf'); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $writer ); diff --git a/public/demos/5-Signer/1-standard-signatures/5-create-a-timestamp-signature/script.php b/public/demos/5-Signer/1-standard-signatures/5-create-a-timestamp-signature/script.php index 22405b0..039fef3 100644 --- a/public/demos/5-Signer/1-standard-signatures/5-create-a-timestamp-signature/script.php +++ b/public/demos/5-Signer/1-standard-signatures/5-create-a-timestamp-signature/script.php @@ -3,8 +3,8 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('timestamped.pdf'); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('timestamped.pdf'); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $writer ); diff --git a/public/demos/5-Signer/1-standard-signatures/6-create-a-digital-signature-with-timestamp/script.php b/public/demos/5-Signer/1-standard-signatures/6-create-a-digital-signature-with-timestamp/script.php index 84fabc7..b07a3cc 100644 --- a/public/demos/5-Signer/1-standard-signatures/6-create-a-digital-signature-with-timestamp/script.php +++ b/public/demos/5-Signer/1-standard-signatures/6-create-a-digital-signature-with-timestamp/script.php @@ -3,8 +3,8 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('signed-and-timestamped.pdf'); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('signed-and-timestamped.pdf'); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $writer ); diff --git a/public/demos/5-Signer/1-standard-signatures/7-async-signature-and-timestamp/script.php b/public/demos/5-Signer/1-standard-signatures/7-async-signature-and-timestamp/script.php index 2ccc6ca..ad538af 100644 --- a/public/demos/5-Signer/1-standard-signatures/7-async-signature-and-timestamp/script.php +++ b/public/demos/5-Signer/1-standard-signatures/7-async-signature-and-timestamp/script.php @@ -29,14 +29,14 @@ 'signature' => null ]; - $document = SetaPDF_Core_Document::loadByFilename($workflow['fileToSign']); + $document = \SetaPDF_Core_Document::loadByFilename($workflow['fileToSign']); $signer = new SetaPDF_Signer($document); $signer->setSignatureContentLength(20000); // use an empty module instance to trigger implemented interface methods $module = new SetaPDF_Signer_Signature_Module_Pades(); - $tmpDocument = $signer->preSign(new SetaPDF_Core_Writer_File($workflow['tempPath']), $module); + $tmpDocument = $signer->preSign(new \SetaPDF_Core_Writer_File($workflow['tempPath']), $module); $workflow['tmpDocument'] = $tmpDocument; // if you don't want to save the TmpDocument instance in your workflow, you will need at least the ByteRange @@ -50,7 +50,7 @@ if ($state === 'prepared') { $workflow = $_SESSION['workflow']; - $document = SetaPDF_Core_Document::loadByFilename($workflow['fileToSign']); + $document = \SetaPDF_Core_Document::loadByFilename($workflow['fileToSign']); $signer = new SetaPDF_Signer($document); // now create a complete module instance @@ -61,7 +61,7 @@ $tmpDocument = $workflow['tmpDocument']; // If you want to create a TmpDocument instance manually, you need to do this in each step: -// $tmpDocument = new SetaPDF_Signer_TmpDocument(new SetaPDF_Core_Writer_File($workflow['tempPath'])); +// $tmpDocument = new SetaPDF_Signer_TmpDocument(new \SetaPDF_Core_Writer_File($workflow['tempPath'])); // $tmpDocument->setDocumentIdentification($document); // $tmpDocument->updateIdentificationHash(); // $tmpDocument->setByteRange($workflow['tmpDocumentByteRange']); @@ -92,7 +92,7 @@ if (isset($workflow['timestamped'])) { echo 'Signature already timestamped. Next step: '; } else { - $document = SetaPDF_Core_Document::loadByFilename($workflow['fileToSign']); + $document = \SetaPDF_Core_Document::loadByFilename($workflow['fileToSign']); $signer = new SetaPDF_Signer($document); $url = 'https://freetsa.org/tsr'; @@ -114,8 +114,8 @@ } elseif ($state === 'signatureCreated') { $workflow = $_SESSION['workflow']; - $writer = new SetaPDF_Core_Writer_Http('async-signature.pdf'); - $document = SetaPDF_Core_Document::loadByFilename($workflow['fileToSign'], $writer); + $writer = new \SetaPDF_Core_Writer_Http('async-signature.pdf'); + $document = \SetaPDF_Core_Document::loadByFilename($workflow['fileToSign'], $writer); $signer = new SetaPDF_Signer($document); $signer->saveSignature($workflow['tmpDocument'], $workflow['signature']); diff --git a/public/demos/5-Signer/1-standard-signatures/8-several-signatures/script.php b/public/demos/5-Signer/1-standard-signatures/8-several-signatures/script.php index 7b9c5ab..15988c3 100644 --- a/public/demos/5-Signer/1-standard-signatures/8-several-signatures/script.php +++ b/public/demos/5-Signer/1-standard-signatures/8-several-signatures/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // create a temporary writer -$tempWriter = new SetaPDF_Core_Writer_String(); +$tempWriter = new \SetaPDF_Core_Writer_String(); -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $tempWriter ); @@ -34,10 +34,10 @@ // create the final writer -$writer = new SetaPDF_Core_Writer_Http('several-signatures.pdf'); +$writer = new \SetaPDF_Core_Writer_Http('several-signatures.pdf'); // create a new document instance based on the temporary result -$document = SetaPDF_Core_Document::loadByString($tempWriter, $writer); +$document = \SetaPDF_Core_Document::loadByString($tempWriter, $writer); // create a signer instance $signer = new SetaPDF_Signer($document); diff --git a/public/demos/5-Signer/2-visible-signatures/1-dynamic-appearance/script.php b/public/demos/5-Signer/2-visible-signatures/1-dynamic-appearance/script.php index 66e3f04..204a9b9 100644 --- a/public/demos/5-Signer/2-visible-signatures/1-dynamic-appearance/script.php +++ b/public/demos/5-Signer/2-visible-signatures/1-dynamic-appearance/script.php @@ -3,8 +3,8 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('visible-signature.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('visible-signature.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $writer ); @@ -36,7 +36,7 @@ // now create the appearance module and pass the signature module along $appearance = new SetaPDF_Signer_Signature_Appearance_Dynamic($module); // let's create a font instance to not use standard fonts (not embedded) -$font = new SetaPDF_Core_Font_Type0_Subset( +$font = new \SetaPDF_Core_Font_Type0_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); diff --git a/public/demos/5-Signer/2-visible-signatures/10-several-appearances/script.php b/public/demos/5-Signer/2-visible-signatures/10-several-appearances/script.php index a6b5490..30b99c0 100644 --- a/public/demos/5-Signer/2-visible-signatures/10-several-appearances/script.php +++ b/public/demos/5-Signer/2-visible-signatures/10-several-appearances/script.php @@ -7,8 +7,8 @@ // load the wrapper class require_once __DIR__ . '/../../../../../classes/Signer/Appearance/OnAllPages.php'; -$writer = new SetaPDF_Core_Writer_Http('several-appearances.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('several-appearances.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/Brand-Guide.pdf', // $assetsDirectory . '/pdfs/misc/rotated/all.pdf', $writer @@ -45,7 +45,7 @@ // now create the appearance module and pass the signature module along $appearance = new SetaPDF_Signer_Signature_Appearance_Dynamic($module); // let's create a font instance to not use standard fonts (not embedded) -$font = new SetaPDF_Core_Font_Type0_Subset( +$font = new \SetaPDF_Core_Font_Type0_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); diff --git a/public/demos/5-Signer/2-visible-signatures/2-dynamic-appearance-with-background-and-graphic/script.php b/public/demos/5-Signer/2-visible-signatures/2-dynamic-appearance-with-background-and-graphic/script.php index 876b8dd..7262295 100644 --- a/public/demos/5-Signer/2-visible-signatures/2-dynamic-appearance-with-background-and-graphic/script.php +++ b/public/demos/5-Signer/2-visible-signatures/2-dynamic-appearance-with-background-and-graphic/script.php @@ -9,8 +9,8 @@ false ); -$writer = new SetaPDF_Core_Writer_Http('visible-signature.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('visible-signature.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $writer ); @@ -42,7 +42,7 @@ // now create the appearance module and pass the signature module along $appearance = new SetaPDF_Signer_Signature_Appearance_Dynamic($module); // let's create a font instance to not use standard fonts (not embedded) -$font = new SetaPDF_Core_Font_Type0_Subset( +$font = new \SetaPDF_Core_Font_Type0_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); @@ -51,36 +51,36 @@ if ($pdfOrPng === 'pdf') { // load a PDF for the background appearance - $bgDocument = SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/camtown/Logo.pdf'); + $bgDocument = \SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/camtown/Logo.pdf'); // convert the first page to a XObject $xObject = $bgDocument ->getCatalog() ->getPages() ->getPage(1) - ->toXObject($document, SetaPDF_Core_PageBoundaries::ART_BOX); + ->toXObject($document, \SetaPDF_Core_PageBoundaries::ART_BOX); // add it to the appearance $appearance->setBackgroundLogo($xObject, .3); // load a PDF for the graphic appearance - $graphicDocument = SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/misc/Handwritten-Signature.pdf'); + $graphicDocument = \SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/misc/Handwritten-Signature.pdf'); // convert the first page to a XObject $xObject = $graphicDocument ->getCatalog() ->getPages() ->getPage(1) - ->toXObject($document, SetaPDF_Core_PageBoundaries::ART_BOX); + ->toXObject($document, \SetaPDF_Core_PageBoundaries::ART_BOX); // add it to the appearance $appearance->setGraphic($xObject); } elseif ($pdfOrPng === 'png') { // load a PNG image for the background appearance - $bgImage = SetaPDF_Core_Image::getByPath($assetsDirectory . '/pdfs/camtown/Logo.png'); + $bgImage = \SetaPDF_Core_Image::getByPath($assetsDirectory . '/pdfs/camtown/Logo.png'); $xObject = $bgImage->toXObject($document); // add it to the appearance $appearance->setBackgroundLogo($xObject, .3); // load a PNG image for the graphic appearance - $graphicImage = SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/Handwritten-Signature.png'); + $graphicImage = \SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/Handwritten-Signature.png'); $xObject = $graphicImage->toXObject($document); // add it to the appearance $appearance->setGraphic($xObject); diff --git a/public/demos/5-Signer/2-visible-signatures/3-localized-dynamic-appearance/script.php b/public/demos/5-Signer/2-visible-signatures/3-localized-dynamic-appearance/script.php index 6028e1d..900cc74 100644 --- a/public/demos/5-Signer/2-visible-signatures/3-localized-dynamic-appearance/script.php +++ b/public/demos/5-Signer/2-visible-signatures/3-localized-dynamic-appearance/script.php @@ -3,8 +3,8 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('visible-signature.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('visible-signature.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $writer ); @@ -36,7 +36,7 @@ // now create the appearance module and pass the signature module along $appearance = new SetaPDF_Signer_Signature_Appearance_Dynamic($module); // let's create a font instance to not use standard fonts (not embedded) -$font = new SetaPDF_Core_Font_Type0_Subset( +$font = new \SetaPDF_Core_Font_Type0_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); @@ -56,7 +56,7 @@ $appearance->setShowTpl(SetaPDF_Signer_Signature_Appearance_Dynamic::CONFIG_DATE, 'Datum: %s'); // use a photo for the signature -$appDocument = SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/misc/Passport-Photo.pdf'); +$appDocument = \SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/misc/Passport-Photo.pdf'); $pageXObject = $appDocument->getCatalog()->getPages()->getPage(1)->toXObject($document); // set the photo xObject as graphic diff --git a/public/demos/5-Signer/2-visible-signatures/4-image-as-appearance/script.php b/public/demos/5-Signer/2-visible-signatures/4-image-as-appearance/script.php index 028ee58..41e111e 100644 --- a/public/demos/5-Signer/2-visible-signatures/4-image-as-appearance/script.php +++ b/public/demos/5-Signer/2-visible-signatures/4-image-as-appearance/script.php @@ -3,8 +3,8 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('visible-signature.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('visible-signature.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $writer ); @@ -34,10 +34,10 @@ $module->setPrivateKey('file://' . $certificatePath, ''); // load an image and ... -$graphicImage = SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/Handwritten-Signature.png'); +$graphicImage = \SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/Handwritten-Signature.png'); // or e.g. through base64 encoded image data: //$data = base64_decode('iVBORw0KGgoAAAANSUhEUgAABJYAAAEmCAYAAAAwZRqhAAAgAElEQVR4Xu.../w+l98Lb9eaTFwAAAABJRU5ErkJggg=='); -//$graphicImage = SetaPDF_Core_Image::get(new SetaPDF_Core_Reader_String($data)); +//$graphicImage = \SetaPDF_Core_Image::get(new \SetaPDF_Core_Reader_String($data)); // convert it to an XObject $xObject = $graphicImage->toXObject($document); diff --git a/public/demos/5-Signer/2-visible-signatures/5-pdf-page-as-appearance/script.php b/public/demos/5-Signer/2-visible-signatures/5-pdf-page-as-appearance/script.php index 335b26f..803c30f 100644 --- a/public/demos/5-Signer/2-visible-signatures/5-pdf-page-as-appearance/script.php +++ b/public/demos/5-Signer/2-visible-signatures/5-pdf-page-as-appearance/script.php @@ -3,8 +3,8 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('visible-signature.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('visible-signature.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $writer ); @@ -34,13 +34,13 @@ $module->setPrivateKey('file://' . $certificatePath, ''); // load the PDF document and ... -$graphicDocument = SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/misc/Handwritten-Signature.pdf'); +$graphicDocument = \SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/misc/Handwritten-Signature.pdf'); // convert the first page to a XObject $xObject = $graphicDocument ->getCatalog() ->getPages() ->getPage(1) - ->toXObject($document, SetaPDF_Core_PageBoundaries::ART_BOX); + ->toXObject($document, \SetaPDF_Core_PageBoundaries::ART_BOX); // which can be used to initiate a XObject appearance instance $appearance = new SetaPDF_Signer_Signature_Appearance_XObject($xObject); diff --git a/public/demos/5-Signer/2-visible-signatures/6-individual-signature-appearance/script.php b/public/demos/5-Signer/2-visible-signatures/6-individual-signature-appearance/script.php index 937b569..722885f 100644 --- a/public/demos/5-Signer/2-visible-signatures/6-individual-signature-appearance/script.php +++ b/public/demos/5-Signer/2-visible-signatures/6-individual-signature-appearance/script.php @@ -3,8 +3,8 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('visible-signature.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('visible-signature.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $writer ); @@ -26,13 +26,13 @@ $module->setPrivateKey('file://' . $certificatePath, ''); // create a font instance -$font = new SetaPDF_Core_Font_Type0_Subset( +$font = new \SetaPDF_Core_Font_Type0_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); // let's create a simple text block -$textBlock = new SetaPDF_Core_Text_Block($font, 10); +$textBlock = new \SetaPDF_Core_Text_Block($font, 10); $textBlock->setWidth(200); $textBlock->setLineHeight(11); $textBlock->setPadding(2); @@ -60,7 +60,7 @@ $height = $textBlock->getHeight() * 2; // create a form XObject and ... -$xObject = SetaPDF_Core_XObject_Form::create($document, [0, 0, $width, $height]); +$xObject = \SetaPDF_Core_XObject_Form::create($document, [0, 0, $width, $height]); $canvas = $xObject->getCanvas(); // draw a border ... @@ -74,7 +74,7 @@ $textBlock->draw($canvas, 0, 0); // draw an image above the text -$image = SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/Handwritten-Signature.png'); +$image = \SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/Handwritten-Signature.png'); $imageXObject = $image->toXObject($document); $imageHeight = $height / 2; diff --git a/public/demos/5-Signer/2-visible-signatures/6.2-individual-signature-appearance/script.php b/public/demos/5-Signer/2-visible-signatures/6.2-individual-signature-appearance/script.php index af48189..0951811 100644 --- a/public/demos/5-Signer/2-visible-signatures/6.2-individual-signature-appearance/script.php +++ b/public/demos/5-Signer/2-visible-signatures/6.2-individual-signature-appearance/script.php @@ -3,8 +3,8 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('visible-signature.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('visible-signature.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $writer ); @@ -41,17 +41,17 @@ $height = $field->getHeight(); // create a form XObject and ... -$xObject = SetaPDF_Core_XObject_Form::create($document, [0, 0, $width, $height]); +$xObject = \SetaPDF_Core_XObject_Form::create($document, [0, 0, $width, $height]); $canvas = $xObject->getCanvas(); // add a seal on the left side -$sealImage = SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/seal.png'); +$sealImage = \SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/seal.png'); $sealImageXObject = $sealImage->toXObject($document); $sealImageXObject->draw($canvas, 0, 0, null, $height); $sealWidth = $sealImageXObject->getWidth($height); // add a QR-Code image to the right -$qrImage = SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/qr.png'); +$qrImage = \SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/qr.png'); $qrImageXObject = $qrImage->toXObject($document); $qrWidth = $qrImageXObject->getWidth($height); $qrImageXObject->draw($canvas, $width - $qrWidth, 0, null, $height); @@ -59,16 +59,16 @@ // now create a text between both images // create a font instance -$font = new SetaPDF_Core_Font_Type0_Subset( +$font = new \SetaPDF_Core_Font_Type0_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); // let's create a simple text block -$textBlock = new SetaPDF_Core_Text_Block($font, 10); +$textBlock = new \SetaPDF_Core_Text_Block($font, 10); $textBlock->setTextWidth($width - $sealWidth - $qrWidth); $textBlock->setLineHeight(11); $textBlock->setPadding(2); -$textBlock->setAlign(SetaPDF_Core_Text::ALIGN_CENTER); +$textBlock->setAlign(\SetaPDF_Core_Text::ALIGN_CENTER); $certificateInfo = openssl_x509_parse('file://' . $certificatePath); $text = "Signee: " . (isset($certificateInfo['subject']['CN']) ? $certificateInfo['subject']['CN'] : $signer->getName()) diff --git a/public/demos/5-Signer/2-visible-signatures/7-several-visible-signatures/script.php b/public/demos/5-Signer/2-visible-signatures/7-several-visible-signatures/script.php index f58ea3d..d19ea3c 100644 --- a/public/demos/5-Signer/2-visible-signatures/7-several-visible-signatures/script.php +++ b/public/demos/5-Signer/2-visible-signatures/7-several-visible-signatures/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // create a temporary writer -$tempWriter = new SetaPDF_Core_Writer_String(); +$tempWriter = new \SetaPDF_Core_Writer_String(); -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $tempWriter ); @@ -46,10 +46,10 @@ // create the final writer -$writer = new SetaPDF_Core_Writer_Http('several-signatures.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('several-signatures.pdf', true); // create a new document instance based on the temporary result -$document = SetaPDF_Core_Document::loadByString($tempWriter, $writer); +$document = \SetaPDF_Core_Document::loadByString($tempWriter, $writer); // create a signer instance $signer = new SetaPDF_Signer($document); diff --git a/public/demos/5-Signer/2-visible-signatures/8-async-visible-signature-and-timestamp/script.php b/public/demos/5-Signer/2-visible-signatures/8-async-visible-signature-and-timestamp/script.php index 8782650..9300317 100644 --- a/public/demos/5-Signer/2-visible-signatures/8-async-visible-signature-and-timestamp/script.php +++ b/public/demos/5-Signer/2-visible-signatures/8-async-visible-signature-and-timestamp/script.php @@ -29,7 +29,7 @@ 'signature' => null ]; - $document = SetaPDF_Core_Document::loadByFilename($workflow['fileToSign']); + $document = \SetaPDF_Core_Document::loadByFilename($workflow['fileToSign']); $signer = new SetaPDF_Signer($document); $signer->setSignatureContentLength(20000); @@ -58,7 +58,7 @@ // pass it to the signer instance $signer->setAppearance($appearance); - $workflow['tmpDocument'] = $signer->preSign(new SetaPDF_Core_Writer_File($workflow['tempPath']), $module); + $workflow['tmpDocument'] = $signer->preSign(new \SetaPDF_Core_Writer_File($workflow['tempPath']), $module); $workflow['state'] = 'prepared'; @@ -67,7 +67,7 @@ if ($state === 'prepared') { $workflow = $_SESSION['workflow']; - $document = SetaPDF_Core_Document::loadByFilename($workflow['fileToSign']); + $document = \SetaPDF_Core_Document::loadByFilename($workflow['fileToSign']); $signer = new SetaPDF_Signer($document); // now create a complete module instance @@ -93,7 +93,7 @@ if (isset($workflow['timestamped'])) { echo 'Signature already timestamped. Next step: '; } else { - $document = SetaPDF_Core_Document::loadByFilename($workflow['fileToSign']); + $document = \SetaPDF_Core_Document::loadByFilename($workflow['fileToSign']); $signer = new SetaPDF_Signer($document); $url = 'https://freetsa.org/tsr'; @@ -115,8 +115,8 @@ } elseif ($state === 'signatureCreated') { $workflow = $_SESSION['workflow']; - $writer = new SetaPDF_Core_Writer_Http('async-signature.pdf'); - $document = SetaPDF_Core_Document::loadByFilename($workflow['fileToSign'], $writer); + $writer = new \SetaPDF_Core_Writer_Http('async-signature.pdf'); + $document = \SetaPDF_Core_Document::loadByFilename($workflow['fileToSign'], $writer); $signer = new SetaPDF_Signer($document); $signer->saveSignature($workflow['tmpDocument'], $workflow['signature']); diff --git a/public/demos/5-Signer/2-visible-signatures/9-use-an-existing-signature-field/script.php b/public/demos/5-Signer/2-visible-signatures/9-use-an-existing-signature-field/script.php index e590c67..a6eeb87 100644 --- a/public/demos/5-Signer/2-visible-signatures/9-use-an-existing-signature-field/script.php +++ b/public/demos/5-Signer/2-visible-signatures/9-use-an-existing-signature-field/script.php @@ -3,8 +3,8 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('visible-signature.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('visible-signature.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Order-Form.pdf', $writer ); @@ -32,10 +32,10 @@ $module->setPrivateKey('file://' . $certificatePath, ''); // use the handwritten signature through a PNG image -$image = SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/Handwritten-Signature.png'); +$image = \SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/Handwritten-Signature.png'); // or e.g. through base64 encoded image data: //$data = base64_decode('iVBORw0KGgoAAAANSUhEUgAABJYAAAEmCAYAAAAwZRqhAAAgAElEQVR4Xu.../w+l98Lb9eaTFwAAAABJRU5ErkJggg=='); -//$image = SetaPDF_Core_Image::get(new SetaPDF_Core_Reader_String($data)); +//$image = \SetaPDF_Core_Image::get(new \SetaPDF_Core_Reader_String($data)); $xObject = $image->toXObject($document); diff --git a/public/demos/5-Signer/3-ltv/4-add-vri-to-an-existing-pdf-document/script.php b/public/demos/5-Signer/3-ltv/4-add-vri-to-an-existing-pdf-document/script.php index cfc843a..22c218b 100644 --- a/public/demos/5-Signer/3-ltv/4-add-vri-to-an-existing-pdf-document/script.php +++ b/public/demos/5-Signer/3-ltv/4-add-vri-to-an-existing-pdf-document/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // create a HTTP writer -$writer = new SetaPDF_Core_Writer_Http('Laboratory-Report-signed-LTV.pdf'); +$writer = new \SetaPDF_Core_Writer_Http('Laboratory-Report-signed-LTV.pdf'); // let's get the document -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/tektown/Laboratory-Report-signed-no-LTV.pdf', $writer ); diff --git a/public/demos/5-Signer/4-various/1-get-existing-signature-fields/script.php b/public/demos/5-Signer/4-various/1-get-existing-signature-fields/script.php index f93160f..23dda0c 100644 --- a/public/demos/5-Signer/4-various/1-get-existing-signature-fields/script.php +++ b/public/demos/5-Signer/4-various/1-get-existing-signature-fields/script.php @@ -12,7 +12,7 @@ $path = displayFiles($files); -$document = SetaPDF_Core_Document::loadByFilename($path); +$document = \SetaPDF_Core_Document::loadByFilename($path); $signatureFieldNames = SetaPDF_Signer_ValidationRelatedInfo_Collector::getSignatureFieldNames($document); foreach ($signatureFieldNames as $signatureFieldName) { diff --git a/public/demos/5-Signer/4-various/2-sign-encrypted-pdf-document/script.php b/public/demos/5-Signer/4-various/2-sign-encrypted-pdf-document/script.php index 5afa4cb..8a86967 100644 --- a/public/demos/5-Signer/4-various/2-sign-encrypted-pdf-document/script.php +++ b/public/demos/5-Signer/4-various/2-sign-encrypted-pdf-document/script.php @@ -3,14 +3,14 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('topsecret.pdf'); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('topsecret.pdf'); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/tektown/Laboratory-Report-up=topsecret,op=owner.pdf', $writer ); // let's create an authentication callback -$authCallback = static function(SetaPDF_Core_SecHandler_SecHandlerInterface $secHandler) { +$authCallback = static function(\SetaPDF_Core_SecHandler_SecHandlerInterface $secHandler) { $secHandler->auth('owner'); }; diff --git a/public/demos/5-Signer/4-various/3-sign-and-encrypt/script.php b/public/demos/5-Signer/4-various/3-sign-and-encrypt/script.php index d9f3c18..513f767 100644 --- a/public/demos/5-Signer/4-various/3-sign-and-encrypt/script.php +++ b/public/demos/5-Signer/4-various/3-sign-and-encrypt/script.php @@ -3,8 +3,8 @@ // load and register the autoload function require_once __DIR__ . '/../../../../../bootstrap.php'; -$writer = new SetaPDF_Core_Writer_Http('encrypted-and-signed.pdf'); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('encrypted-and-signed.pdf'); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/lenstown/Laboratory-Report.pdf', $writer ); @@ -13,23 +13,23 @@ $userPassword = 'ANotherVerySecretUserPassword'; // all permissions but printing -$permissions = SetaPDF_Core_SecHandler::PERM_ACCESSIBILITY - | SetaPDF_Core_SecHandler::PERM_ANNOT - | SetaPDF_Core_SecHandler::PERM_ASSEMBLE - | SetaPDF_Core_SecHandler::PERM_COPY - | SetaPDF_Core_SecHandler::PERM_MODIFY - | SetaPDF_Core_SecHandler::PERM_FILL_FORM +$permissions = \SetaPDF_Core_SecHandler::PERM_ACCESSIBILITY + | \SetaPDF_Core_SecHandler::PERM_ANNOT + | \SetaPDF_Core_SecHandler::PERM_ASSEMBLE + | \SetaPDF_Core_SecHandler::PERM_COPY + | \SetaPDF_Core_SecHandler::PERM_MODIFY + | \SetaPDF_Core_SecHandler::PERM_FILL_FORM ; // create a security handler -$secHandler = SetaPDF_Core_SecHandler_Standard_Aes256::factory( +$secHandler = \SetaPDF_Core_SecHandler_Standard_Aes256::factory( $document, $ownerPassword, $userPassword, $permissions ); // and pass it to the document instance $document->setSecHandler($secHandler); // let's create an authentication callback -$authCallback = static function(SetaPDF_Core_SecHandler_SecHandlerInterface $secHandler) use ($ownerPassword) { +$authCallback = static function(\SetaPDF_Core_SecHandler_SecHandlerInterface $secHandler) use ($ownerPassword) { $secHandler->auth($ownerPassword); }; diff --git a/public/demos/5-Signer/4-various/4-validation-poc/script.php b/public/demos/5-Signer/4-various/4-validation-poc/script.php index 8460bbd..c08280a 100644 --- a/public/demos/5-Signer/4-various/4-validation-poc/script.php +++ b/public/demos/5-Signer/4-various/4-validation-poc/script.php @@ -98,7 +98,7 @@ function verifyAndDumpCertificate( echo '

Checking signatures in ' . htmlspecialchars($filename) . '

'; try { - $document = SetaPDF_Core_Document::loadByFilename($file); + $document = \SetaPDF_Core_Document::loadByFilename($file); $signatureFieldNames = SetaPDF_Signer_ValidationRelatedInfo_Collector::getSignatureFieldNames($document); foreach ($signatureFieldNames AS $fieldName) { @@ -120,7 +120,7 @@ function verifyAndDumpCertificate( $signatureData = (string)$signedData->getAsn1(); - echo '
asn1js | '; echo 'download
'; @@ -173,7 +173,7 @@ function verifyAndDumpCertificate( echo '
'; echo 'Signature properties:
'; - /** @var SetaPDF_Core_Type_Dictionary $dictionary */ + /** @var \SetaPDF_Core_Type_Dictionary $dictionary */ $dictionary = $integrityResult->getField()->getValue(); // get PDF signature properties foreach ([ @@ -190,10 +190,10 @@ function verifyAndDumpCertificate( echo $property . ': '; $value = $dictionary->getValue($property)->ensure()->getValue(); if ($property == SetaPDF_Signer::PROP_TIME_OF_SIGNING) { - $value = SetaPDF_Core_DataStructure_Date::stringToDateTime($value); + $value = \SetaPDF_Core_DataStructure_Date::stringToDateTime($value); $value = $value->format('Y-m-d H:i:s'); } else { - $value = SetaPDF_Core_Encoding::convertPdfString($value); + $value = \SetaPDF_Core_Encoding::convertPdfString($value); } echo $value . '
'; } diff --git a/public/demos/5-Signer/4-various/5-add-metadata-stream/script.php b/public/demos/5-Signer/4-various/5-add-metadata-stream/script.php index 26d6faa..76f19a1 100644 --- a/public/demos/5-Signer/4-various/5-add-metadata-stream/script.php +++ b/public/demos/5-Signer/4-various/5-add-metadata-stream/script.php @@ -7,31 +7,31 @@ class MySignatureModule extends SetaPDF_Signer_Signature_Module_Pades { /** - * @var SetaPDF_Core_Type_IndirectObjectInterface + * @var \SetaPDF_Core_Type_IndirectObjectInterface */ protected $metadata; /** - * @param SetaPDF_Core_Type_IndirectObjectInterface $metadata The indirect object/reference to the metadata stream. + * @param \SetaPDF_Core_Type_IndirectObjectInterface $metadata The indirect object/reference to the metadata stream. */ - public function setMetadata(SetaPDF_Core_Type_IndirectObjectInterface $metadata) + public function setMetadata(\SetaPDF_Core_Type_IndirectObjectInterface $metadata) { $this->metadata = $metadata; } /** - * @param SetaPDF_Core_Type_Dictionary $dictionary + * @param \SetaPDF_Core_Type_Dictionary $dictionary * @throws SetaPDF_Signer_Exception */ - public function updateSignatureDictionary(SetaPDF_Core_Type_Dictionary $dictionary) + public function updateSignatureDictionary(\SetaPDF_Core_Type_Dictionary $dictionary) { parent::updateSignatureDictionary($dictionary); $dictionary->offsetSet('Metadata', $this->metadata); } } -$writer = new SetaPDF_Core_Writer_Http('signed.pdf'); -$document = SetaPDF_Core_Document::loadByFilename( +$writer = new \SetaPDF_Core_Writer_Http('signed.pdf'); +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/camtown/Laboratory-Report.pdf', $writer ); @@ -49,10 +49,10 @@ public function updateSignatureDictionary(SetaPDF_Core_Type_Dictionary $dictiona $module = new MySignatureModule(); // create a metadata object -$metadataObject = $document->createNewObject(new SetaPDF_Core_Type_Stream( - new SetaPDF_Core_Type_Dictionary([ - 'Type' => new SetaPDF_Core_Type_Name('Metadata', true), - 'Subtype' => new SetaPDF_Core_Type_Name('XML', true) +$metadataObject = $document->createNewObject(new \SetaPDF_Core_Type_Stream( + new \SetaPDF_Core_Type_Dictionary([ + 'Type' => new \SetaPDF_Core_Type_Name('Metadata', true), + 'Subtype' => new \SetaPDF_Core_Type_Name('XML', true) ]), '' . "\n" . '' . "\n" . diff --git a/public/demos/5-Signer/4-various/6-get-signed-version/script.php b/public/demos/5-Signer/4-various/6-get-signed-version/script.php index fedca6b..271fdc5 100644 --- a/public/demos/5-Signer/4-various/6-get-signed-version/script.php +++ b/public/demos/5-Signer/4-various/6-get-signed-version/script.php @@ -6,8 +6,8 @@ $file = $assetsDirectory . '/pdfs/tektown/Laboratory-Report-signed.pdf'; $fh = fopen($file, 'rb'); -$reader = new SetaPDF_Core_Reader_Stream($fh); -$document = SetaPDF_Core_Document::load($reader); +$reader = new \SetaPDF_Core_Reader_Stream($fh); +$document = \SetaPDF_Core_Document::load($reader); $fieldNames = SetaPDF_Signer_ValidationRelatedInfo_Collector::getSignatureFieldNames($document); // let's filter only used signature fields @@ -31,7 +31,7 @@ stream_copy_to_stream($fh, $out, $length); fseek($out, 0); -$writer = new SetaPDF_Core_Writer_Http('result.pdf'); +$writer = new \SetaPDF_Core_Writer_Http('result.pdf'); $writer->copy($out); $writer->finish(); diff --git a/public/demos/5-Signer/4-various/7-check-for-certification-signature/script.php b/public/demos/5-Signer/4-various/7-check-for-certification-signature/script.php index 429ea5b..28a8af9 100644 --- a/public/demos/5-Signer/4-various/7-check-for-certification-signature/script.php +++ b/public/demos/5-Signer/4-various/7-check-for-certification-signature/script.php @@ -19,7 +19,7 @@ } try { - $document = SetaPDF_Core_Document::loadByFilename($file); + $document = \SetaPDF_Core_Document::loadByFilename($file); $certficationLevel = SetaPDF_Signer::getCertificationLevelByDocument($document); if ($certficationLevel === null) { echo "Document is not certified."; diff --git a/public/demos/5-Signer/5-external-implementations/2-fortify/1-web-component/controller.php b/public/demos/5-Signer/5-external-implementations/2-fortify/1-web-component/controller.php index fd6c991..de62bbc 100644 --- a/public/demos/5-Signer/5-external-implementations/2-fortify/1-web-component/controller.php +++ b/public/demos/5-Signer/5-external-implementations/2-fortify/1-web-component/controller.php @@ -46,7 +46,7 @@ } // load the PDF document - $document = SetaPDF_Core_Document::loadByFilename($fileToSign); + $document = \SetaPDF_Core_Document::loadByFilename($fileToSign); // create a signer instance $signer = new SetaPDF_Signer($document); // create a module instance @@ -114,11 +114,11 @@ // $signer->setAppearance($appearance); // you may use an own temporary file handler - $tempPath = SetaPDF_Core_Writer_TempFile::createTempPath(); + $tempPath = \SetaPDF_Core_Writer_TempFile::createTempPath(); // prepare the PDF $_SESSION['tmpDocument'] = $signer->preSign( - new SetaPDF_Core_Writer_File($tempPath), + new \SetaPDF_Core_Writer_File($tempPath), $module ); @@ -126,7 +126,7 @@ // prepare the response $response = [ - 'dataToSign' => SetaPDF_Core_Type_HexString::str2hex( + 'dataToSign' => \SetaPDF_Core_Type_HexString::str2hex( $module->getDataToSign($_SESSION['tmpDocument']->getHashFile()) ), 'extraCerts' => array_map(function (SetaPDF_Signer_X509_Certificate $cert) { @@ -148,11 +148,11 @@ die(); } - $data->signature = SetaPDF_Core_Type_HexString::hex2str($data->signature); + $data->signature = \SetaPDF_Core_Type_HexString::hex2str($data->signature); // create the document instance - $writer = new SetaPDF_Core_Writer_String(); - $document = SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); + $writer = new \SetaPDF_Core_Writer_String(); + $document = \SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); $signer = new SetaPDF_Signer($document); // pass the signature to the signature modul diff --git a/public/demos/5-Signer/5-external-implementations/2-fortify/2-vanilla-javascript/controller.php b/public/demos/5-Signer/5-external-implementations/2-fortify/2-vanilla-javascript/controller.php index 456ad9e..1d9d903 100644 --- a/public/demos/5-Signer/5-external-implementations/2-fortify/2-vanilla-javascript/controller.php +++ b/public/demos/5-Signer/5-external-implementations/2-fortify/2-vanilla-javascript/controller.php @@ -28,7 +28,7 @@ } // load the PDF document - $document = SetaPDF_Core_Document::loadByFilename($fileToSign); + $document = \SetaPDF_Core_Document::loadByFilename($fileToSign); // create a signer instance $signer = new SetaPDF_Signer($document); // create a module instance @@ -88,11 +88,11 @@ } // you may use an own temporary file handler - $tempPath = SetaPDF_Core_Writer_TempFile::createTempPath(); + $tempPath = \SetaPDF_Core_Writer_TempFile::createTempPath(); // prepare the PDF $_SESSION['tmpDocument'] = $signer->preSign( - new SetaPDF_Core_Writer_File($tempPath), + new \SetaPDF_Core_Writer_File($tempPath), $module ); @@ -100,7 +100,7 @@ // prepare the response $response = [ - 'dataToSign' => SetaPDF_Core_Type_HexString::str2hex( + 'dataToSign' => \SetaPDF_Core_Type_HexString::str2hex( $module->getDataToSign($_SESSION['tmpDocument']->getHashFile()) ) ]; @@ -118,11 +118,11 @@ die(); } - $data->signature = SetaPDF_Core_Type_HexString::hex2str($data->signature); + $data->signature = \SetaPDF_Core_Type_HexString::hex2str($data->signature); // create the document instance - $writer = new SetaPDF_Core_Writer_String(); - $document = SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); + $writer = new \SetaPDF_Core_Writer_String(); + $document = \SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); $signer = new SetaPDF_Signer($document); // pass the signature to the signature modul diff --git a/public/demos/5-Signer/5-external-implementations/3-openssl-cli/1-dgst/script.php b/public/demos/5-Signer/5-external-implementations/3-openssl-cli/1-dgst/script.php index 25024f6..f3a31e5 100644 --- a/public/demos/5-Signer/5-external-implementations/3-openssl-cli/1-dgst/script.php +++ b/public/demos/5-Signer/5-external-implementations/3-openssl-cli/1-dgst/script.php @@ -13,12 +13,12 @@ // the file to sign $fileToSign = $assetsDirectory . '/pdfs/tektown/Laboratory-Report.pdf'; // create a temporary path -$tempFile = SetaPDF_Core_Writer_TempFile::createTempPath(); +$tempFile = \SetaPDF_Core_Writer_TempFile::createTempPath(); // create a writer instance -$writer = new SetaPDF_Core_Writer_Http('signed-with-dgst.pdf'); +$writer = new \SetaPDF_Core_Writer_Http('signed-with-dgst.pdf'); // create the document instance -$document = SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); +$document = \SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); // create the signer instance $signer = new SetaPDF_Signer($document); @@ -29,7 +29,7 @@ $module->setCertificate('file://' . $assetsDirectory . '/certificates/setapdf-no-pw.pem'); // create a temporary version which represents the data which should get signed -$tmpDocument = $signer->preSign(new SetaPDF_Core_Writer_File($tempFile), $module); +$tmpDocument = $signer->preSign(new \SetaPDF_Core_Writer_File($tempFile), $module); // get the hash data from the module $hashData = $module->getDataToSign($tmpDocument->getHashFile()); @@ -39,9 +39,9 @@ $privateKeyPass = ''; // create a temporary file with the data to sign -$tmpFileIn = SetaPDF_Core_Writer_TempFile::createTempFile($hashData); +$tmpFileIn = \SetaPDF_Core_Writer_TempFile::createTempFile($hashData); // prepare a temporary file for the final signature -$tmpFileOut = SetaPDF_Core_Writer_TempFile::createTempPath(); +$tmpFileOut = \SetaPDF_Core_Writer_TempFile::createTempPath(); // build the command $cmd = $opensslPath . 'openssl dgst ' diff --git a/public/demos/5-Signer/5-external-implementations/3-openssl-cli/2-dgst-pss/script.php b/public/demos/5-Signer/5-external-implementations/3-openssl-cli/2-dgst-pss/script.php index 2019fb0..3a3a13d 100644 --- a/public/demos/5-Signer/5-external-implementations/3-openssl-cli/2-dgst-pss/script.php +++ b/public/demos/5-Signer/5-external-implementations/3-openssl-cli/2-dgst-pss/script.php @@ -13,12 +13,12 @@ // the file to sign $fileToSign = $assetsDirectory . '/pdfs/tektown/Laboratory-Report.pdf'; // create a temporary path -$tempFile = SetaPDF_Core_Writer_TempFile::createTempPath(); +$tempFile = \SetaPDF_Core_Writer_TempFile::createTempPath(); // create a writer instance -$writer = new SetaPDF_Core_Writer_Http('signed-with-dgst.pdf'); +$writer = new \SetaPDF_Core_Writer_Http('signed-with-dgst.pdf'); // create the document instance -$document = SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); +$document = \SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); // create the signer instance $signer = new SetaPDF_Signer($document); @@ -29,7 +29,7 @@ $module->setCertificate('file://' . $assetsDirectory . '/certificates/setapdf-no-pw.pem'); // create a temporary version which represents the data which should get signed -$tmpDocument = $signer->preSign(new SetaPDF_Core_Writer_File($tempFile), $module); +$tmpDocument = $signer->preSign(new \SetaPDF_Core_Writer_File($tempFile), $module); // for PSS we need to update the SignatureAlgorithmIdentifier as defined here: // https://tools.ietf.org/html/rfc4055#section-3.1 @@ -108,9 +108,9 @@ $privateKeyPass = ''; // create a temporary file with the data to sign -$tmpFileIn = SetaPDF_Core_Writer_TempFile::createTempFile($hashData); +$tmpFileIn = \SetaPDF_Core_Writer_TempFile::createTempFile($hashData); // prepare a temporary file for the final signature -$tmpFileOut = SetaPDF_Core_Writer_TempFile::createTempPath(); +$tmpFileOut = \SetaPDF_Core_Writer_TempFile::createTempPath(); // build the command $cmd = $opensslPath . 'openssl dgst ' diff --git a/public/demos/5-Signer/5-external-implementations/3-openssl-cli/3-pkeyutl/script.php b/public/demos/5-Signer/5-external-implementations/3-openssl-cli/3-pkeyutl/script.php index 2c7472d..6e7c03c 100644 --- a/public/demos/5-Signer/5-external-implementations/3-openssl-cli/3-pkeyutl/script.php +++ b/public/demos/5-Signer/5-external-implementations/3-openssl-cli/3-pkeyutl/script.php @@ -13,12 +13,12 @@ // the file to sign $fileToSign = $assetsDirectory . '/pdfs/tektown/Laboratory-Report.pdf'; // create a temporary path -$tempFile = SetaPDF_Core_Writer_TempFile::createTempPath(); +$tempFile = \SetaPDF_Core_Writer_TempFile::createTempPath(); // create a writer instance -$writer = new SetaPDF_Core_Writer_Http('signed-with-pkeyutl.pdf'); +$writer = new \SetaPDF_Core_Writer_Http('signed-with-pkeyutl.pdf'); // create the document instance -$document = SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); +$document = \SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); // create the signer instance $signer = new SetaPDF_Signer($document); @@ -28,7 +28,7 @@ $module->setCertificate('file://' . $assetsDirectory . '/certificates/setapdf-no-pw.pem'); // create a temporary version which represents the data which should get signed -$tmpDocument = $signer->preSign(new SetaPDF_Core_Writer_File($tempFile), $module); +$tmpDocument = $signer->preSign(new \SetaPDF_Core_Writer_File($tempFile), $module); // get the hash data from the module $hashData = $module->getDataToSign($tmpDocument->getHashFile()); @@ -41,9 +41,9 @@ $hash = hash($module->getDigest(), $hashData, true); // and write it to a temporary file -$tmpFileIn = SetaPDF_Core_Writer_TempFile::createTempFile($hash); +$tmpFileIn = \SetaPDF_Core_Writer_TempFile::createTempFile($hash); // prepare a temporary file for the final signature -$tmpFileOut = SetaPDF_Core_Writer_TempFile::createTempPath(); +$tmpFileOut = \SetaPDF_Core_Writer_TempFile::createTempPath(); // build the command $cmd = $opensslPath . "openssl pkeyutl -sign " diff --git a/public/demos/5-Signer/5-external-implementations/3-openssl-cli/4-pkeyutl-capi-engine/script.php b/public/demos/5-Signer/5-external-implementations/3-openssl-cli/4-pkeyutl-capi-engine/script.php index 8f8fdcd..e6a9fd4 100644 --- a/public/demos/5-Signer/5-external-implementations/3-openssl-cli/4-pkeyutl-capi-engine/script.php +++ b/public/demos/5-Signer/5-external-implementations/3-openssl-cli/4-pkeyutl-capi-engine/script.php @@ -13,12 +13,12 @@ // the file to sign $fileToSign = $assetsDirectory . '/pdfs/tektown/Laboratory-Report.pdf'; // create a temporary path -$tempFile = SetaPDF_Core_Writer_TempFile::createTempPath(); +$tempFile = \SetaPDF_Core_Writer_TempFile::createTempPath(); // create a writer instance -$writer = new SetaPDF_Core_Writer_Http('signed-with-pkeyutl-and-capi-engine.pdf'); +$writer = new \SetaPDF_Core_Writer_Http('signed-with-pkeyutl-and-capi-engine.pdf'); // create the document instance -$document = SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); +$document = \SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); // create the signer instance $signer = new SetaPDF_Signer($document); @@ -28,7 +28,7 @@ $module->setCertificate('file://' . $assetsDirectory . '/certificates/setapdf-no-pw.pem'); // create a temporary version which represents the data which should get signed -$tmpDocument = $signer->preSign(new SetaPDF_Core_Writer_File($tempFile), $module); +$tmpDocument = $signer->preSign(new \SetaPDF_Core_Writer_File($tempFile), $module); // get the hash data from the module $hashData = $module->getDataToSign($tmpDocument->getHashFile()); @@ -42,9 +42,9 @@ $hash = hash($module->getDigest(), $hashData, true); // and write it to a temporary file -$tmpFileIn = SetaPDF_Core_Writer_TempFile::createTempFile($hash); +$tmpFileIn = \SetaPDF_Core_Writer_TempFile::createTempFile($hash); // prepare a temporary file for the final signature -$tmpFileOut = SetaPDF_Core_Writer_TempFile::createTempPath(); +$tmpFileOut = \SetaPDF_Core_Writer_TempFile::createTempPath(); // build the command $cmd = $opensslPath . "openssl pkeyutl -sign " diff --git a/public/demos/5-Signer/5-external-implementations/3-openssl-cli/5-rsautl/script.php b/public/demos/5-Signer/5-external-implementations/3-openssl-cli/5-rsautl/script.php index 9fb8984..1da4d67 100644 --- a/public/demos/5-Signer/5-external-implementations/3-openssl-cli/5-rsautl/script.php +++ b/public/demos/5-Signer/5-external-implementations/3-openssl-cli/5-rsautl/script.php @@ -13,12 +13,12 @@ // the file to sign $fileToSign = $assetsDirectory . '/pdfs/tektown/Laboratory-Report.pdf'; // create a temporary path -$tempFile = SetaPDF_Core_Writer_TempFile::createTempPath(); +$tempFile = \SetaPDF_Core_Writer_TempFile::createTempPath(); // create a writer instance -$writer = new SetaPDF_Core_Writer_Http('signed-with-rsautl.pdf'); +$writer = new \SetaPDF_Core_Writer_Http('signed-with-rsautl.pdf'); // create the document instance -$document = SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); +$document = \SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); // create the signer instance $signer = new SetaPDF_Signer($document); @@ -29,7 +29,7 @@ $module->setCertificate('file://' . $assetsDirectory . '/certificates/setapdf-no-pw.pem'); // create a temporary version which represents the data which should get signed -$tmpDocument = $signer->preSign(new SetaPDF_Core_Writer_File($tempFile), $module); +$tmpDocument = $signer->preSign(new \SetaPDF_Core_Writer_File($tempFile), $module); // get the hash data from the module $hashData = $module->getDataToSign($tmpDocument->getHashFile()); @@ -62,9 +62,9 @@ ); // and write it to a temporary file -$tmpFileIn = SetaPDF_Core_Writer_TempFile::createTempFile($digestInfo); +$tmpFileIn = \SetaPDF_Core_Writer_TempFile::createTempFile($digestInfo); // prepare a temporary file for the final signature -$tmpFileOut = SetaPDF_Core_Writer_TempFile::createTempPath(); +$tmpFileOut = \SetaPDF_Core_Writer_TempFile::createTempPath(); // build the command $cmd = $opensslPath . "openssl rsautl -sign -pkcs " diff --git a/public/demos/5-Signer/5-external-implementations/4-php/1-openssl_private_encrypt/script.php b/public/demos/5-Signer/5-external-implementations/4-php/1-openssl_private_encrypt/script.php index 18454e3..fdf81da 100644 --- a/public/demos/5-Signer/5-external-implementations/4-php/1-openssl_private_encrypt/script.php +++ b/public/demos/5-Signer/5-external-implementations/4-php/1-openssl_private_encrypt/script.php @@ -6,12 +6,12 @@ // the file to sign $fileToSign = $assetsDirectory . '/pdfs/tektown/Laboratory-Report.pdf'; // create a temporary path -$tempFile = SetaPDF_Core_Writer_TempFile::createTempPath(); +$tempFile = \SetaPDF_Core_Writer_TempFile::createTempPath(); // create a writer instance -$writer = new SetaPDF_Core_Writer_Http('signed-with-php-openssl.pdf'); +$writer = new \SetaPDF_Core_Writer_Http('signed-with-php-openssl.pdf'); // create the document instance -$document = SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); +$document = \SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); // create the signer instance $signer = new SetaPDF_Signer($document); @@ -22,7 +22,7 @@ $module->setCertificate('file://' . $assetsDirectory . '/certificates/setapdf-no-pw.pem'); // create a temporary version which represents the data which should get signed -$tmpDocument = $signer->preSign(new SetaPDF_Core_Writer_File($tempFile), $module); +$tmpDocument = $signer->preSign(new \SetaPDF_Core_Writer_File($tempFile), $module); // get the hash data from the module $hashData = $module->getDataToSign($tmpDocument->getHashFile()); diff --git a/public/demos/5-Signer/5-external-implementations/4-php/2-openssl_private_encrypt-as-module/script.php b/public/demos/5-Signer/5-external-implementations/4-php/2-openssl_private_encrypt-as-module/script.php index d208568..7bf4658 100644 --- a/public/demos/5-Signer/5-external-implementations/4-php/2-openssl_private_encrypt-as-module/script.php +++ b/public/demos/5-Signer/5-external-implementations/4-php/2-openssl_private_encrypt-as-module/script.php @@ -10,12 +10,12 @@ // the file to sign $fileToSign = $assetsDirectory . '/pdfs/tektown/Laboratory-Report.pdf'; // create a temporary path -$tempFile = SetaPDF_Core_Writer_TempFile::createTempPath(); +$tempFile = \SetaPDF_Core_Writer_TempFile::createTempPath(); // create a writer instance -$writer = new SetaPDF_Core_Writer_Http('signed-with-php-openssl.pdf'); +$writer = new \SetaPDF_Core_Writer_Http('signed-with-php-openssl.pdf'); // create the document instance -$document = SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); +$document = \SetaPDF_Core_Document::loadByFilename($fileToSign, $writer); // create the signer instance $signer = new SetaPDF_Signer($document); diff --git a/public/demos/6-Stamper/1-stamp-types/1-text-stamp/1-simple/script.php b/public/demos/6-Stamper/1-stamp-types/1-text-stamp/1-simple/script.php index c498b05..c4f98d1 100644 --- a/public/demos/6-Stamper/1-stamp-types/1-text-stamp/1-simple/script.php +++ b/public/demos/6-Stamper/1-stamp-types/1-text-stamp/1-simple/script.php @@ -11,14 +11,14 @@ $path = displayFiles($files); -$writer = new SetaPDF_Core_Writer_Http('stamped.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename($path, $writer); +$writer = new \SetaPDF_Core_Writer_Http('stamped.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename($path, $writer); // create a stamper instance $stamper = new SetaPDF_Stamper($document); // create a font instance which is needed for the text stamp instance -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); diff --git a/public/demos/6-Stamper/1-stamp-types/1-text-stamp/2-color-rendering-mode-opacity/script.php b/public/demos/6-Stamper/1-stamp-types/1-text-stamp/2-color-rendering-mode-opacity/script.php index dbd1420..4b44780 100644 --- a/public/demos/6-Stamper/1-stamp-types/1-text-stamp/2-color-rendering-mode-opacity/script.php +++ b/public/demos/6-Stamper/1-stamp-types/1-text-stamp/2-color-rendering-mode-opacity/script.php @@ -24,14 +24,14 @@ $path = displayFiles($files)['file']; -$writer = new SetaPDF_Core_Writer_Http('stamped.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename($path, $writer); +$writer = new \SetaPDF_Core_Writer_Http('stamped.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename($path, $writer); // create a stamper instance $stamper = new SetaPDF_Stamper($document); // create a font instance which is needed for the text stamp instance -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); diff --git a/public/demos/6-Stamper/1-stamp-types/1-text-stamp/3-advanced-styling/script.php b/public/demos/6-Stamper/1-stamp-types/1-text-stamp/3-advanced-styling/script.php index 4f87162..0c7a9d4 100644 --- a/public/demos/6-Stamper/1-stamp-types/1-text-stamp/3-advanced-styling/script.php +++ b/public/demos/6-Stamper/1-stamp-types/1-text-stamp/3-advanced-styling/script.php @@ -11,14 +11,14 @@ $path = displayFiles($files); -$writer = new SetaPDF_Core_Writer_Http('stamped.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename($path, $writer); +$writer = new \SetaPDF_Core_Writer_Http('stamped.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename($path, $writer); // create a stamper instance $stamper = new SetaPDF_Stamper($document); // create a font instance which is needed for the text stamp instance -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); @@ -35,7 +35,7 @@ // set padding $stamp->setPadding(3); // set text color by an explicit color instance -$stamp->setTextColor(new SetaPDF_Core_DataStructure_Color_Rgb(56/255, 101/255, 174/255)); +$stamp->setTextColor(new \SetaPDF_Core_DataStructure_Color_Rgb(56/255, 101/255, 174/255)); // add the stamp to the stamper instance $stamper->addStamp($stamp, [ diff --git a/public/demos/6-Stamper/1-stamp-types/1-text-stamp/4-align/script.php b/public/demos/6-Stamper/1-stamp-types/1-text-stamp/4-align/script.php index 6463bef..ab7dc73 100644 --- a/public/demos/6-Stamper/1-stamp-types/1-text-stamp/4-align/script.php +++ b/public/demos/6-Stamper/1-stamp-types/1-text-stamp/4-align/script.php @@ -7,20 +7,20 @@ . "and line-breaks to be able to align\nthe text at all."; // we create a blank document to show the behavior -$writer = new SetaPDF_Core_Writer_Http('stamped.pdf', true); -$document = new SetaPDF_Core_Document($writer); +$writer = new \SetaPDF_Core_Writer_Http('stamped.pdf', true); +$document = new \SetaPDF_Core_Document($writer); // let's create 3 pages for demonstration purpose $pages = $document->getCatalog()->getPages(); -$pages->create(SetaPDF_Core_PageFormats::A4); -$pages->create(SetaPDF_Core_PageFormats::A4); -$pages->create(SetaPDF_Core_PageFormats::A4); +$pages->create(\SetaPDF_Core_PageFormats::A4); +$pages->create(\SetaPDF_Core_PageFormats::A4); +$pages->create(\SetaPDF_Core_PageFormats::A4); // create a stamper instance $stamper = new SetaPDF_Stamper($document); // create a font instance which is needed for the text stamp instance -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); @@ -28,13 +28,13 @@ // create a stamp instance left aligned $stampLeft = new SetaPDF_Stamper_Stamp_Text($font, 12); $stampLeft->setText($text); -$stampLeft->setAlign(SetaPDF_Core_Text::ALIGN_LEFT); +$stampLeft->setAlign(\SetaPDF_Core_Text::ALIGN_LEFT); $stamper->addStamp($stampLeft); // create a stamp instance centered $stampCenter = new SetaPDF_Stamper_Stamp_Text($font, 12); $stampCenter->setText($text); -$stampCenter->setAlign(SetaPDF_Core_Text::ALIGN_CENTER); +$stampCenter->setAlign(\SetaPDF_Core_Text::ALIGN_CENTER); $stamper->addStamp($stampCenter, [ 'position' => SetaPDF_Stamper::POSITION_CENTER_MIDDLE, 'translateY' => 140 @@ -43,7 +43,7 @@ // create a stamp instance justified $stampCenter = new SetaPDF_Stamper_Stamp_Text($font, 12); $stampCenter->setText($text); -$stampCenter->setAlign(SetaPDF_Core_Text::ALIGN_JUSTIFY); +$stampCenter->setAlign(\SetaPDF_Core_Text::ALIGN_JUSTIFY); $stamper->addStamp($stampCenter, [ 'position' => SetaPDF_Stamper::POSITION_CENTER_MIDDLE, 'translateY' => -140 @@ -52,7 +52,7 @@ // create a stamp instance right aligned $stampLeft = new SetaPDF_Stamper_Stamp_Text($font, 12); $stampLeft->setText($text); -$stampLeft->setAlign(SetaPDF_Core_Text::ALIGN_RIGHT); +$stampLeft->setAlign(\SetaPDF_Core_Text::ALIGN_RIGHT); $stamper->addStamp($stampLeft, SetaPDF_Stamper::POSITION_RIGHT_BOTTOM); // execute the stamp process diff --git a/public/demos/6-Stamper/1-stamp-types/1-text-stamp/5-automatic-line-breaks/script.php b/public/demos/6-Stamper/1-stamp-types/1-text-stamp/5-automatic-line-breaks/script.php index e82e39b..f7fb5ee 100644 --- a/public/demos/6-Stamper/1-stamp-types/1-text-stamp/5-automatic-line-breaks/script.php +++ b/public/demos/6-Stamper/1-stamp-types/1-text-stamp/5-automatic-line-breaks/script.php @@ -7,18 +7,18 @@ . "line-breaks to be able to show the line break behavior."; // we create a blank document to show the behavior -$writer = new SetaPDF_Core_Writer_Http('stamped.pdf', true); -$document = new SetaPDF_Core_Document($writer); +$writer = new \SetaPDF_Core_Writer_Http('stamped.pdf', true); +$document = new \SetaPDF_Core_Document($writer); // let's create 1 page for demonstration purpose $pages = $document->getCatalog()->getPages(); -$pages->create(SetaPDF_Core_PageFormats::A4); +$pages->create(\SetaPDF_Core_PageFormats::A4); // create a stamper instance $stamper = new SetaPDF_Stamper($document); // create a font instance which is needed for the text stamp instance -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); @@ -26,14 +26,14 @@ // create a stamp instance WITHOUT width $stampA = new SetaPDF_Stamper_Stamp_Text($font, 12); $stampA->setText('No width given: ' . $text); -$stampA->setAlign(SetaPDF_Core_Text::ALIGN_JUSTIFY); +$stampA->setAlign(\SetaPDF_Core_Text::ALIGN_JUSTIFY); $stamper->addStamp($stampA); // create a stamp instance WITH width $stampB = new SetaPDF_Stamper_Stamp_Text($font, 12); $stampB->setText('Width given: ' . $text); $stampB->setWidth(220); -$stampB->setAlign(SetaPDF_Core_Text::ALIGN_JUSTIFY); +$stampB->setAlign(\SetaPDF_Core_Text::ALIGN_JUSTIFY); $stamper->addStamp($stampB, SetaPDF_Stamper::POSITION_LEFT_MIDDLE); // execute the stamp process diff --git a/public/demos/6-Stamper/1-stamp-types/2-image-stamp/1-simple/script.php b/public/demos/6-Stamper/1-stamp-types/2-image-stamp/1-simple/script.php index 0c16c25..4fd8250 100644 --- a/public/demos/6-Stamper/1-stamp-types/2-image-stamp/1-simple/script.php +++ b/public/demos/6-Stamper/1-stamp-types/2-image-stamp/1-simple/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../../bootstrap.php'; // create a writer -$writer = new SetaPDF_Core_Writer_Http('image-stamp.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('image-stamp.pdf', true); // get a document instance -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/Fact-Sheet-without-personalization.pdf', $writer ); @@ -15,7 +15,7 @@ $stamper = new SetaPDF_Stamper($document); // get an image instance -$image = SetaPDF_Core_Image::getByPath($assetsDirectory . '/pdfs/camtown/Logo.png'); +$image = \SetaPDF_Core_Image::getByPath($assetsDirectory . '/pdfs/camtown/Logo.png'); // initiate the stamp $stamp = new SetaPDF_Stamper_Stamp_Image($image); // set height (and width until no setWidth is set the ratio will retain) diff --git a/public/demos/6-Stamper/1-stamp-types/2-image-stamp/2-on-pdf-form/script.php b/public/demos/6-Stamper/1-stamp-types/2-image-stamp/2-on-pdf-form/script.php index d2d2343..8983bf8 100644 --- a/public/demos/6-Stamper/1-stamp-types/2-image-stamp/2-on-pdf-form/script.php +++ b/public/demos/6-Stamper/1-stamp-types/2-image-stamp/2-on-pdf-form/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../../bootstrap.php'; // create a writer -$writer = new SetaPDF_Core_Writer_Http('pdf-form-stamped.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('pdf-form-stamped.pdf', true); // get a document instance -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/tektown/Order-Form-without-Signaturefield.pdf', $writer ); @@ -15,7 +15,7 @@ $stamper = new SetaPDF_Stamper($document); // get an image instance -$image = SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/Handwritten-Signature.png'); +$image = \SetaPDF_Core_Image::getByPath($assetsDirectory . '/images/Handwritten-Signature.png'); // initiate the stamp $stamp = new SetaPDF_Stamper_Stamp_Image($image); // set height (and width until no setWidth is set the ratio will retain) diff --git a/public/demos/6-Stamper/1-stamp-types/3-pdf-stamp/1-simple/script.php b/public/demos/6-Stamper/1-stamp-types/3-pdf-stamp/1-simple/script.php index baf588e..ee71543 100644 --- a/public/demos/6-Stamper/1-stamp-types/3-pdf-stamp/1-simple/script.php +++ b/public/demos/6-Stamper/1-stamp-types/3-pdf-stamp/1-simple/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../../bootstrap.php'; // create a writer -$writer = new SetaPDF_Core_Writer_Http('pdf-stamp.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('pdf-stamp.pdf', true); // get a document instance -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/Fact-Sheet-without-personalization.pdf', $writer ); @@ -18,7 +18,7 @@ $stamp = new SetaPDF_Stamper_Stamp_Pdf( $assetsDirectory . '/pdfs/lenstown/Logo.pdf', 1, - SetaPDF_Core_PageBoundaries::ART_BOX + \SetaPDF_Core_PageBoundaries::ART_BOX ); // set height (and width until no setWidth is set the ratio will retain) $stamp->setHeight(23); diff --git a/public/demos/6-Stamper/1-stamp-types/4-xobject-stamp/1-simple/script.php b/public/demos/6-Stamper/1-stamp-types/4-xobject-stamp/1-simple/script.php index 141e32b..de405cd 100644 --- a/public/demos/6-Stamper/1-stamp-types/4-xobject-stamp/1-simple/script.php +++ b/public/demos/6-Stamper/1-stamp-types/4-xobject-stamp/1-simple/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../../bootstrap.php'; // create a writer -$writer = new SetaPDF_Core_Writer_Http('smile.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('smile.pdf', true); // get a document instance -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/lenstown/Laboratory-Report.pdf', $writer ); @@ -15,7 +15,7 @@ $stamper = new SetaPDF_Stamper($document); // create a XObject -$xObject = SetaPDF_Core_XObject_Form::create($document, array(0, 0, 205, 205)); +$xObject = \SetaPDF_Core_XObject_Form::create($document, array(0, 0, 205, 205)); // get the Canvas $canvas = $xObject->getCanvas(); // Let's draw a smilie ;-) @@ -26,7 +26,7 @@ ->path() ->setLineWidth(5) ->draw() - ->circle(102.5, 102.5, 100, SetaPDF_Core_Canvas_Draw::STYLE_DRAW_AND_FILL) // head + ->circle(102.5, 102.5, 100, \SetaPDF_Core_Canvas_Draw::STYLE_DRAW_AND_FILL) // head ->circle(60, 120, 15) // left eye ->circle(140, 120, 15) // right exe ->path() diff --git a/public/demos/6-Stamper/1-stamp-types/4-xobject-stamp/2-styled-text/script.php b/public/demos/6-Stamper/1-stamp-types/4-xobject-stamp/2-styled-text/script.php index 81dd5dd..f8c0ba1 100644 --- a/public/demos/6-Stamper/1-stamp-types/4-xobject-stamp/2-styled-text/script.php +++ b/public/demos/6-Stamper/1-stamp-types/4-xobject-stamp/2-styled-text/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../../bootstrap.php'; // create a writer -$writer = new SetaPDF_Core_Writer_Http('styled.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('styled.pdf', true); // get a document instance -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/lenstown/Laboratory-Report.pdf', $writer ); @@ -16,17 +16,17 @@ // We need to draw the text style-by-style. // First we prepare font instances: -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); -$fontB = new SetaPDF_Core_Font_TrueType_Subset( +$fontB = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans-Bold.ttf' ); -$fontI = new SetaPDF_Core_Font_TrueType_Subset( +$fontI = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans-Oblique.ttf' ); @@ -47,7 +47,7 @@ } // create a XObject -$xObject = SetaPDF_Core_XObject_Form::create($document, [0, 0, $width, $height]); +$xObject = \SetaPDF_Core_XObject_Form::create($document, [0, 0, $width, $height]); // get the Canvas $canvas = $xObject->getCanvas(); @@ -57,7 +57,7 @@ ->moveToNextLine(0, -$text[0][1]->getDescent() / 1000 * $fontSize); foreach ($text as $textItem) { - /** @var SetaPDF_Core_Font_FontInterface $font */ + /** @var \SetaPDF_Core_Font_FontInterface $font */ $font = $textItem[1]; $canvasText diff --git a/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/1-different-font-styles/script.php b/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/1-different-font-styles/script.php index bf347fc..7c9778e 100644 --- a/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/1-different-font-styles/script.php +++ b/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/1-different-font-styles/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../../bootstrap.php'; // create a writer -$writer = new SetaPDF_Core_Writer_Http('styled.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('styled.pdf', true); // get a document instance -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/lenstown/Laboratory-Report.pdf', $writer ); diff --git a/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/2-align/script.php b/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/2-align/script.php index 7f12014..f8cd90a 100644 --- a/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/2-align/script.php +++ b/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/2-align/script.php @@ -10,14 +10,14 @@ HTML; // we create a blank document to show the behavior -$writer = new SetaPDF_Core_Writer_Http('stamped.pdf', true); -$document = new SetaPDF_Core_Document($writer); +$writer = new \SetaPDF_Core_Writer_Http('stamped.pdf', true); +$document = new \SetaPDF_Core_Document($writer); // let's create 3 pages for demonstration purpose $pages = $document->getCatalog()->getPages(); -$pages->create(SetaPDF_Core_PageFormats::A4); -$pages->create(SetaPDF_Core_PageFormats::A4); -$pages->create(SetaPDF_Core_PageFormats::A4); +$pages->create(\SetaPDF_Core_PageFormats::A4); +$pages->create(\SetaPDF_Core_PageFormats::A4); +$pages->create(\SetaPDF_Core_PageFormats::A4); // create a stamper instance $stamper = new SetaPDF_Stamper($document); @@ -29,14 +29,14 @@ $stampLeft = new SetaPDF_Stamper_Stamp_RichText($document, $fontLoader); $stampLeft->setDefaultFontFamily('DejaVuSans'); $stampLeft->setText($text); -$stampLeft->setAlign(SetaPDF_Core_Text::ALIGN_LEFT); +$stampLeft->setAlign(\SetaPDF_Core_Text::ALIGN_LEFT); $stamper->addStamp($stampLeft); // create a stamp instance centered $stampCenter = new SetaPDF_Stamper_Stamp_RichText($document, $fontLoader); $stampCenter->setDefaultFontFamily('DejaVuSans'); $stampCenter->setText($text); -$stampCenter->setAlign(SetaPDF_Core_Text::ALIGN_CENTER); +$stampCenter->setAlign(\SetaPDF_Core_Text::ALIGN_CENTER); $stamper->addStamp($stampCenter, [ 'position' => SetaPDF_Stamper::POSITION_CENTER_MIDDLE, 'translateY' => 140 @@ -46,7 +46,7 @@ $stampCenter = new SetaPDF_Stamper_Stamp_RichText($document, $fontLoader); $stampCenter->setDefaultFontFamily('DejaVuSans'); $stampCenter->setText($text); -$stampCenter->setAlign(SetaPDF_Core_Text::ALIGN_JUSTIFY); +$stampCenter->setAlign(\SetaPDF_Core_Text::ALIGN_JUSTIFY); $stamper->addStamp($stampCenter, [ 'position' => SetaPDF_Stamper::POSITION_CENTER_MIDDLE, 'translateY' => -140 @@ -56,7 +56,7 @@ $stampRight = new SetaPDF_Stamper_Stamp_RichText($document, $fontLoader); $stampRight->setDefaultFontFamily('DejaVuSans'); $stampRight->setText($text); -$stampRight->setAlign(SetaPDF_Core_Text::ALIGN_RIGHT); +$stampRight->setAlign(\SetaPDF_Core_Text::ALIGN_RIGHT); $stamper->addStamp($stampRight, SetaPDF_Stamper::POSITION_RIGHT_BOTTOM); // execute the stamp process diff --git a/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/3-advanced-styling/script.php b/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/3-advanced-styling/script.php index 851f697..3ab5f3b 100644 --- a/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/3-advanced-styling/script.php +++ b/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/3-advanced-styling/script.php @@ -11,8 +11,8 @@ $path = displayFiles($files); -$writer = new SetaPDF_Core_Writer_Http('stamped.pdf', true); -$document = SetaPDF_Core_Document::loadByFilename($path, $writer); +$writer = new \SetaPDF_Core_Writer_Http('stamped.pdf', true); +$document = \SetaPDF_Core_Document::loadByFilename($path, $writer); // create a stamper instance $stamper = new SetaPDF_Stamper($document); @@ -33,7 +33,7 @@ // set padding $stamp->setPadding(3); // set default text color by an explicit color instance -$stamp->setDefaultTextColor(new SetaPDF_Core_DataStructure_Color_Rgb(56/255, 101/255, 174/255)); +$stamp->setDefaultTextColor(new \SetaPDF_Core_DataStructure_Color_Rgb(56/255, 101/255, 174/255)); // add the stamp to the stamper instance $stamper->addStamp($stamp, [ diff --git a/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/4-simple-font-loader/script.php b/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/4-simple-font-loader/script.php index f30fc91..a762904 100644 --- a/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/4-simple-font-loader/script.php +++ b/public/demos/6-Stamper/1-stamp-types/5-rich-text-stamp/4-simple-font-loader/script.php @@ -4,9 +4,9 @@ require_once __DIR__ . '/../../../../../../bootstrap.php'; // create a writer -$writer = new SetaPDF_Core_Writer_Http('font-loader.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('font-loader.pdf', true); // get a document instance -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/lenstown/Laboratory-Report.pdf', $writer ); @@ -17,22 +17,22 @@ * It is an urgent requirement to cache the instances for a document instance. Otherwise, you will create * and embed several minimal font subsets. */ -$fontLoader = static function(SetaPDF_Core_Document $document, $fontFamily, $fontStyle) use (&$loadedFonts, $assetsDirectory) { +$fontLoader = static function(\SetaPDF_Core_Document $document, $fontFamily, $fontStyle) use (&$loadedFonts, $assetsDirectory) { $cacheKey = $document->getInstanceIdent() . '_' . $fontStyle; if (!array_key_exists($cacheKey, $loadedFonts)) { $fontPath = $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans'; switch ($fontStyle) { case 'B': - $font = new SetaPDF_Core_Font_Type0_Subset($document, $fontPath . '-Bold.ttf'); + $font = new \SetaPDF_Core_Font_Type0_Subset($document, $fontPath . '-Bold.ttf'); break; case 'I': - $font = new SetaPDF_Core_Font_Type0_Subset($document, $fontPath . '-Oblique.ttf'); + $font = new \SetaPDF_Core_Font_Type0_Subset($document, $fontPath . '-Oblique.ttf'); break; case 'BI': - $font = new SetaPDF_Core_Font_Type0_Subset($document, $fontPath . '-BoldOblique.ttf'); + $font = new \SetaPDF_Core_Font_Type0_Subset($document, $fontPath . '-BoldOblique.ttf'); break; default: - $font = new SetaPDF_Core_Font_Type0_Subset($document, $fontPath . '.ttf'); + $font = new \SetaPDF_Core_Font_Type0_Subset($document, $fontPath . '.ttf'); } $loadedFonts[$cacheKey] = $font; } diff --git a/public/demos/6-Stamper/2-adding-stamps/1-positioning/script.php b/public/demos/6-Stamper/2-adding-stamps/1-positioning/script.php index f8636c5..190bda9 100644 --- a/public/demos/6-Stamper/2-adding-stamps/1-positioning/script.php +++ b/public/demos/6-Stamper/2-adding-stamps/1-positioning/script.php @@ -17,18 +17,18 @@ $position = displaySelect('Position:', $positions); -$writer = new SetaPDF_Core_Writer_Http('positioning.pdf', true); -$document = new SetaPDF_Core_Document($writer); +$writer = new \SetaPDF_Core_Writer_Http('positioning.pdf', true); +$document = new \SetaPDF_Core_Document($writer); // let's add 2 pages for demonstration purpose $pages = $document->getCatalog()->getPages(); -$pages->create(SetaPDF_Core_PageFormats::A4, SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT); -$pages->create(SetaPDF_Core_PageFormats::A4, SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE); +$pages->create(\SetaPDF_Core_PageFormats::A4, \SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT); +$pages->create(\SetaPDF_Core_PageFormats::A4, \SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE); // create a stamper instance $stamper = new SetaPDF_Stamper($document); // create a font instance which is needed for the text stamp instance -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); diff --git a/public/demos/6-Stamper/2-adding-stamps/2-positioning-and-translation/script.php b/public/demos/6-Stamper/2-adding-stamps/2-positioning-and-translation/script.php index c12a0b1..dbe1160 100644 --- a/public/demos/6-Stamper/2-adding-stamps/2-positioning-and-translation/script.php +++ b/public/demos/6-Stamper/2-adding-stamps/2-positioning-and-translation/script.php @@ -8,18 +8,18 @@ $value = displaySelect('Position & Translate:', $translateOptions); $data = $translateOptions[$value]; -$writer = new SetaPDF_Core_Writer_Http('positioning-and-translate.pdf', true); -$document = new SetaPDF_Core_Document($writer); +$writer = new \SetaPDF_Core_Writer_Http('positioning-and-translate.pdf', true); +$document = new \SetaPDF_Core_Document($writer); // let's add some pages for demonstration purpose $pages = $document->getCatalog()->getPages(); -$pages->create(SetaPDF_Core_PageFormats::A4, SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT); -$pages->create(SetaPDF_Core_PageFormats::A4, SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE); +$pages->create(\SetaPDF_Core_PageFormats::A4, \SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT); +$pages->create(\SetaPDF_Core_PageFormats::A4, \SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE); // create a stamper instance $stamper = new SetaPDF_Stamper($document); // create a font instance which is needed for the text stamp instance -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); diff --git a/public/demos/6-Stamper/2-adding-stamps/3-show-on-page/script.php b/public/demos/6-Stamper/2-adding-stamps/3-show-on-page/script.php index 020e405..f9ce694 100644 --- a/public/demos/6-Stamper/2-adding-stamps/3-show-on-page/script.php +++ b/public/demos/6-Stamper/2-adding-stamps/3-show-on-page/script.php @@ -8,14 +8,14 @@ $value = displaySelect('Show on page:', $showOnPageOptions); $data = $showOnPageOptions[$value]; -$writer = new SetaPDF_Core_Writer_Http('positioning-and-translate.pdf', true); -$document = new SetaPDF_Core_Document($writer); +$writer = new \SetaPDF_Core_Writer_Http('positioning-and-translate.pdf', true); +$document = new \SetaPDF_Core_Document($writer); // let's add some pages for demonstration purpose $pages = $document->getCatalog()->getPages(); for ($i = 100; $i > 0; $i--) { $pages->create( - SetaPDF_Core_PageFormats::A4, - ($i & 1) ? SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT : SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE + \SetaPDF_Core_PageFormats::A4, + ($i & 1) ? \SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT : \SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE ); } @@ -23,7 +23,7 @@ $stamper = new SetaPDF_Stamper($document); // create a font instance which is needed for the text stamp instance -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); diff --git a/public/demos/6-Stamper/2-adding-stamps/4-rotation/script.php b/public/demos/6-Stamper/2-adding-stamps/4-rotation/script.php index aa7222e..4224024 100644 --- a/public/demos/6-Stamper/2-adding-stamps/4-rotation/script.php +++ b/public/demos/6-Stamper/2-adding-stamps/4-rotation/script.php @@ -8,18 +8,18 @@ $value = displaySelect('Position & Rotation:', $rotationOptions); $data = $rotationOptions[$value]; -$writer = new SetaPDF_Core_Writer_Http('positioning-and-translate.pdf', true); -$document = new SetaPDF_Core_Document($writer); +$writer = new \SetaPDF_Core_Writer_Http('positioning-and-translate.pdf', true); +$document = new \SetaPDF_Core_Document($writer); // let's add 2 pages for demonstration purpose $pages = $document->getCatalog()->getPages(); -$pages->create(SetaPDF_Core_PageFormats::A4, SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT); -$pages->create(SetaPDF_Core_PageFormats::A4, SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE); +$pages->create(\SetaPDF_Core_PageFormats::A4, \SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT); +$pages->create(\SetaPDF_Core_PageFormats::A4, \SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE); // create a stamper instance $stamper = new SetaPDF_Stamper($document); // create a font instance which is needed for the text stamp instance -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); @@ -30,7 +30,7 @@ $stamp->setBorderWidth(1); $stamp->setPadding(2); $stamp->setWidth(180); -$stamp->setAlign(SetaPDF_Core_Text::ALIGN_CENTER); +$stamp->setAlign(\SetaPDF_Core_Text::ALIGN_CENTER); $stamp->setText('A simple example text to demonstrate rotation.'); // add the stamp object on all pages on the given position diff --git a/public/demos/6-Stamper/2-adding-stamps/5-callback/script.php b/public/demos/6-Stamper/2-adding-stamps/5-callback/script.php index df809a3..8b04070 100644 --- a/public/demos/6-Stamper/2-adding-stamps/5-callback/script.php +++ b/public/demos/6-Stamper/2-adding-stamps/5-callback/script.php @@ -4,35 +4,35 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // create a writer -$writer = new SetaPDF_Core_Writer_Http('callback.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('callback.pdf', true); // we create a fresh document instance for demonstration purpose -$document = new SetaPDF_Core_Document($writer); +$document = new \SetaPDF_Core_Document($writer); // get the pages instance $pages = $document->getCatalog()->getPages(); // create 20 pages for ($i = 0; $i < 20; $i++) { $orientation = $i % 2 - ? SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE - : SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT; + ? \SetaPDF_Core_PageFormats::ORIENTATION_LANDSCAPE + : \SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT; - $pages->create(SetaPDF_Core_PageFormats::A4, $orientation); + $pages->create(\SetaPDF_Core_PageFormats::A4, $orientation); } // create a stamper instance $stamper = new SetaPDF_Stamper($document); // create a font object -$font = SetaPDF_Core_Font_Standard_Helvetica::create($document); +$font = \SetaPDF_Core_Font_Standard_Helvetica::create($document); // create simple text stamp $stamp = new SetaPDF_Stamper_Stamp_Text($font, 16); $stamp->setPadding(4); -$stamp->setAlign(SetaPDF_Core_Text::ALIGN_RIGHT); +$stamp->setAlign(\SetaPDF_Core_Text::ALIGN_RIGHT); /** * @param $pageNumber The current page number that should be stamped * @param $pageCount The page count of the document - * @param SetaPDF_Core_Document_Page $page The page instance of the current page + * @param \SetaPDF_Core_Document_Page $page The page instance of the current page * @param SetaPDF_Stamper_Stamp_Text $stamp The stamp object * @param array $currentStampData The data that were passed to the addStamp() method. * @@ -41,7 +41,7 @@ $callback = function( $pageNumber, $pageCount, - SetaPDF_Core_Document_Page $page, + \SetaPDF_Core_Document_Page $page, SetaPDF_Stamper_Stamp_Text $stamp, array &$currentStampData ) { @@ -78,7 +78,7 @@ $stamper->stamp(); // show the whole page at opening time -$document->getCatalog()->setPageLayout(SetaPDF_Core_Document_PageLayout::SINGLE_PAGE); +$document->getCatalog()->setPageLayout(\SetaPDF_Core_Document_PageLayout::SINGLE_PAGE); // save and send it to the client $document->save()->finish(); diff --git a/public/demos/6-Stamper/3-various/1-stamp-visibility/script.php b/public/demos/6-Stamper/3-various/1-stamp-visibility/script.php index 53b1eba..766ac83 100644 --- a/public/demos/6-Stamper/3-various/1-stamp-visibility/script.php +++ b/public/demos/6-Stamper/3-various/1-stamp-visibility/script.php @@ -4,17 +4,17 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // let's get access to the file -$reader = new SetaPDF_Core_Reader_File($assetsDirectory . '/pdfs/Brand-Guide.pdf'); +$reader = new \SetaPDF_Core_Reader_File($assetsDirectory . '/pdfs/Brand-Guide.pdf'); // create a HTTP writer -$writer = new SetaPDF_Core_Writer_Http('stamped.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('stamped.pdf', true); // let's get the document -$document = SetaPDF_Core_Document::load($reader, $writer); +$document = \SetaPDF_Core_Document::load($reader, $writer); // initiate a stamper instance $stamper = new SetaPDF_Stamper($document); // let's use a TrueType font for the stamp appearance: -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans-ExtraLight.ttf' ); diff --git a/public/demos/6-Stamper/3-various/2-page-numbering/script.php b/public/demos/6-Stamper/3-various/2-page-numbering/script.php index 74047ae..2ed9a0f 100644 --- a/public/demos/6-Stamper/3-various/2-page-numbering/script.php +++ b/public/demos/6-Stamper/3-various/2-page-numbering/script.php @@ -4,15 +4,15 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // create a file writer -$writer = new SetaPDF_Core_Writer_Http('page-numbering-demo.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('page-numbering-demo.pdf', true); // load document by filename -$document = SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/lenstown/products/All.pdf', $writer); +$document = \SetaPDF_Core_Document::loadByFilename($assetsDirectory . '/pdfs/lenstown/products/All.pdf', $writer); // create a stamper instance for the document $stamper = new SetaPDF_Stamper($document); // let's use a TrueType font for the stamp appearance: -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans-ExtraLight.ttf' ); @@ -22,8 +22,8 @@ $stamp->setTextColor('#6d6f72'); // let's create links back to page 1 -$dest = SetaPDF_Core_Document_Destination::createByPageNo($document, 1); -$action = new SetaPDF_Core_Document_Action_GoTo($dest); +$dest = \SetaPDF_Core_Document_Destination::createByPageNo($document, 1); +$action = new \SetaPDF_Core_Document_Action_GoTo($dest); $stamp->setAction($action); // a callback to set the pagenumbers for each page @@ -50,7 +50,7 @@ function callbackForPageNumbering($pageNumber, $pageCount, $page, SetaPDF_Stampe $lineWidth = .7; // create a XObject -$xObject = SetaPDF_Core_XObject_Form::create($document, [0, 0, 10, $lineWidth]); +$xObject = \SetaPDF_Core_XObject_Form::create($document, [0, 0, 10, $lineWidth]); // get the Canvas $canvas = $xObject->getCanvas(); // set the collor and draw a line @@ -73,7 +73,7 @@ function callbackForPageNumbering($pageNumber, $pageCount, $page, SetaPDF_Stampe 'callback' => static function( $pageNumber, $pageCount, - SetaPDF_Core_Document_Page $page, + \SetaPDF_Core_Document_Page $page, SetaPDF_Stamper_Stamp_XObject $stamp ) { $stamp->setWidth($page->getWidth() - 29 * 2); diff --git a/public/demos/6-Stamper/3-various/3-stamp-prepended-title-page/script.php b/public/demos/6-Stamper/3-various/3-stamp-prepended-title-page/script.php index f0be1c8..2a953fd 100644 --- a/public/demos/6-Stamper/3-various/3-stamp-prepended-title-page/script.php +++ b/public/demos/6-Stamper/3-various/3-stamp-prepended-title-page/script.php @@ -4,16 +4,16 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // let's get access to the file -$reader = new SetaPDF_Core_Reader_File($assetsDirectory . '/pdfs/Brand-Guide.pdf'); +$reader = new \SetaPDF_Core_Reader_File($assetsDirectory . '/pdfs/Brand-Guide.pdf'); // create a HTTP writer -$writer = new SetaPDF_Core_Writer_Http('stamped.pdf', true); +$writer = new \SetaPDF_Core_Writer_Http('stamped.pdf', true); // let's get the document -$document = SetaPDF_Core_Document::load($reader, $writer); +$document = \SetaPDF_Core_Document::load($reader, $writer); // get pages helper $pages = $document->getCatalog()->getPages(); // create a page in format A4 but don't append it -$page = $pages->create(SetaPDF_Core_PageFormats::A4, SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT, false); +$page = $pages->create(\SetaPDF_Core_PageFormats::A4, \SetaPDF_Core_PageFormats::ORIENTATION_PORTRAIT, false); // prepend the created page $pages->prepend($page); @@ -21,7 +21,7 @@ $stamper = new SetaPDF_Stamper($document); // let's use a TrueType font for the stamp appearance: -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); @@ -36,7 +36,7 @@ . "Date: " . date("Y-m-d H:i") ); // center the text in textbox -$stamp->setAlign(SetaPDF_Core_Text::ALIGN_CENTER); +$stamp->setAlign(\SetaPDF_Core_Text::ALIGN_CENTER); // define line height to 35 $stamp->setLineHeight(30); // add stamp to stamper @@ -45,7 +45,7 @@ // now we want to insert an image above the text // define which image we want to stamp -$image = SetaPDF_Core_Image::getByPath($assetsDirectory . '/pdfs/camtown/Logo.png'); +$image = \SetaPDF_Core_Image::getByPath($assetsDirectory . '/pdfs/camtown/Logo.png'); // initiate a image stamp $stamp = new SetaPDF_Stamper_Stamp_Image($image); // stretch image stamp diff --git a/public/demos/6-Stamper/3-various/4-stamp-enlarged-page/script.php b/public/demos/6-Stamper/3-various/4-stamp-enlarged-page/script.php index dc32ca8..dcc3d23 100644 --- a/public/demos/6-Stamper/3-various/4-stamp-enlarged-page/script.php +++ b/public/demos/6-Stamper/3-various/4-stamp-enlarged-page/script.php @@ -4,34 +4,34 @@ require_once __DIR__ . '/../../../../../bootstrap.php'; // let's get access to the file -$reader = new SetaPDF_Core_Reader_File($assetsDirectory . '/pdfs/Brand-Guide.pdf'); +$reader = new \SetaPDF_Core_Reader_File($assetsDirectory . '/pdfs/Brand-Guide.pdf'); // create a HTTP writer -$writer = new SetaPDF_Core_Writer_Http('stamped.pdf', true); -//$writer = new SetaPDF_Core_Writer_File('stamped.pdf'); +$writer = new \SetaPDF_Core_Writer_Http('stamped.pdf', true); +//$writer = new \SetaPDF_Core_Writer_File('stamped.pdf'); // let's get the document -$document = SetaPDF_Core_Document::load($reader, $writer); +$document = \SetaPDF_Core_Document::load($reader, $writer); // get first page $firstPage = $document->getCatalog()->getPages()->getPage(1); // get actually boundary of the first page $boundary = $firstPage->getBoundary(); // define the new boundary which is increased on the bottom by 50 -$newBoundary = SetaPDF_Core_DataStructure_Rectangle::byArray( +$newBoundary = \SetaPDF_Core_DataStructure_Rectangle::byArray( [$boundary->getLlx(), $boundary->getLly() - 55, $boundary->getUrx(), $boundary->getUry()] ); // we will first need to enlarge the media box to resize the crop box(visible area) // because in this document the crop box has the same size like the media box // and everything which isn't in the media box wouldn't be displayed -$firstPage->setBoundary($newBoundary, SetaPDF_Core_PageBoundaries::MEDIA_BOX); +$firstPage->setBoundary($newBoundary, \SetaPDF_Core_PageBoundaries::MEDIA_BOX); // now we can enlarge the crop box -$firstPage->setBoundary($newBoundary, SetaPDF_Core_PageBoundaries::CROP_BOX); +$firstPage->setBoundary($newBoundary, \SetaPDF_Core_PageBoundaries::CROP_BOX); // initiate a stamper instance $stamper = new SetaPDF_Stamper($document); // initiate an custom font -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); @@ -46,7 +46,7 @@ // set the width of the stamp to the same width like the crop box $stamp->setWidth($newBoundary->getWidth()); // center text -$stamp->setAlign(SetaPDF_Core_Text::ALIGN_CENTER); +$stamp->setAlign(\SetaPDF_Core_Text::ALIGN_CENTER); // set padding to 5 $stamp->setPadding(10); diff --git a/public/demos/6-Stamper/3-various/5-tagged-stamp/script.php b/public/demos/6-Stamper/3-various/5-tagged-stamp/script.php index 719ca87..8efceae 100644 --- a/public/demos/6-Stamper/3-various/5-tagged-stamp/script.php +++ b/public/demos/6-Stamper/3-various/5-tagged-stamp/script.php @@ -7,10 +7,10 @@ require_once __DIR__ . '/../../../../../classes/Stamper/Stamp/Tagged.php'; // create a HTTP writer -$writer = new SetaPDF_Core_Writer_Http('tagged.pdf', true); -//$writer = new SetaPDF_Core_Writer_File('tagged.pdf'); +$writer = new \SetaPDF_Core_Writer_Http('tagged.pdf', true); +//$writer = new \SetaPDF_Core_Writer_File('tagged.pdf'); // let's get the document -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/Brand-Guide.pdf', $writer ); @@ -21,7 +21,7 @@ //--- Create a text stamp and wrap it in a Tagged stamp instance ---// // create a font instance which is needed for the text stamp instance -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' ); @@ -47,7 +47,7 @@ //--- Create an image stamp and wrap it in a Tagged stamp instance ---// // get an image instance -$image = SetaPDF_Core_Image::getByPath($assetsDirectory . '/pdfs/tektown/Logo.png'); +$image = \SetaPDF_Core_Image::getByPath($assetsDirectory . '/pdfs/tektown/Logo.png'); // initiate the image stamp $imageStamp = new SetaPDF_Stamper_Stamp_Image($image); // set height (and width until no setWidth is set the ratio will retain) diff --git a/public/demos/6-Stamper/3-various/6-artifacts-stamp/script.php b/public/demos/6-Stamper/3-various/6-artifacts-stamp/script.php index d1cf439..ec81687 100644 --- a/public/demos/6-Stamper/3-various/6-artifacts-stamp/script.php +++ b/public/demos/6-Stamper/3-various/6-artifacts-stamp/script.php @@ -7,10 +7,10 @@ require_once __DIR__ . '/../../../../../classes/Stamper/Stamp/ArtifactTextStamp.php'; // create a HTTP writer -$writer = new SetaPDF_Core_Writer_Http('artifact.pdf', true); -//$writer = new SetaPDF_Core_Writer_File('artifact.pdf'); +$writer = new \SetaPDF_Core_Writer_Http('artifact.pdf', true); +//$writer = new \SetaPDF_Core_Writer_File('artifact.pdf'); // let's get the document -$document = SetaPDF_Core_Document::loadByFilename( +$document = \SetaPDF_Core_Document::loadByFilename( $assetsDirectory . '/pdfs/Brand-Guide.pdf', $writer ); @@ -21,7 +21,7 @@ //--- Create a text stamp and wrap it in a Tagged stamp instance ---// // create a font instance which is needed for the text stamp instance -$font = new SetaPDF_Core_Font_TrueType_Subset( +$font = new \SetaPDF_Core_Font_TrueType_Subset( $document, $assetsDirectory . '/fonts/DejaVu/ttf/DejaVuSans.ttf' );