Create a PDF portfolio (package) on Server/Desktop

To create a PDF portfolio containing multiple file types.

1func AddPackage(doc PDFDoc, file string, desc string){
2 files := NameTreeCreate(doc.GetSDFDoc(), "EmbeddedFiles")
3 fs := FileSpecCreate(doc.GetSDFDoc(), file, true)
4 key := make([]byte, len(file))
5 for i := 0; i < len(file); i++{
6 key[i] = file[i]
7 //fmt.Println(file[i])
8 }
9 files.Put(&key[0], len(key), fs.GetSDFObj())
10 fs.SetDesc(desc)
11
12 collection := doc.GetRoot().FindObj("Collection")
13 if collection.GetMp_obj().Swigcptr() == 0{
14 collection = doc.GetRoot().PutDict("Collection")
15 }
16
17 // You could here manipulate any entry in the Collection dictionary.
18 // For example, the following line sets the tile mode for initial view mode
19 // Please refer to section '2.3.5 Collections' in PDF Reference for details.
20 collection.PutName("View", "T");
21}
22doc := NewPDFDoc()
23AddPackage(doc, filename, "PDF")
24AddPackage(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