Create a PDF portfolio (package) on Server/Desktop

To create a PDF portfolio containing multiple file types.

1void addPackage(PDFDoc doc, String file, String desc) throws PDFNetException {
2 NameTree files = NameTree.create(doc.getSDFDoc(), "EmbeddedFiles");
3 FileSpec fs = FileSpec.create(doc, file, true);
4 files.put(file.getBytes(), fs.getSDFObj());
5 fs.getSDFObj().putText("Desc", desc);
6
7 Obj collection = doc.getRoot().findObj("Collection");
8 if (collection == null) collection = doc.getRoot().putDict("Collection");
9
10 // You could here manipulate any entry in the Collection dictionary.
11 // For example, the following line sets the tile mode for initial view mode
12 // Please refer to section '2.3.5 Collections' in PDF Reference for details.
13 collection.putName("View", "T");
14}
15PDFDoc doc = new PDFDoc();
16AddPackage(doc, filename, "PDF");
17AddPackage(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