Re: [Podofo-users] Getting Segmentation fault when ttrying to access PdfVecObjects

2018-05-21 Thread zyx
On Mon, 2018-05-21 at 08:11 +, Georg Funk wrote:
> I'm trying to build up a tree of all objects and want to walk them
> afterwards to convert the document in epub format.

Hi,
you might need to know what each dictionary servers to, because each of
them references its dependencies differently, not talking about content
streams, which have the references (partly) inside the stream itself.

I mean, to have it done you should read the PDF standard and do the
object searching according to it, while some of the references can be
references to real objects, some can be stored "inline". That is to
construct a real "tree" (some objects like fonts can (and should) be
reused, not talking about XObject-s), you need to know the PDF data
structure very well.
Bye,
zyx

--
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
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users


Re: [Podofo-users] Getting Segmentation fault when ttrying to access PdfVecObjects

2018-05-21 Thread Georg Funk
Hi!
Am Montag, den 21.05.2018, 09:19 +0200 schrieb zyx:
> 
>   Hi,
> what are you trying to achieve exactly, please?

I'm trying to build up a tree of all objects and want to walk them
afterwards to convert the document in epub format.

Best regards,
Georg
--
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
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users


Re: [Podofo-users] Getting Segmentation fault when ttrying to access PdfVecObjects

2018-05-21 Thread zyx
On Sat, 2018-05-19 at 17:30 +, Georg Funk wrote:
> 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.

Hi,
what are you trying to achieve exactly, please?
Bye,
zyx

--
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
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users


Re: [Podofo-users] Getting Segmentation fault when ttrying to access PdfVecObjects

2018-05-19 Thread Georg Funk
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 *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 ::getCurrentReference() const {
return currentReference;
}

void ObjectNode::setCurrentReference(const PoDoFo::PdfObject
) {
ObjectNode::currentReference = currentReference;
};

DocumentModel::DocumentModel(const char* filename) {

::memDocument = new PoDoFo::PdfMemDocument(filename);
::tree = new Glib::NodeTree;
::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
> Podofo-users@lists.sourceforge.net
> 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
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users


Re: [Podofo-users] Getting Segmentation fault when ttrying to access PdfVecObjects

2018-05-14 Thread zyx
On Fri, 2018-05-11 at 16:24 +, Georg Funk wrote:
> 723 0 R Current Reference
> 
> The failing step seems to be the check of IsReference().

Hi,
does 723 0 object exist in your PDF document at all? Everything points
to it does not exist. There is really nothing to fail (or better crash)
in IsReference() when it's called on a valid (non-NULL) object.

Could you verify that objectVector.GetObject(currentReference) returns
non-NULL object, please?

You also wrote that the objectVector is some global variable. How is it
set? What if you use PdfDocument::GetObjects() instead (which returns a
pointer, not a reference), thus something like this:

   PdfObject *function (PdfDocument , const PdfReference & ref)
   {
   return doc.GetObjects()->GetObject(ref);
   }

Is the associated PdfDocument still valid, when you are at this place
in the code?

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

--
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
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users


Re: [Podofo-users] Getting Segmentation fault when ttrying to access PdfVecObjects

2018-05-11 Thread Georg Funk
Hi,

i printed out currentReference before the following section is called.

if (objectVector.GetObject(currentReference)->IsReference()) {
   currentReference = objectVector.
GetObject(currentReference)->GetReference(); }

Output:

723 0 R Current Reference

The failing step seems to be the check of IsReference().

Regards,
Georg

Am Donnerstag, den 10.05.2018, 17:42 +0200 schrieb Joerg Sonnenberger:
> On Thu, May 10, 2018 at 02:14:18PM +, Georg Funk wrote:
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x55ba2342486e in PoDoFo::PdfVariant::DelayedLoad (this=0x0) at
> > /usr/local/include/podofo/base/PdfVariant.h:545
> > 545 if( !m_bDelayedLoadDone)
> > 
> > Have you any idea for me?
> 
> Your reference goes to a null pointer. Look at the "this" above.
> 
> Joerg
--
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
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users


Re: [Podofo-users] Getting Segmentation fault when ttrying to access PdfVecObjects

2018-05-10 Thread Georg Funk
Hi Joerg,

thanks for this hint.

I thought maybe I'am misusing PdfObject::Reference() and
PdfObject::GetReference() in my code This could explain the null
pointer.

I want to get a objects Reference number by calling
PdfObject::Reference() and get a pointer to a eventually existing
indirect object by calling PdfObject::GetReference().

Is this the correct use case?

Thanks in advance!

Georg 


Am Donnerstag, den 10.05.2018, 17:42 +0200 schrieb Joerg Sonnenberger:
> On Thu, May 10, 2018 at 02:14:18PM +, Georg Funk wrote:
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x55ba2342486e in PoDoFo::PdfVariant::DelayedLoad (this=0x0) at
> > /usr/local/include/podofo/base/PdfVariant.h:545
> > 545 if( !m_bDelayedLoadDone)
> > 
> > Have you any idea for me?
> 
> Your reference goes to a null pointer. Look at the "this" above.
> 
> Joerg
--
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
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users


Re: [Podofo-users] Getting Segmentation fault when ttrying to access PdfVecObjects

2018-05-10 Thread Georg Funk
Hi,

Am Donnerstag, den 10.05.2018, 18:09 +0200 schrieb zyx:
> On Thu, 2018-05-10 at 14:14 +, Georg Funk wrote:
> > Have you any idea for me?
> 
>   Hi,
> what is your exact version of PoDoFo, please? Do your sources include
> https://sourceforge.net/p/podofo/code/1825 ?
> 

I am using 0.9.6-rc1.
The patch is included.

Thanks,
Georg
--
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
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users


Re: [Podofo-users] Getting Segmentation fault when ttrying to access PdfVecObjects

2018-05-10 Thread zyx
On Thu, 2018-05-10 at 14:14 +, Georg Funk wrote:
> Have you any idea for me?

Hi,
what is your exact version of PoDoFo, please? Do your sources include
https://sourceforge.net/p/podofo/code/1825 ?

I do not know whether it's related to your crash, but it sounds quite
similar.
Bye,
zyx

--
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
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users


Re: [Podofo-users] Getting Segmentation fault when ttrying to access PdfVecObjects

2018-05-10 Thread Joerg Sonnenberger
On Thu, May 10, 2018 at 02:14:18PM +, Georg Funk wrote:
> Program received signal SIGSEGV, Segmentation fault.
> 0x55ba2342486e in PoDoFo::PdfVariant::DelayedLoad (this=0x0) at
> /usr/local/include/podofo/base/PdfVariant.h:545
> 545   if( !m_bDelayedLoadDone)
> 
> Have you any idea for me?

Your reference goes to a null pointer. Look at the "this" above.

Joerg

--
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
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users