Record Class PdfAttachment
java.lang.Object
java.lang.Record
com.nsdev.lettergenerator.document.PdfAttachment
- Record Components:
data- complete unencrypted PDF bytes, copied on construction and access
Owned, validated PDF pages to append after a generated letter. Encrypted and empty PDFs are
rejected; equality and hashing compare encoded contents. Attachments are accepted only by the
standard output profile because merging arbitrary PDFs cannot preserve profile guarantees.
-
Constructor Summary
ConstructorsConstructorDescriptionPdfAttachment(byte[] data) Takes a defensive snapshot and checks PDF readability without retaining parser state. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]data()Returns the value of thedatarecord component.booleanCompares exact encoded PDF contents.inthashCode()Returns a hash code value for this object.static PdfAttachmentof(byte[] bytes) Snapshots an already encoded PDF.static PdfAttachmentReads an explicitly trusted local PDF path once.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
PdfAttachment
public PdfAttachment(byte[] data) Takes a defensive snapshot and checks PDF readability without retaining parser state.- Parameters:
data- complete nonempty PDF bytes- Throws:
InvalidLetterException- if the bytes are absent, invalid, encrypted or have no pages
-
-
Method Details
-
of
Snapshots an already encoded PDF.- Parameters:
bytes- PDF contents- Returns:
- independent immutable attachment
-
of
Reads an explicitly trusted local PDF path once.- Parameters:
path- non-null PDF source- Returns:
- immutable attachment independent of later file changes
- Throws:
InvalidLetterException- if the path cannot be read or is not an accepted PDF
-
data
public byte[] data()Returns the value of thedatarecord component.- Returns:
- the value of the
datarecord component
-
equals
Compares exact encoded PDF contents. -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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.
-