Record Class PageSpec

java.lang.Object
java.lang.Record
com.nsdev.lettergenerator.model.layout.PageSpec
Record Components:
size - portrait paper size; null becomes PageSize.A4
marginsMm - outer page insets; null becomes 20 mm on every side
topZoneMm - reserved height above body content, in millimeters; null becomes zero
bottomZoneMm - reserved height below body content, in millimeters; null becomes zero
dimensions - optional custom paper edges in millimeters
orientation - optional orientation; null means PORTRAIT
signatureZoneMm - additional reserved last-page height above the bottom zone, in millimeters; null becomes zero

public record PageSpec(PageSize size, Margins marginsMm, Double topZoneMm, Double bottomZoneMm, Double signatureZoneMm, PageDimensions dimensions, Orientation orientation) extends Record
Physical page layout with reserved regions inside the page margins. The top zone is above the body and the bottom zone is below it. On the last page, the signature zone sits above the bottom zone and reduces the available body height by its own height, even if no signature is supplied. All zones span the width remaining between left/right margins.

The constructor replaces nulls with defaults but does not check dimensions. Generation requires finite nonnegative margins/zones and positive body space on ordinary and last pages.

  • Field Details

    • A4

      public static final PageSpec A4
      A4 with 20 mm margins and zero-height reserved zones.
    • LETTER

      public static final PageSpec LETTER
      US Letter with 20 mm margins and zero-height reserved zones.
  • Constructor Details

    • PageSpec

      public PageSpec(PageSize size, Margins marginsMm, Double topZoneMm, Double bottomZoneMm, Double signatureZoneMm, PageDimensions dimensions, Orientation orientation)
      Replaces omitted layout properties with defaults; numeric validity is checked during PDF generation.
      Parameters:
      size - paper size, or null for A4
      marginsMm - margins, or null for 20 mm on all sides
      topZoneMm - top region height in millimeters, or null for zero
      bottomZoneMm - bottom region height in millimeters, or null for zero
      signatureZoneMm - last-page signature region height in millimeters, or null for zero
      dimensions - optional custom physical edges
      orientation - optional orientation
    • PageSpec

      public PageSpec(PageSize size, Margins marginsMm, Double topZoneMm, Double bottomZoneMm, Double signatureZoneMm)
      Preserves the original named-page constructor.
      Parameters:
      size - named paper size
      marginsMm - outer insets
      topZoneMm - top reservation
      bottomZoneMm - bottom reservation
      signatureZoneMm - final signature reservation
  • Method Details

    • widthMm

      public double widthMm()
      Returns:
      effective physical width after custom dimensions and orientation
    • heightMm

      public double heightMm()
      Returns:
      effective physical height after custom dimensions and orientation
    • defaults

      public static PageSpec defaults()
      Returns the default A4 specification.
      Returns:
      A4, with 20 mm margins and no reserved zones
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • size

      public PageSize size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component
    • marginsMm

      public Margins marginsMm()
      Returns the value of the marginsMm record component.
      Returns:
      the value of the marginsMm record component
    • topZoneMm

      public Double topZoneMm()
      Returns the value of the topZoneMm record component.
      Returns:
      the value of the topZoneMm record component
    • bottomZoneMm

      public Double bottomZoneMm()
      Returns the value of the bottomZoneMm record component.
      Returns:
      the value of the bottomZoneMm record component
    • signatureZoneMm

      public Double signatureZoneMm()
      Returns the value of the signatureZoneMm record component.
      Returns:
      the value of the signatureZoneMm record component
    • dimensions

      public PageDimensions dimensions()
      Returns the value of the dimensions record component.
      Returns:
      the value of the dimensions record component
    • orientation

      public Orientation orientation()
      Returns the value of the orientation record component.
      Returns:
      the value of the orientation record component