Support
未讀,2008年11月26日 下午3:42:132008/11/26登入以回覆作者
登入以轉寄訊息
你的權限不足,無法在這個群組刪除訊息
登入以檢舉訊息
該群組的電子郵件地址為匿名,或你需要檢視成員電子郵件地址的權限才能查看原始貼文
收件者:PDFTron PDFNet SDK
Q: I would like to detect is a PDF document is a PDF Collection
(a.k.a. PDF Package) so that we can popup a warning to our users. At
this point, we don't necessarily need to open the PDF package files,
just to detect them. Could you point me to any relevant sample code?
----
A: You could use the following line to detect is a PDF document
contains a portable collection (i.e.PDF package)
Obj collection = doc.GetRoot().FindObj("Collection");
if (collection != NULL) {
// This 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.
#include <SDF/NameTree.h>
#include <Filters/FilterReader.h>
...
// C++ Pseudocode to traverse the list of embedded files
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(...);
}
}
}
}
You can also access content of 'Collection' dictionary to find more
info about the embedded files in the collection.