void linkLayer::loadFromDoc(PoDoFo::PdfMemDocument* doc) { qDebug() << "linkLayer: Loading named destinations ..."; try { PoDoFo::PdfNamesTree* pNames = doc->GetNamesTree( PoDoFo::ePdfDontCreateObject ); if( ! pNames ) return; PoDoFo::PdfDictionary destsDict; pNames->ToDictionary( PoDoFo::PdfName("Dests"), destsDict ); PoDoFo::TKeyMap keyMap = destsDict.GetKeys(); QString tName; PoDoFo::PdfDestination *dest; PoDoFo::PdfObject *obj; for(PoDoFo::TKeyMap::const_iterator it = keyMap.begin(); it != keyMap.end(); ++it ) { try { tName = QString::fromUtf8( it->first.GetName().c_str() ); qDebug() << "Processing "<< tName; obj = pdfUtil::resolveRefs( doc, it->second ); if ( obj->IsArray() ) dest = new PoDoFo::PdfDestination( obj ); else if ( obj->IsDictionary() ) { obj->GetDictionary().GetKey("D")->SetOwner( &doc->GetObjects() ); dest = new PoDoFo::PdfDestination( obj->GetDictionary().GetKey("D") ); } else { qDebug() << "Element is neither an array, nor a dictionary:"<< obj->GetDataTypeString(); continue; } addTarget( tName, dest ); } catch ( PoDoFo::PdfError e ) { qDebug() << "linkLayer: Error adding named destination ("<<tName<<"):"<<e.what(); } } } catch ( PoDoFo::PdfError e ) { qDebug() << "linkLayer: Error processing names tree:" << e.what(); }; qDebug() << "linkLayer: Done loading named destinations."; }
std::ostream& ossimGeoPdfInfo::print(std::ostream& out) const { static const char MODULE[] = "ossimGeoPdfInfo::print"; int count = m_PdfMemDocument->GetPageCount(); PoDoFo::PdfString author = m_PdfMemDocument->GetInfo()->GetAuthor(); PoDoFo::PdfString creator = m_PdfMemDocument->GetInfo()->GetCreator(); PoDoFo::PdfString title = m_PdfMemDocument->GetInfo()->GetTitle(); PoDoFo::PdfString subject = m_PdfMemDocument->GetInfo()->GetSubject(); PoDoFo::PdfString keywords = m_PdfMemDocument->GetInfo()->GetKeywords(); PoDoFo::PdfString producer = m_PdfMemDocument->GetInfo()->GetProducer(); ossimString createDate; ossimString modifyDate; PoDoFo::PdfObject* obj = m_PdfMemDocument->GetInfo()->GetObject(); if (obj->IsDictionary()) { PoDoFo::PdfDictionary pdfDictionary = obj->GetDictionary(); PoDoFo::TKeyMap keyMap = pdfDictionary.GetKeys(); PoDoFo::TKeyMap::iterator it = keyMap.begin(); while (it != keyMap.end()) { ossimString refName = ossimString(it->first.GetName()); PoDoFo::PdfObject* refObj = it->second; std::string objStr; refObj->ToString(objStr); if (refName == "CreationDate") { createDate = ossimString(objStr); createDate = createDate.substitute("(", "", true).trim(); createDate = createDate.substitute(")", "", true).trim(); createDate = createDate.substitute("D:", "", true).trim(); } else if (refName == "ModDate") { modifyDate = ossimString(objStr); modifyDate = modifyDate.substitute("(", "", true).trim(); modifyDate = modifyDate.substitute(")", "", true).trim(); modifyDate = modifyDate.substitute("D:", "", true).trim(); } it++; } } try { m_PdfMemDocument->FreeObjectMemory(obj); } catch (...) { } ossimString authorStr = author.GetString(); ossimString creatorStr = creator.GetString(); ossimString titleStr = title.GetString(); ossimString producerStr = producer.GetString(); ossimString subjectStr = subject.GetString(); ossimString keywordsStr = keywords.GetString(); ossimString prefix = "geopdf."; out << prefix << "pagecount: " << ossimString::toString(count).c_str() << "\n"; if (!authorStr.empty()) { out << prefix << "author: " << authorStr.c_str() << "\n"; } if (!creatorStr.empty()) { out << prefix << "creator: " << creatorStr.c_str() << "\n"; } if (!titleStr.empty()) { out << prefix << "title: " << titleStr.c_str() << "\n"; } if (!producerStr.empty()) { out << prefix << "producer: " << producerStr.c_str() << "\n"; } if (!subjectStr.empty()) { out << prefix << "subject: " << subjectStr.c_str() << "\n"; } if (!keywordsStr.empty()) { out << prefix << "keywords: " << keywordsStr.c_str() << "\n"; } if (!createDate.empty()) { out << prefix << "creationdate: " << createDate.c_str() << "\n"; } if (!modifyDate.empty()) { out << prefix << "modificationdate: " << modifyDate.c_str() << "\n"; } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " DEBUG Entered...\n"; } return out; }