I haven't had the time to test it, but this javascript code

{this.dirty = false; var pdfDocOpened = true;}


doesn't this mean that you're setting the local variable "pdfDocOpened"?

And this:

"var isDirty = this.dirty;"

...

"if (!isDirty) {this.dirty = false;}"


so you're setting the global dirty to false if it was false before.

If this really works, I'd like to make an example out of this so that people who set needAppearances to true can avoid the dialogbox if they have changed nothing. I wonder if this can be used as an OpenAction in the document catalog.

Tilman


Am 11.09.2017 um 03:40 schrieb Gary Grosso:
When using PDAcroForm.setNeedAppearances(true) to set a signal in the PDF file 
that Reader/Acrobat should provide missing appearances, if a user opens that 
PDF file and goes to quit, even if they have made no changes (manually), they 
are prompted to save the file, because of the appearance modifications which 
have been done automatically.

I found that I could insert a hidden textbox with a bit of JavaScript to avoid 
this:

PDActionJavaScript jsAction = new PDActionJavaScript();
jsAction.setAction("if (typeof(pdfDocOpened) == 'undefined') {this.dirty = false; 
var pdfDocOpened = true;}");
annotationActions.setPO(jsAction);
widget.setActions(annotationActions);

I also had to augment some code I am using to allow a user to specify a date textfield as 
"current" to maintain the modified/unmodified status:

PDActionJavaScript jsPageOpenAction = new PDActionJavaScript();
String javaScript = "var isDirty = this.dirty;"
         + "var now = util.printd('mm/dd/yyyy', new Date());"
         + "var oField = this.getField('" + nameStr + "');"
         + "oField.value = now;"
         + "if (!isDirty) {this.dirty = false;}";
jsPageOpenAction.setAction(javaScript);
annotationActions.setPO(jsPageOpenAction);


Gary





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to