Not sure how those line breaks got lost, but here is that portion with them put 
back in:


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



-----Original Message-----
From: Gary Grosso [mailto:[email protected]] 
Sent: Sunday, September 10, 2017 9:40 PM
To: [email protected]
Subject: workaround for PDF being considered modified if using 
setNeedAppreances(true)

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