Class PdfOverlay


  • public final class PdfOverlay
    extends java.lang.Object
    Composites selected pages of one document (srcDoc) onto selected pages of another (destDoc) -- the engine behind com.pd4ml.pdf.PdfDocumentBase#overlay/#underlay. Replaces the legacy com.pd4ml.pdf.parser.PdfDoc's own ~600-line per-operator content-stream/resource-merging engine with a simpler design: each distinct source page actually used is cloned once into a fully self-contained Form XObject (its own /BBox, its own deep-cloned /Resources -- via COSObjectImporter, which already deduplicates any resource shared across multiple cloned pages), so nothing here ever needs to merge or deduplicate two documents' resource dictionaries by hand the way the legacy engine did. Wiring per destination page is limited to: copy-on-write its own /Resources (and the /XObject//ExtGState sub-dictionaries within it) only if not already page-owned, add one uniquely-named XObject (and, if opacity<255, one ExtGState) entry, and splice one small new content-stream snippet into its /Contents array -- appended for overlay (drawn last, on top), prepended for underlay (drawn first, underneath) -- without ever touching the page's own existing content stream bytes.

    Destination-to-source page pairing is round-robin over the pages actually kept by each scope array (matches legacy's own count % ovlCount pairing exactly). /Link annotations are cloned across from each used source page (matching legacy's own annotation-copying scope -- no other subtype was ever carried over either).

    Deliberate deviations from legacy, documented rather than silently replicated: no page-position coordinate translation is applied (legacy sourced one from the *destination* document's own page-0 CropBox regardless of which destination page was actually being composited onto -- read as a latent quirk, not a real feature); /Names/Dests-style named-destination bookkeeping is out of scope (irrelevant to page content compositing).

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void apply​(COSDocument destDoc, COSDocument srcDoc, boolean[] destScope, boolean[] srcScope, int opacity, boolean underlay)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait