On Wed, 27 Mar 2002, Chris Yocum wrote: > Hello All, > Well, I have a project that requires me to: parse a PDF file, add some > content inside the file, then out put the file for viewing on a browser that > has Adobe Acrobat reader installed. I searched the net. I found the great > pdflib library but found out that it would cost me $1000 to get a licence > for their PDI library that would allow me to parse the PDF then manipluate > it. So, I searched some more. I found Panda PDF project that seemed to fit > the bill. I downloaded the source then compiled into a Windows DLL since > that is the system that I am using. I was going to use ActivePerl's > Win32::API to call into the dll to access the functions and allow me to > complete this project. > > At first, it seemed to work. I needed to call a function that takes two char > *. I read the manual for Win32::API. I found out that you need to pack the > variables to pass into the function if they are pointers. Here is some > sample code to show you what I mean: > > > use Win32::API; > > $panda_init = Win32::API->new("c:\\temp\\panda", > "panda_init", > [], > V); > > $panda_init->Call(); > > $panda_open = Win32::API->new("c:\\temp\\panda", > "panda_open", > [P, P], > P); > > $filename = pack("p", "dd.pdf"); > $mode = pack("p", "w"); > > $panda_open->Call($filename, $mode); > > When I did this it returned "Unknown file mode handed to panda." Now I > looked in the docs and the source. The only supported file mode right now is > "w". Although, it always returns this error no matter what character I pack. > > Does anyone have experience with Win32::API enough to give me some clues? It > is probably my pack but I cannot be sure. I am about to go hack the code to > see what the function thinks it is receiving but I wanted to know if anyone > has encountered this before I start. >
I don't know that this is a solution to your problem but if I were faced with the same problem, here's how I'd proceed. You're passing a pointer to a string. Quite often in C-based routines, strings are expected to be terminated with a null (\x00) byte. My suggestion is to try to pad your strings with a null byte, e.g.: $filename = pack("p", "dd.pdf\x00"); $mode = pack("p", "w\x00"); **** [EMAIL PROTECTED] <Carl Jolley> **** All opinions are my own and not necessarily those of my employer **** _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs