Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

form fields need recalculation after pages are inserted or prior to viewing, printing

Posted on 2011-02-11
4
339 Views
Last Modified: 2012-05-11
I have a two-page PDF (sample.pdf) that has a different form field (field01, field02) on each page that contains the formula:

event.value = "Page " + (event.target.page + 1) + " of " + this.numPages;

This lets each page calculate its own position within the document. This works fine until I insert a cover page. The revised document continues to show "Page 1 of 2" and "Page 2 of 2" until I bring up the console and manually call this.calculateNow(). Then the fields recalc and show "Page 2 of 3" and "Page 3 of 3" like I want. I want to change sample.pdf so that it recalculates after pages are added / deleted / moved or before it is viewed or printed. What event can I change so that sample.pdf is an easily insertable component of packets that I create?

TIA,
pT72
0
Comment
Question by:pteranodon72
  • 2
  • 2
4 Comments
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 34880711
The easiest way to accomplish this is by creating a document level script that calls the recalculate function. When you create the script, make sure that you are calling that function outside of the function body that Acrobat suggests by default (you can delete that function, you don't need it).

You still would have to save and reload the document in order for the page numbers to be correct, but the next time somebody will open that document, the page numbers would be correct.
0
 
LVL 14

Author Comment

by:pteranodon72
ID: 34888753
That makes sense. I've read about the Doc/Open event, but Acrobat 8 Pro will only guides me to creating scripts on Will Close, Will Save, Did Save, Will Print, and Did Print actions. If I name my own function in Document Javascripts and then follow the function definition with a call to the function, will that code run at Doc/Open?

Thanks,
pT72
0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 500 total points
ID: 34889007
As I said, you can create a document level script that will be executed when the document opens. Acrobat will create a function stub for you - you don't need that, so remove that in the editor window. Now anything that you add to the editor window will get executed when the document opens. So, if you just call the is.calculateNow() function (again, this needs to be done outside of a function), it will run when you open the document. Give it a try. If it's not working, I can give you step by step instructions.
0
 
LVL 14

Author Closing Comment

by:pteranodon72
ID: 34889601
That makes sense. I thought the document level scripts were just for definition of functions to be used elsewhere. I didn't realize that code can be called from them and it will run when the document is opened.

Thanks for your help.

pT72
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Sometimes we receive PDF files that are in the wrong orientation. They may be sideways or even upside down. This most commonly happens with scanned or faxed documents. It is possible to rotate the view of these PDFs with the free Adobe Reader produc…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question