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

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.

Replies are listed 'Best First'.
Re^4: PDF::Reuse - adding javascript
by qq (Hermit) on Dec 13, 2004 at 17:11 UTC

    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.

        I'm working my way through the Adobe JavaScript docs, so although I'm currently working at the limit of my understanding, hopefully that situation will change. It doesn't seem unreasonably complicated.

        I have mailed the author, but no response yet.

        Thanks