Using the answers in How to merge PDFs into a PDF Portfolio?, I’ve been able to create an PDF portfolio using iTextSharp. However, using Adobe Acrobat I’m able to create folders, and I’m able to put files in those folders.
How do I create folders and how do I put files in those folders in a PDF portfolio using iTextSharp?
I’ve tried using a pdf inspector program to see the differences between a portfolio with and without folders, but I haven’t been able to see any. I guess I’m looking in the wrong places
EDIT
For this specific use case of mine it is actually possible to create the PDF portfolio with folder up front. So it’s way more important to be able to insert files in folders in an existing PDF portfolio as opposed to actually creating the folders themselves.
Here is some proof of concept code that creates a new portfolio pdf with couple of folders and inserts an existing pdf file into each of those folders. This approach is based on using a text editor to look at a pdf file created using the sample code linked to in the original post, then using Acrobat to create a folder and move the embedded file into that folder, saving the pdf, then looking at the changes with a text editor. In the code I’m recreating the changes found while comparing the two versions of the portfolio pdf, so while it works (at least on my machine), it may not be the best way to accomplish the task.
If you want to view the before/after files like I did, create the portfolio using iTextsharp, then open with Acrobat and create a folder and move the embedded file(s) into the folder, then just save the file again using the save icon on the toolbar. Do not use the File -> Save As… option to save the file as a Portfolio PDF. Acrobat reorganizes the file and compresses or in some other way converts a lot of the file to binary data that you won’t be able read in a text editor. I found that deleting the binary stream data made the structure much easier to follow. Just get rid of everything between each pair of
stream/endstreamkeywords.One thing that Acrobat does in portfolio pdfs is embed a flash file that provides animation and a more attractive theme for the portfolio. I wasn’t able to figure out how to do that, so the resulting file from this code is a bit plain looking.