Q: Does PDFNet SDK provide support for PDF V9 Portfolios?
-----
A: You can use PDFNet’s SDF/Cos API to work with PDF Portfolios (this
feature was also available in PDF 1.7 under the name "PDF package" but
was not properly implemented in Acrobat).
As an example, you could use the following lines to detect is a PDF
document contains a portable collection (a.k.a. PDF package, or PDF
portfolio)
Obj collection = doc.GetRoot().FindObj("Collection");
if (collection != NULL) {
// The PDF contains a collection.
}
When a PDF viewer first opens a PDF document containing a collection,
it should display the contents of the initial document, along with a
list of the documents present in the "EmbeddedFiles" name tree.
// C# Pseudocode to list parts or extract parts of a PDF package
(a.k.a. PDF Portfolio)
pdftron.SDF.NameTree files = NameTree.Find(doc.GetSDFDoc(),
"EmbeddedFiles");
if(files.IsValid()) { // Traverse the list of embedded files.
for (DictIterator i = files.GetIterator(); i.HasNext(); i.Next()) {
string entry_name = i.Key().GetAsPDFText();
if (extract_emebdded_files) {
FileSpec file_spec = new FileSpec(i.Value());
Filter stm = file_spec.GetFileData();
if (stm!=null) {
FilterReader reader = new FilterReader(stm);
reader.Read(...);
}
}
}
}
// C++ Pseudocode
#include <SDF/NameTree.h>
...
pdftron::SDF::NameTree files = NameTree::Find(*doc.GetSDFDoc(),
"EmbeddedFiles");
if(files.IsValid()) { // Traverse the list of embedded files.
for (DictIterator i = files.GetIterator(); i.HasNext(); i.Next()) {
UString entry_name;
i.Key().GetAsPDFText(entry_name);
if (extract_emebdded_files) {
FileSpec file_spec(i.Value());
AutoPtr<Filter> stm = file_spec.GetFileData();
if (stm.get()) {
FilterReader reader(*stm);
Reader.Read(...);
}
}
}
}
Similarly you can use SDF/Cos API to edit or create new PDF package/
portfolio entries. To make some package operations a bit more
intuitive we will introduce a small high-level API in the near future.