What the Document Runs as It Is Closed, Saved or Printed

Run a script when reading software is about to close, save or print the document, and another once it has saved or printed it.

Summary

A form can stamp the date on itself as it goes to the printer, or remind whoever is closing it that a field is still empty. Each of those moments — about to close, about to save, saved, about to print, printed — can be given a script of its own. What reading software does with them is its own affair: many programs run none, so nothing a document needs should hang on one.

Technically

Written at the top level of a request, under "document_triggers"

document_triggers writes the /AA of the document catalogue: /WC for about to close, /WS for about to save, /DS for saved, /WP for about to print and /DP for printed. Each moment takes one script, {"script": "…"}, the only action the standard lets these moments set off: any other action is refused, and a moment left out sets off nothing. A script calls the functions the document registers under scripts.

Request Schema

  • document_triggers — object, optional. Absent, the document sets off nothing.
  • document_triggers.will_close — script, optional. Run just before the document is closed.
  • document_triggers.will_save — script, optional. Run just before the document is saved.
  • document_triggers.saved — script, optional. Run once the document is saved.
  • document_triggers.will_print — script, optional. Run just before the document is printed.
  • document_triggers.printed — script, optional. Run once the document is printed.

No part of PDF/A lets a document act when it is closed, saved or printed. A request claiming one and stating these is written all the same, and a check of that part names it among its findings.

A Whole Request That Creates a PDF

{
  "document_triggers": {
    "will_print": { "script": "app.alert('This copy is for internal use.');" }
  },
  "standard_fonts": [{ "name": "sans", "face": "helvetica" }],
  "items": [
    {
      "type": "text",
      "rect": { "llx": 60, "lly": 740, "urx": 535, "ury": 765 },
      "content": ["A document that speaks up before it is printed"],
      "font": "sans",
      "font_size": 14
    }
  ]
}

The line that sends it, in three languages

Finding one's way through it

The Order One Field Leads to the Next What a Page Sets off as Reading Software Comes and Goes The Scripts the Document Registers by Name What the Document Says It Is Made Of The Clickable Contents Down the Side Landing Places That Have a Name Following an Article Column by Column How the Document Opens and Prints

Where to Go Next

Every JSON key of a request, in one page The other forty-one settings of a request

See the Prices See the Examples