Rank: Member
Groups: Registered
Joined: 6/22/2022(UTC) Posts: 11  Location: Pennsylvania
|
When I open a PDF Portfolio in Acrobat, it is pretty clear from the portfolio menu what these are. Unfortunately, other viewers do not handle them.
In fact, they are not technically a PDF file even though they have the .pdf extension. How can I use PDFium SDK to quickly detect a portfolio without having to read the entire file?
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,140
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Hi! You can accurately and efficiently detect a PDF Portfolio by checking the document's root catalog for the /Collection dictionary. While Adobe uses the marketing term "PDF Portfolio" in Acrobat's user interface, the underlying ISO PDF Specification refers to this feature as Collections. According to the official PDF Specification, the document catalog dictionary uses the following trigger: Quote:Key: Collection Type: dictionary Value: (Optional; PDF 1.7) A collection dictionary that a PDF consumer uses to enhance the presentation of file attachments stored in the PDF document. When Adobe Acrobat creates a Portfolio, it injects this exact /Collection dictionary into the /Root object. This entry signals the viewer to switch from standard page rendering to an interactive, archive-like file manager user interface. (Note: If you need to support very old portfolios created in Adobe Acrobat 8, they used an earlier, deprecated implementation marked by the /Packages key, so it is a good practice to check for both). Since the cross-reference table (xref) allows to jump straight to the /Root object without parsing the entire file or downloading embedded streams, you can perform a lightweight check right after loading the document: Code:
using(var doc = PdfDocument.Load(@"e:\15\digitally_signed_3D_Portfolio.pdf"))
{
if(doc.Root.ContainsKey("Collection"))
{
Console.WriteLine("Adobe PDF Portfolio (Collection/Package) detected.");
}
}
Edited by user Tuesday, September 29, 2026 3:13:12 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close