Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 76ECD200CF8 for ; Thu, 14 Sep 2017 23:23:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 75AA51609CD; Thu, 14 Sep 2017 21:23:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id BBF351609C6 for ; Thu, 14 Sep 2017 23:23:05 +0200 (CEST) Received: (qmail 41999 invoked by uid 500); 14 Sep 2017 21:23:04 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Received: (qmail 41988 invoked by uid 99); 14 Sep 2017 21:23:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Sep 2017 21:23:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id E200ECD070 for ; Thu, 14 Sep 2017 21:23:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.801 X-Spam-Level: X-Spam-Status: No, score=-1.801 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-2.8, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Y9E7EMDpd8FX for ; Thu, 14 Sep 2017 21:23:03 +0000 (UTC) Received: from mailout10.t-online.de (mailout10.t-online.de [194.25.134.21]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 087FA5FCF4 for ; Thu, 14 Sep 2017 21:23:03 +0000 (UTC) Received: from fwd26.aul.t-online.de (fwd26.aul.t-online.de [172.20.26.131]) by mailout10.t-online.de (Postfix) with SMTP id DC32841E273E for ; Thu, 14 Sep 2017 23:22:55 +0200 (CEST) Received: from [192.168.2.108] (XKhX4QZGohe9jWYj9uF5u9M7tpHQWAsNe3M9slHDnmI3FS7jXHs6stIXDZrzTPdw1N@[217.231.145.205]) by fwd26.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1dsbb1-2NABnM0; Thu, 14 Sep 2017 23:22:51 +0200 Subject: Re: workaround for PDF being considered modified if using setNeedAppreances(true) To: users@pdfbox.apache.org References: From: Tilman Hausherr Message-ID: Date: Thu, 14 Sep 2017 23:22:50 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-ID: XKhX4QZGohe9jWYj9uF5u9M7tpHQWAsNe3M9slHDnmI3FS7jXHs6stIXDZrzTPdw1N X-TOI-MSGID: a34768e4-df69-492b-9193-972c73f2c68d archived-at: Thu, 14 Sep 2017 21:23:06 -0000 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: users-unsubscribe@pdfbox.apache.org For additional commands, e-mail: users-help@pdfbox.apache.org