PDFPackage sorting


we try to use PDFNet SDK to create pdf packages. I followed your PDFPackage sample (http://www.pdftron.com/pdfnet/samplecode.html#PDFPackage) and it works as expected, but going through the Pdf specification today I have learned that the files in package are sorted alphabetically by default when opened in Adobe reader. However, we would like to have the files sorted in order of insertion (so the user can set their order). Is there any way to achieve this with PDFNet SDK, either by setting the custom sort rule or disabling the sorting completely (something like collection.PutName(“View”, “T”) used in your sample)? I have not been able to figure this out yet.


You can specify the sort order by adding a dictionary named “Sort” into the Collection dictionary, then adding a name with key “S” and value “Description”. See 8.2.4 Collections of the PDF reference for more information/options.

PDF Spec (seen via PDFTron WebViewer): http://xodo.com/view/#/573dd717-5eec-4dce-9476-7095179be37d

The actual entries to change/add are described in section 12.3.5 of the PDF specification (starting at the 378th page of the following document):


To view low-level document structure, use our CosEdit tool (https://www.pdftron.com/pdfcosedit/downloads.html; it’s free for file inspection).

Is there any way to change the layout of the portfolio? I’d like it be listed with thumbnails, instead of a list of file names.

The relevant value is the View entry of the collection dictionary (see table 155 of the PDF specification linked above). It sounds like you want this value to be “T” for tile display mode.

The sizes of the listed PDFs are always zero. How can we have this be the actual size of the PDF instead?

The relevant value is the Size field of the Subtype dictionary under the collection field dictionary (see table 157 of the PDF specification linked above). If you set this value, the size should appear correctly in Acrobat.