Create a PDF portfolio (package) on Server/Desktop

To create a PDF portfolio containing multiple file types.

1def AddPackage(doc, file, desc):
2 files = NameTree.Create(doc.GetSDFDoc(), "EmbeddedFiles")
3 fs = FileSpec.Create(doc.GetSDFDoc(), file, True)
4 key = bytearray(file, "utf-8")
5 files.Put(key, len(key), fs.GetSDFObj())
6 fs.SetDesc(desc)
7
8 collection = doc.GetRoot().FindObj("Collection")
9 if collection is None:
10 collection = doc.GetRoot().PutDict("Collection")
11
12 # You could here manipulate any entry in the Collection dictionary.
13 # For example, the following line sets the tile mode for initial view mode
14 # Please refer to section '2.3.5 Collections' in PDF Reference for details.
15 collection.PutName("View", "T")
16doc = 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).

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales