Skip to main content

layer_set_for

Function layer_set_for 

Source
pub fn layer_set_for(doc: &PdfDocument<'_>, intent: RenderIntent) -> LayerSet
Expand description

Build a LayerSet that reflects the document’s default configuration with every /AS automatic-state rule for the given RenderIntent applied.

Algorithm:

  1. Start from layer_set_from_document.
  2. For each auto-state rule on the default configuration whose /Event matches the requested intent:
    • For each OCG listed in the rule’s /OCGs:
      • For each /Category in the rule:
        • If that category’s /Usage sub-dict on the OCG carries an explicit ON/OFF state, override that OCG’s entry in the LayerSet.

PDF spec doesn’t define precedence when multiple rules touch the same OCG; this implementation is last-wins in the order rules appear in /AS.

Layers carrying /Usage hints with no matching /AS rule are untouched — by spec their hints are informational only, not auto-applied. Some viewers heuristically apply them anyway; stet does not.