Create a PDF portfolio (package) in PHP

To create a PDF portfolio containing multiple file types.

1function AddPackage($doc, $file, $desc)
2{
3 $files = NameTree::Create($doc->GetSDFDoc(), "EmbeddedFiles");
4 $fs = FileSpec::Create($doc->GetSDFDoc(), $file, true);
5 $files->Put($file, strlen($file), $fs->GetSDFObj());
6 $fs->SetDesc($desc);
7
8 $collection = $doc->GetRoot()->FindObj("Collection");
9 if (!$collection) $collection = $doc->GetRoot()->PutDict("Collection");
10
11 // You could here manipulate any entry in the Collection dictionary.
12 // For example, the following line sets the tile mode for initial view mode
13 // Please refer to section '2.3.5 Collections' in PDF Reference for details.
14 $collection->PutName("View", "T");
15}
16$doc = new PDFDoc();
17AddPackage($doc, $filename, "PDF");
18AddPackage($doc, $imagename, "Image");

PDF packages (portfolios)
Full code sample which illustrates how to create, extract, and manipulate PDF Packages (also known as PDF Portfolios). Code sample is available in C++, C#, Java, Python, Go, PHP, Ruby & VB.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales