Re: [Podofo-users] How to extract embedded file from pdf

2018-01-01 Thread Matthew Brincke
Hello all,

I'm forwarding this e-mail exchange for the list's and the public's
benefit. It began with a response to the e-mail I'm replying to here.
I'm sorry to do this only now as I originally tried it (hopefully
only less than a minute) too late to be archived in December 2017,
but with a typo in the address: podofo-users AT list.sourceforge.net

Best regards, mabri

-- Original message --
From: David Swank <dsw...@tslusa.biz>
To: Matthew Brincke <ma...@mailbox.org>
Date: Sat, 30 Dec 2017 07:19:17 -0500
Subject: Re: [Podofo-users] How to extract embedded file from pdf

Setting -DPODOFO_BUILD_SHARED:BOOL=TRUE did the trick with r1863
Thank You very much.


On 12/29/2017 6:37 PM, Matthew Brincke wrote:
> Hallo David Swank,
>
>> David Swank <dsw...@tslusa.biz> has written on 29 December 2017 at 20:30:
>>
>>
>> Thanks for the reply,  but I still have the same issue.
>> On building podofo from current trunk r1863, I did get warning during
>> build.  And only got a libpodofo.a  No .dll or dll.a.
>> then rebuilt r1810 with no warnings an did get all 3 src\ files. with
>> the result is the same as before.
>>
> so you didn't test with svn r1863 (please see below for .dll building,
> the .a file is a static library in GCC format, maybe you could use it)?
> The regression was introduced in svn r1810 (so r1809 was the last "good"
> one before it), fixed in svn 1825, the next revision removes forcing
> the build to the C++98 standard, i.e. the compiler default is used then.
>
> Warning: this can change the ABI too: If you build your project using a
> newer standard (e.g. C++11) please only use PoDoFo from svn r1826 on
> because older ones can be ABI-incompatible because of this alone.
>
> In svn r1815 a change was made which (should have) changed build to
> default to building a shared library (.dll file) on Win32, to explicitly
> specify that (are you building for or on 64-bit Windows?) give the
> option -DPODOFO_BUILD_SHARED:BOOL=TRUE to cmake (as first option).
>
> The warnings (I'm guessing here, as I don't have your environment and so
> can't reproduce them) should be mostly harmless, so please either ignore
> them, use one of the revisions I gave above (which shouldn't have added
> any), or copy them as text with line-breaks preserved into your reply
> (especially if building one of the older revisions, so I can help you
> better, I hope). In any case, do specify the revision you used, any other
> options to cmake, relevant environment variables, whether you used the
> mingw-w64 environment, and its exact version (I couldn't find "7.2.0",
> only as GCC version), also for the (original) MinGW if you use that.
> Please do report your results, also if you succeeded (please spare me
> from fearing you failed without reporting).
> Please also mention if the e-mail is indeed confidential, or if you
> explicitly (are allowed to, and) lift that restriction from the footer.
> Then I'd remove the footer and forward to the mailing list (please
> don't do that yourself just yet).
>   
> Best regards, Matthew

> Matthew Brincke <ma...@mailbox.org> has written on 29 December 2017 at 01:00:
> 
> 
> Hello David, hello all,
> 
> > David Swank <dsw...@tslusa.biz> has written on 27 Dezember 2017 at 22:47: 
> >  
> >  Environment Msys on Win7.  Qt 5.9.2, MinGw 7.2.0, PoDoFo .0.9.5.0 
> >  I am able to Attach my csv files into a pdf just fine. 
> >  Now I am attempting to retrieve the attachments so that i can parse the 
> > csv file data to be read by some other another pc. 
> >  
> >  I have been playing with a example from 2013 referenced here 
> > https://www.mail-archive.com/podofo-users@lists.sourceforge.net/msg02174.html
> >  
> >  
> >  The code will crash at kidskey->GetArray. 
> >  when stepping through the code i found that kidskey->GetDataTypeString() 
> > returns array but kidskey->IsArray returns false. 
> 
> I'm sorry that your build is affected by it: there is an ABI regression in 
> libpodofo 0.9.5 (from
> svn r1810) so please update to current svn trunk.
> 
> Best regards, mabri
> 
> >  
> >  Any assistance would be appreciated, 
> >  Thank You 
> >  
> > 
> > -- 
> > David

--
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] How to extract embedded file from pdf

2017-12-28 Thread Matthew Brincke
Hello David, hello all,

> David Swank  has written on 27 Dezember 2017 at 22:47: 
>  
>  Environment Msys on Win7.  Qt 5.9.2, MinGw 7.2.0, PoDoFo .0.9.5.0 
>  I am able to Attach my csv files into a pdf just fine. 
>  Now I am attempting to retrieve the attachments so that i can parse the csv 
> file data to be read by some other another pc. 
>  
>  I have been playing with a example from 2013 referenced here 
> https://www.mail-archive.com/podofo-users@lists.sourceforge.net/msg02174.html 
>  
>  The code will crash at kidskey->GetArray. 
>  when stepping through the code i found that kidskey->GetDataTypeString() 
> returns array but kidskey->IsArray returns false. 

I'm sorry that your build is affected by it: there is an ABI regression in 
libpodofo 0.9.5 (from
svn r1810) so please update to current svn trunk.

Best regards, mabri

>  
>  Any assistance would be appreciated, 
>  Thank You 
>  
> 
> -- 
> David
> 
>

--
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] How to extract embedded file from pdf?

2013-09-22 Thread zyx
Dne 19.9.2013 10:19, Sebastian Haag napsal(a):
 I managed to embed a file (or file content/string) into a 
 PdfMemDocument. Now I want to extract it again and don´t find a way...
 Hi,
it's tricky, or slightly complicated. I do it through traversing the 
actual object hierarchy (see below, it asks for data of an attachment at 
index 'index').
 Bye, zyx

PdfNamesTree *names = document-GetNamesTree(false);
 if (names) {
 PdfObject *pObj = 
names-GetObject()-GetIndirectKey(EmbeddedFiles);
 if (pObj) {
 const PdfObject *kidsKey = pObj-GetIndirectKey(Kids);
 if (kidsKey) {
 const PdfArray kids = kidsKey-GetArray();
 PdfArray::const_iterator kit, kend = kids.end();

 for (kit = kids.begin(); kit != kend; kit++) {
 const PdfObject *obj = (*kit);
 if (obj-IsReference()) {
 obj = 
document-GetObjects()-GetObject(obj-GetReference());
 if (!obj) {
 continue;
 }
 }

 const PdfObject *namesKey = 
obj-GetIndirectKey(Names);
 if (namesKey) {
 const PdfArray names = namesKey-GetArray();
 // pair of PdfString/PdfObject, thus divide 
by two
 if (names.GetSize() / 2  index) {
 PdfArray::const_iterator nit, nend = 
names.end();
 for (nit = names.begin(); nit != nend;) {
 if (index == 0) {
 nit++;

 pdf_int64 streamSize = 0;
 const PdfStream *stream = NULL;

 obj = (*nit);
 if (obj-IsReference()) {
 obj = 
document-GetObjects()-GetObject(obj-GetReference());
 }

 if (obj) {
 const PdfDictionary dict = 
obj-GetDictionary();
 if (dict.HasKey(Type) 
  dict.GetKey(Type)-GetName() == PdfName(Filespec) 
  dict.HasKey(EF) 
  dict.GetKey(EF)-GetDictionary().HasKey(F)) {
 obj = 
dict.GetKey(EF)-GetDictionary().GetKey(F);
 if (obj  
obj-IsReference()) {
 obj = 
document-GetObjects()-GetObject(obj-GetReference());
 }
 } else {
 obj = NULL;
 }
 }

 if (obj) {
 const PdfDictionary dict = 
obj-GetDictionary();
 if (dict.HasKey(Type) 
  dict.GetKey(Type)-GetName() == PdfName(EmbeddedFile) 
  dict.HasKey(Params) 
  dict.GetKey(Params)-GetDictionary().HasKey(Size) 
  dict.GetKey(Params)-GetDictionary().GetKey(Size)-IsNumber() 
  obj-HasStream()) {
 // get the stream
 streamSize = 
dict.GetKey(Params)-GetDictionary().GetKey(Size)-GetNumber();
 stream = obj-GetStream();
 }
 }

 if (!obj) {
 // Failed to get embedded 
file object
 return FALSE;
 }

 if (!stream) {
 // Failed to get embedded 
file stream
 return FALSE;
 }

 char *buff = NULL;
 pdf_long buffLength = 0;

stream-GetFilteredCopy(buff, buffLength);

 // the buffLength is supposed 
to match streamSize
 // do something with the 
buff/buffLength

 return TRUE;
 }
 index--;
 nit++;
 nit++;