Some test text!

menu
search
Create a packagekeyboard_arrow_down

Create a PDF portfolio (package)

To create a PDF portfolio containing multiple file types.

function AddPackage($doc, $file, $desc) 
{
    $files = NameTree::Create($doc->GetSDFDoc(), "EmbeddedFiles");
    $fs = FileSpec::Create($doc->GetSDFDoc(), $file, true);
    $files->Put($file, strlen($file), $fs->GetSDFObj());
    $fs->SetDesc($desc);

    $collection = $doc->GetRoot()->FindObj("Collection");
    if (!$collection) $collection = $doc->GetRoot()->PutDict("Collection");

    // You could here manipulate any entry in the Collection dictionary. 
    // For example, the following line sets the tile mode for initial view mode
    // Please refer to section '2.3.5 Collections' in PDF Reference for details.
    $collection->PutName("View", "T");
}
$doc = new PDFDoc();
AddPackage($doc, $filename, "PDF");
AddPackage($doc, $imagename, "Image");

PDF packages (portfolios)
Full code sample which illustrates how to create, extract, and manipulate PDF Packages (also known as PDF Portfolios).

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

PDFTron Receives USD$71 Million Growth Investment Led By Silversmith Capital Partners

Learn more
close