A Name That Stands for Several Layers at Once

Draw items on a name that follows several layers, and say what reading software must find true of them before it shows what the name covers.

See It in a Real PDF

One Drawing, and Each Reader Sees Their Own

The same floor plan on six layers shown and hidden one at a time: the furniture and the distances shown, the internal notes hidden until asked for, and a draft watermark meant for the screen and not for the paper.

Open the PDF The Whole Example

Summary

Layers are shown and hidden one by one. A rule is a name that watches several of them: show this warning while every safety layer is on, show that note as soon as any language layer is off. Items drawn on the rule follow it, and reading software works the rule out from the layers themselves rather than from a switch of its own.

Technically

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

layer_rules writes the visibility expressions of the document: a membership dictionary naming several layers and the policy that decides them. An item drawn on the rule's name follows the rule. The name sits beside the declared layers, so a rule taking the name of a layer the request declared is refused.

Request Schema

  • layer_rules — array, optional, empty by default.
  • layer_rules[].name — string, required. The name items say they are drawn on. It must not be the name of a declared layer.
  • layer_rules[].shown — object, required. layers — array of strings, the declared layers the rule follows; policy — one of all_visible, any_visible, any_hidden, all_hidden.
  • layer_rules[].expression — object, optional. A formula over layers, which reading software that knows formulas reads in place of shown; one that does not reads shown, which is why the rule still states one. Four forms, nested as deep as needed: {"layer": name}, true while that layer is shown; {"and": […]}, true while every operand is; {"or": […]}, true while one operand at least is; {"not": …}, true while its operand is false. A layer no layers entry declared is refused. It needs PDF 1.6.

A rule decides what is shown, never what is printed: what goes on paper is settled by each layer's own entry under layers.

A Whole Request That Creates a PDF

{
  "layers": [{ "name": "French" }, { "name": "Safety" }],
  "layer_rules": [
    {
      "name": "french-safety",
      "shown": { "all_visible": ["French", "Safety"] }
    }
  ],
  "standard_fonts": [{ "name": "sans", "face": "helvetica" }],
  "items": [
    {
      "type": "text",
      "rect": { "llx": 60, "lly": 740, "urx": 535, "ury": 765 },
      "content": ["A warning shown while both layers are on"],
      "font": "sans",
      "font_size": 14
    }
  ]
}

The line that sends it, in three languages

What is drawn, and how it comes out

Everything That Can Be Drawn on a Page The File's Weight and the Time It Takes The First Page, Shown While the Rest Arrives Layers Reading Software Shows or Hides A Drawing Made Once, Shown by a Button Drawings Read from SVG Files The Sets of Layers Reading Software Offers Layers Reading Software Shows One of at a Time

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