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");