I humbly ask the Monks for their sage advice.

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.

Many many thanks in advance!


In reply to Pack and Win32::API by cyocum

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.