Re: [Podofo-users] Difference between PdfObject::GetReference() and PdfObject::Reference()

2018-01-16 Thread Georg Funk
Thanks Dimitry,
for this hint!

Regards,
Georg

Am 13.01.2018 um 13:25 schrieb Dmitry Salychev 
>:

Hi, Georg.

I'm not a developer of PoDoFo and don't know any details lying deep there.
You may just take a look at the src/base/PdfObject.h and
src/base/PdfVariant.h to understand the difference between these two
functions:

inline const PdfReference & Reference() const;
inline const PdfReference & GetReference() const;

and their implementations:

const PdfReference & PdfObject::Reference() const
{
return m_reference;
}

const PdfReference & PdfVariant::GetReference() const
{
DelayedLoad();

if( !IsReference() )
{
PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
}

// Do not change this to an reinterpret_cast
// We need a c-style casts here to avoid crashes
// because a reinterpret_cast might point to a different position.
return *((PdfReference*)m_Data.pData);
}

Personally, I didn't have a need to find object by its object and generation
numbers, but I had to obtain 'em from an existing one. There is a chance that
this piece of code to get a specific XObject by its name will be useful:

PdfObject *xobj;
int nobj, ngen;

xobj = get_xobject(_name, (PdfCanvas *)page);
/* Is object a reference? */
if (xobj->IsReference())
xobj = doc->GetObjects().GetObject(xobj->GetReference());
ngen = xobj->Reference().GenerationNumber();
nobj = xobj->Reference().ObjectNumber();
/* ... */

static PdfObject *get_xobject(PdfName *xobjname, PdfCanvas *pPage)
{
PdfObject *pResources = pPage->GetResources();
PdfObject *xobj_dict;

if (pResources != NULL &&
pResources->GetDictionary().HasKey(PdfName("XObject"))) {
xobj_dict = pResources->GetIndirectKey(PdfName("XObject"));
if (xobj_dict != NULL && xobj_dict->IsDictionary()) {
return xobj_dict->GetIndirectKey(*xobjname);
}
}
return NULL;
}


Regards,

- Dmitry

On Fri, Jan 12, 2018 at 10:35 PM, Georg Funk 
> wrote:
Dear podofo-developers,

could you please describe the difference between PdfObject::GetReference() and 
PdfObject::Reference()?
I need a way to access PdfObjects from within a PfVecObjects vector by their 
object and generation number. Further I need a function to follow indirect 
references of an object.
Can I use the above mentioned methods for these purposes?

Thank you in advance!

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

--
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] Difference between PdfObject::GetReference() and PdfObject::Reference()

2018-01-16 Thread Dmitry Salychev
Georg,

no problem (: It's nice that this code helped.

Regards,

- Dmitry
--
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] Difference between PdfObject::GetReference() and PdfObject::Reference()

2018-01-13 Thread Dmitry Salychev
Hi, Georg.

I'm not a developer of PoDoFo and don't know any details lying deep there.
You may just take a look at the src/base/PdfObject.h and
src/base/PdfVariant.h to understand the difference between these two
functions:

inline const PdfReference & Reference() const;
inline const PdfReference & GetReference() const;

and their implementations:

const PdfReference & PdfObject::Reference() const
{
return m_reference;
}

const PdfReference & PdfVariant::GetReference() const
{
DelayedLoad();

if( !IsReference() )
{
PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
}

// Do not change this to an reinterpret_cast
// We need a c-style casts here to avoid crashes
// because a reinterpret_cast might point to a different position.
return *((PdfReference*)m_Data.pData);
}

Personally, I didn't have a need to find object by its object and generation
numbers, but I had to obtain 'em from an existing one. There is a chance
that
this piece of code to get a specific XObject by its name will be useful:

PdfObject *xobj;
int nobj, ngen;

xobj = get_xobject(_name, (PdfCanvas *)page);
/* Is object a reference? */
if (xobj->IsReference())
xobj = doc->GetObjects().GetObject(xobj->GetReference());
ngen = xobj->Reference().GenerationNumber();
nobj = xobj->Reference().ObjectNumber();
/* ... */

static PdfObject *get_xobject(PdfName *xobjname, PdfCanvas *pPage)
{
PdfObject *pResources = pPage->GetResources();
PdfObject *xobj_dict;

if (pResources != NULL &&
pResources->GetDictionary().HasKey(PdfName("XObject"))) {
xobj_dict = pResources->GetIndirectKey(PdfName("XObject"));
if (xobj_dict != NULL && xobj_dict->IsDictionary()) {
return xobj_dict->GetIndirectKey(*xobjname);
}
}
return NULL;
}


Regards,

- Dmitry

On Fri, Jan 12, 2018 at 10:35 PM, Georg Funk  wrote:

> Dear podofo-developers,
>
> could you please describe the difference between PdfObject::GetReference()
> and PdfObject::Reference()?
> I need a way to access PdfObjects from within a PfVecObjects vector by
> their object and generation number. Further I need a function to follow
> indirect references of an object.
> Can I use the above mentioned methods for these purposes?
>
> Thank you in advance!
>
> 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
>
--
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


[Podofo-users] Difference between PdfObject::GetReference() and PdfObject::Reference()

2018-01-12 Thread Georg Funk
Dear podofo-developers,

could you please describe the difference between PdfObject::GetReference() and 
PdfObject::Reference()?
I need a way to access PdfObjects from within a PfVecObjects vector by their 
object and generation number. Further I need a function to follow indirect 
references of an object.
Can I use the above mentioned methods for these purposes?

Thank you in advance!

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