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.

Encrypt Resulting PDF

This demo shows you how to encrypt the merged result with a password.

Owner password is the-owner-password and the user password is the-user-password.

PHP
<?php

use setasign\SetaPDF2\Core\SecHandler\SecHandler;
use setasign\SetaPDF2\Core\SecHandler\Standard\Aes256;
use setasign\SetaPDF2\Core\Writer\HttpWriter;
use setasign\SetaPDF2\Merger\Merger;

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

// simple merge process
$merger = new Merger();
$merger->addFile($assetsDirectory . '/pdfs/tektown/eBook-Invoice.pdf');
$merger->addFile($assetsDirectory . '/pdfs/tektown/Terms-and-Conditions.pdf');
$merger->merge();

$document = $merger->getDocument();

/* define a handler with an owner and a user password, allow print and
 * copy (for the user - need to be respected by the viewer application)
 * and do not encrypt metadata.
 */
$secHandler = Aes256::create(
    $document,
    'the-owner-password',
    'the-user-password',
    SecHandler::PERM_PRINT | SecHandler::PERM_COPY,
    false
);

// attach the handler to the document instance
$document->setSecHandler($secHandler);

$document->setWriter(new HttpWriter('encrypted.pdf', true));
$document->save()->finish();