Hi!
Am Montag, den 14.05.2018, 09:06 +0200 schrieb zyx:
>
> There are quite few things you can do wrong, but you didn't give
> enough
> information to point to an exact place.
>
> Eventually see PdfObject::GetIndirectKey(), it does something similar
> what you want to achieve and it surely works.
> Bye,
> zyx
>
I now start from the root-Dictionary object for building up the tree,
and PdfObject::GetIndirectKey() seems to work quite well. But I think
I'm getting to few objects into the tree. Could you take a look at my
code?
Thanke you very much!
Georg
namespace {
PoDoFo::PdfMemDocument *memDocument;
PoDoFo::PdfObject *rootObject;
Glib::NodeTree<ObjectNode *> *tree;
PoDoFo::PdfVecObjects objectVector;
}
ObjectNode::ObjectNode(const PoDoFo::PdfObject& currentReference,
ObjectNode *parentObject,
PoDoFo::PdfName dictObjectName)
: currentReference(currentReference),
parentObject(parentObject),
dictObjectName(dictObjectName) {
appendToParent();
generateChildNode();
};
// resolve Childs and build new objectNode from it
void ObjectNode::generateChildNode() {
std::cout << getCurrentReference().GetDataTypeString() <<
std::endl;
while (getCurrentReference().
GetIndirectKey(dictObjectName) != nullptr) {
setCurrentReference(*getCurrentReference().
GetIndirectKey(dictObjectName)); }
if (currentReference.IsArray()) {
PoDoFo::PdfArray& tempArray = currentReference.GetArray();
for (const PoDoFo::PdfObject item : tempArray) {
new ObjectNode(item.Reference(), this);
}
}
if (currentReference.IsDictionary()) {
PoDoFo::TKeyMap tempMap =
currentReference.GetDictionary().GetKeys();
for (const auto& item : tempMap) {
new ObjectNode(*item.second, this, item.first);
}
}
}
void ObjectNode::appendToParent() {
int parentPosition = tree->child_index(getParentObject());
tree->insert_data(parentPosition, this);}
ObjectNode* ObjectNode::getParentObject() const {
return parentObject;
}
void ObjectNode::setParentObject(ObjectNode *parentObject) {
ObjectNode::parentObject = parentObject;
}
const PoDoFo::PdfObject &ObjectNode::getCurrentReference() const {
return currentReference;
}
void ObjectNode::setCurrentReference(const PoDoFo::PdfObject
¤tReference) {
ObjectNode::currentReference = currentReference;
};
DocumentModel::DocumentModel(const char* filename) {
::memDocument = new PoDoFo::PdfMemDocument(filename);
::tree = new Glib::NodeTree<ObjectNode *>;
::objectVector = ::memDocument->GetObjects();
::rootObject = ::memDocument->GetCatalog();
new ObjectNode(*rootObject);
}
> -------------------------------------------------------------------
> -----------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Podofo-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/podofo-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users