Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: PDF::Reuse - adding javascript

by qq (Hermit)
on Dec 13, 2004 at 15:33 UTC ( [id://414412]=note: print w/replies, xml ) Need Help??


in reply to Re: PDF::Reuse - adding javascript
in thread PDF::Reuse - adding javascript

Good advice, but how can I put it into practice?

Because I don't have Acrobat I don't know of any other way to embed javascript in a PDF. Nor to tell if its being called. I don't believe the code would work outside of a PDF, because its using the the PDF object models.

I mentioned calling strings on the resultant pdf - so I know its actually being put in.

However I've just installed a standalone javascript interpreter to see if that gives me more info.

Thanks, qq

Replies are listed 'Best First'.
Re^3: PDF::Reuse - adding javascript
by dragonchild (Archbishop) on Dec 13, 2004 at 16:25 UTC
    I mentioned calling strings on the resultant pdf - so I know its actually being put in.

    Actually, you know it's being put into the data structure. You actually have no idea whether or not it's in the PDF because you're not checking the PDF. Unless, of course, you're parsing the PDF with a second script calling PDF::Reuse ...

    Now, I would definitely get Acrobat Reader - there is a free version of that for every single OS that has a GUI and more than 2 users. That way, you can verify your PDF. You don't need Adobe Acrobat (the pay version) to make sure the Javascript is working - you would need it to build a new PDF.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      I may not be understanding you here. I have Reader, and when I open the resulting pdf (created by PDF::Reuse), I get a blank document. That's how I know that something's wrong - I'm not seeing a form field. Of course I've checked that javascript is enabled, etc.

      I agree that the fact that the javascript appears within the pdf file (the strings test) doesn't mean its in the right place, or that its being initialized/called correctly.

      Other uses of PDF::Reuse seem to work fine.

      Standalone javascript interpreters verify the syntax is ok, although I can't test much else (because the "this" object refers to the Adobe doc object.

      A much stripped down javascript examples also failed (I posted a long one since it was from the Tutorial docs, and I didn't want to risk my javascript syntax being the problem).

      If I had Acrobat I'd have another way to approach the problem, and I could follow the Adobe docs, etc.

      Thanks again, qq

        Standalone javascript interpreters verify the syntax is ok, although I can't test much else (because the "this" object refers to the Adobe doc object.

        There is always a way to test! You can create a mock object of the Adobe DOM. It looks like you have only a few calls to it, and it returns some sort of form element object (which you can also mock up). And not only will this allow you to test this outside of Acrobat, but it will also help by getting you more familiarized with the Adobe DOM itself. Here is a basic mock up, which (if my Javascript knowledge is not too rusty) should work and deal with the "this" in your code properly as well.

        function MockAdobeDOM () { // ... any bookkeeping code you want here } MockAdobeDOM.prototype.addField = addField; MockAdobeDOM.prototype.nameAddress = nameAddress; function addField (fieldName, fieldType, thePage, myRec) { // return mock field object you are asking for } function nameAddress(page, xpos, ypos) { // ... your code here ... }

        -stvn
        Have you tried parsing the PDF with one of the free PDF parsers you can find through Google? Maybe PDF::Reuse can help you here ...

        Plus, how much do you actually know about the Adobe DOM? It sounds like you're doing more than you understand (though examples should always work). Have you asked the author of PDF::Reuse for help?

        Being right, does not endow the right to be rude; politeness costs nothing.
        Being unknowing, is not the same as being stupid.
        Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
        Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://414412]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-26 02:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found