Link to home
Start Free TrialLog in
Avatar of pbaliga
pbaliga

asked on

refresh pdf on open

I have Adobe Acrobat5, Acrobat Distiller 5.0 and Acrobat Reader 5.1
Is there a way to create a javascript onload event for a pdf. The first time the pdf is opened, it has only the default values populated (which is correct). However once the pdf is filled, edited and submitted successfully, it shows the most recent values instead of default values when I open the pdf the next day. I want to show the default values whenever the pdf is opened for data entry, and not when an editing error occurs.  I have the javascript working correctly to display the error messages when encountering editing errors.
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

If you have the full version of Acrobat then yes, this can be done, but the free Reader cannot store any data in the PDF file. There are 4KB of global storage that could be used for this, but the updated license agreement for Reader does not allow this anymore (in the past this was 32KB, and was used by some programs to store locally entered data).

If you have a connection of a web server, you can store the data on the server.
Avatar of pbaliga
pbaliga

ASKER

I do have the full version of acrobat. However my question has to do with refreshing the page every time a new user or for that matter the same user  opens it up the next day. I have listboxes for some fields with default values, which is in the pdf itself.  Is there a javascript pdf onLoad event that I can call to clear the page every time it is opened?  I have a clear button on the page, which calls a javascript (action reset form), but it can be used only after the pdf has been displayed.
Sorry, I misunderstood. I promise to read your comments completely next time :-)

Yes, there is a mechanism to reset the values when you open a PDF file, actually, when you open the first page of the document. I don't have access to Acrobat 5 (at least not here, if this does not work, you have to wait until I get to work tomorrow morning). In Acrobat 6 it works this way:

Select the JavaScript menu (I think this is under Tools in A5) and select "Document JavaScripts" and add these lines outside of any JS functions (so that it gets executed when the documen is opened):

var bReset = false;

In order to add this, you have to specify a function name (e.g. test). Once the editor is up, just delete the function it created and add the one line from above.

Then select the first page in the thumbnail view and right-click, select Properties and add a page action to run JavaScript. In the editor add this:

if (!bReset)
{
    this.resetForm();
    bReset = true;
}

This should reset the form the first time the first page of the document is displayed.


Avatar of pbaliga

ASKER

Thanks for the reply. Will this action also reset the form when the user has made some form validation errors and I have to send it back with an error message. I am calling a javascript for the form validation when the submit button is clicked.( I do not want the values that the user entered to disappear when I show the error message) I will ty it out in the office tomorrow and let you know the result.

Once again thanks for your prompt reply.
ASKER CERTIFIED SOLUTION
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pbaliga

ASKER

Your explanation makes complete sense. I will let you know tomorrow if this was successful.
Avatar of pbaliga

ASKER

It worked exactly as you had explained.
Thanks
The above expalnation is very good and very useful.

But I faced error an in Acrobat 5.0.
In thumbnail view of Acrobat 5.0 I selected the first document and right-click, in the popup window Ithere is no Properties option.
How can I add PageOpen action in Acrobat 5.0?

Another doubt is if we make the above changes in Acrobat 6.0/5.0, Is this work in Acrobat 5.0/6.0 reader.

Please help me in this.

Thanks in advance
Srinivasa_a, please don't post new questions in already closed questions. If you need help, please open a new question.