ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Paul Mazaitis" <pm39@andrew.cmu.edu>
To: "mailing list for ConTeXt users" <ntg-context@ntg.nl>
Subject: Re: Widgets: Any good examples for developing JS-enabled PDFs that calculate?
Date: Tue, 19 Nov 2019 08:59:14 -0500	[thread overview]
Message-ID: <988E44D0-2B15-4D17-9EFE-C6F7E3892723@andrew.cmu.edu> (raw)
In-Reply-To: <9cc6c8d5-0861-f818-a70f-9d0534955da5@xs4all.nl>


Some further progress!

On 18 Nov 2019, at 13:56, Hans Hagen wrote:
> the problem with calculate is that there are also settings related to 
> it (plus some built-in addition stuff, at least that's what i see in 
> the viewer preferences and such, which is likely to interfere)

 From what I've been able to gather, there are three ways to get 
JavaScript into a PDF using Acrobat (or other software that uses the 
Acrobat way of doing things):

  - Predefined Calculations (use a UI to build a simple recipe)

  - Calculations built with Simplified Field Notation (operators and 
field names - I don't understand this one too well)

  - Custom Calculation Script (Acrobat JavaScript)

I _think_ these are relatively exclusive: I don't believe there's 
anything about the first two systems that interferes with the third (and 
I'm not sure how the UI would work for the first two in an LMTX context, 
anyway?).

> (and calculate doens't seem to be called at all)

After digging around in the spec and comparing output, it looks like 
adding the CO (Calculation Order, PDF Spec 12.7.2) key and an array:

	  /CO [15 0 R]

...to the AcroForm object is enough for the indicated field(s) to react 
to the internal calculation event.

The way I tested this is I inserted the above stanza (with the 
appropriate object ID) into the uncompressed LMTX PDF, and that was all 
it took for the calculate JS to start working for the total field.

(I likely wrecked the xref table in the process, but the PDF was still 
functional...)

I then built a form with a chained calculation (a second field that 
doubled the total field) and ended up with a CO entry like this:

	/CO [13 0 R 19 0 R]

...and I believe that the order of the objects in this array is how the 
calculation precedence is determined.

So! This is bigger than just adding the CO array to enable calculations; 
there needs to be enough of an interface to also indicate calculation 
order somehow in the .tex file.

I'd love to have this as a feature, but I will cheerfully defer if this 
has become ridiculous...

     -Paul





___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

      reply	other threads:[~2019-11-19 13:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-07 19:28 [Widgets] " Paul Mazaitis
2019-11-13 15:26 ` Pablo Rodriguez
2019-11-17 20:13   ` Widgets: " Paul Mazaitis
2019-11-18  8:48     ` Hans Hagen
2019-11-19 22:47       ` Paul Mazaitis
2019-11-18 15:15     ` Henning Hraban Ramm
2019-11-18 18:56       ` Hans Hagen
2019-11-19 13:59         ` Paul Mazaitis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=988E44D0-2B15-4D17-9EFE-C6F7E3892723@andrew.cmu.edu \
    --to=pm39@andrew.cmu.edu \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).