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