Page 1 of 1

Unable to read \Annots to get file attachment from page

Posted: Wed Jul 27, 2016 1:47 pm
by truane
I'm using C#

Ok so i have used the low level API to navigate all the way down to /Annots on the page without any issue and get

Dictionary (7061184) \Pages\Kids[3]\Kids[7] :- Type(PVT_NAME = 'Page' ), Annots(PVT_OBJREF = 'Is Dictionary' ), Parent(PVT_OBJREF = 'Is Dictionary' ), Rotate(PVT_INT = '0' ), CropBox(PVT_ARRAY), Contents(PVT_OBJREF = 'Is Dictionary' ), MediaBox(PVT_ARRAY), Resources(PVT_OBJREF = 'Is Dictionary' )

then using the Annots as the variant

XcPro40Defs.DPDFVariant_Type nefvType;
result =XcPro40Defs.PXCp_VariantGetType(variant, out nefvType);

if (nefvType.Equals(XcPro40Defs.DPDFVariant_Type.PVT_OBJREF)){
int pxcObject;
int subDictionary;
result = XcPro40Defs.PXCp_VariantGetObject(variant, out pxcObject);
result = XcPro40Defs.PXCp_ObjectGetDictionary(pxcObject, out subDictionary); <--- This returns 0 for sub directory?
}

the PXCp_VariantGetObject returns a result of 0 and the pxcObject = 511035452
but PXCp_ObjectGetDictionary returns a result of 0 which is success but the subDictionary= 0

I am using xcpro40.dll version 4.0.316.1 from release Version 5.5.315.0 of PDF-XChange PRO SDK

This only happens to the /Annots Dictionary on the page every other Dictionary works fine can tacker not deal with /annots.

The ultimate goal is to get to the /FS underneath it to extract the file stream.

Please Can You help!

Re: Unable to read \Annots to get file attachment from page

Posted: Thu Jul 28, 2016 11:13 am
by Lzcat - Tracker Supp
Hi.
You should take a closer look at PDF specification when using low-level API - Annots is array, not dictionary.
HTH.

Re: Unable to read \Annots to get file attachment from page

Posted: Thu Jul 28, 2016 11:44 am
by truane
i would agree but tracker says it is object

result =XcPro40Defs.PXCp_VariantGetType(variant, out nefvType);

nefvType = PVT_OBJREF not PVT_ARRAY

so have to do XcPro40Defs.PXCp_VariantGetObject(variant, out pxcObject);

and there is no PXCp_ObjectGetArray(pxcObject, out array);
only PXCp_ObjectGetDictionary or PXCp_ObjectGetStream

I even tried result = XcPro40Defs.PXCp_VariantGetArray(variant, out pxcArray); but this throws and error

Re: Unable to read \Annots to get file attachment from page

Posted: Thu Jul 28, 2016 1:57 pm
by Lzcat - Tracker Supp
truane wrote:i would agree but tracker says it is object

result =XcPro40Defs.PXCp_VariantGetType(variant, out nefvType);

nefvType = PVT_OBJREF not PVT_ARRAY
Sure, because in your case Annots array is indirect variant.
truane wrote:so have to do XcPro40Defs.PXCp_VariantGetObject(variant, out pxcObject);

and there is no PXCp_ObjectGetArray(pxcObject, out array);
only PXCp_ObjectGetDictionary or PXCp_ObjectGetStream

I even tried result = XcPro40Defs.PXCp_VariantGetArray(variant, out pxcArray); but this throws and error
But you missed function PXCp_ObjectGetBody, so correct sequence for indirect array is PXCp_VariantGetObject > PXCp_ObjectGetBody > PXCp_VariantGetArray.

Re: Unable to read \Annots to get file attachment from page

Posted: Thu Jul 28, 2016 2:05 pm
by truane
Yes after my last message I went back to documentation and noticed PXCp_ObjectGetBody tired it and it works.

if PXCp_ObjectGetDictionary returns 0 for dictionary ref then call PXCp_ObjectGetBody?

Sorry for wasting your time I got so involved in implementing i didn't have time to write back and tell you i found it :roll:

Re: Unable to read \Annots to get file attachment from page

Posted: Thu Jul 28, 2016 3:52 pm
by Lzcat - Tracker Supp
truane wrote:if PXCp_ObjectGetDictionary returns 0 for dictionary ref then call PXCp_ObjectGetBody?
You asking why PXCp_ObjectGetDictionary return 0 when object does not contain dictionary? It was not good design in old SDK which is no longer developed, so this behavior will be not changed. But you always can use PXCp_ObjectGetBody and then PXCp_VariantGetType to check what is in object.
HTH.