SetaPDF Demos

There seems to be a problem loading the components. Please check your PHP error logs for details!

Common issues could be that you missed to install the trial license or that you are using a trial version on an unsupported PHP version.

Repeat a Single Page

A simple demo showing how to repeat a page several times.

If the same page is merged from a single document instance (internally cached by the merger component) all pages will share the same objects. That means that changing e.g. the content (stream) of a page all other pages will be changed, too. This results in a very smal file size but can produce problems with PDF viewer or editor applications.

To ensure that all pages and objects are unique, you have to use a new document instance for each appended page.

PHP
<?php

// load and register the autoload function
require_once __DIR__ . '/../../../../../bootstrap.php';

$shareObjects = displaySelect('Share objects:', [1 => 'yes', 0 => 'no']);

// initiate a merger instance with an initial document
$merger = new \SetaPDF_Merger();

$path = $assetsDirectory . '/pdfs/camtown/Letterhead.pdf';
for ($i = 100; $i > 0; $i--) {
    if ($shareObjects) {
        $merger->addFile($path, 1);
    } else {
        // load the inital document
        $document = \SetaPDF_Core_Document::loadByFilename($path);
        $merger->addDocument($document, 1);
    }
}

// now merge the documents
$merger->merge();

$document = $merger->getDocument();
$document->setWriter(new \SetaPDF_Core_Writer_Http('repeated.pdf', true));

// save and finish the initial document
$document->save()->finish();