SetaPDF Demos

Check for Collection

Checks whether a PDF document is a Collection (aka PDF Portfolio or PDF Package).

PHP
<?php

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

// prepare some files
$files = [
    $assetsDirectory . '/pdfs/tektown/products/All.pdf',
    $assetsDirectory . '/pdfs/tektown/products/All-Collection.pdf',
    $assetsDirectory . '/pdfs/tektown/products/All-Portfolio.pdf',
];

$path = displayFiles($files);

// create a document
$document = SetaPDF_Core_Document::loadByFilename($path);

$catalog = $document->getCatalog();
$dictionary = $catalog->getDictionary();
if ($dictionary && $dictionary->offsetExists('Collection')) {
    echo 'This document IS a portable collection.';
} else {
    echo 'This document is NOT a portable collection.';
}