Skip to content

Allow layers under PDF/A-2 and PDF/A-3, which permit optional content #351

Closed

Description

@jakejackson1

PDF/A-1 forbids optional content, so mPDF refuses layers and visibility under any PDF/A setting, and records a warning instead:

  • Mpdf::SetVisibility() (src/Mpdf.php:2101-2102): "Cannot set visibility to anything other than full when using PDFA or PDFX"
  • Mpdf::BeginLayer() (src/Mpdf.php:2926-2927): "Cannot use layers when using PDFA or PDFX"

PDF/A-2 and PDF/A-3 (ISO 19005-2, 6.9) do allow optional content, provided that:

  • every optional content configuration dictionary, the default /D and each one in /Configs, has a /Name
  • no configuration dictionary contains /AS
  • the /Order array lists every optional content group

The catalog written today fails two of those rules. Writer\MetadataWriter::writeCatalog() (src/Writer/MetadataWriter.php:478-497) writes the default /D configuration without a /Name. It also writes an /AS array whenever visibility: printonly / screenonly / hidden is used, because the print and view switching behind those values depends on it. So under PDF/A-2 either:

  • keep refusing visibility and allow plain layers, adding a /Name to /D; or
  • give visibility another mechanism. Without /AS a viewer no longer switches the print/screen groups by itself.

#330 adds Mpdf::transparencyAllowed() for the same PDF/A-1-only restriction on transparency. A matching check (e.g. optionalContentAllowed()) would gate these two call sites. Validate the output with the conformance test group #330 adds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions