Package com.nsdev.lettergenerator
Class Letter
java.lang.Object
com.nsdev.lettergenerator.Letter
Starting point for content-first letters and the supported HTML letter template format. Use
builder() for Java content, template(String) for markup with typed map
bindings, or fromHtml(String) for already-resolved markup. Build a LetterDocument and pass it to LetterPdfGenerator.generate(com.nsdev.lettergenerator.model.LetterDocument).
Java builders default to A4 paper, 20 mm margins and the library's letter typography. Builders are mutable; their built document snapshots are immutable.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringForm-feed marker accepted byLetterBuilder.body(String...). -
Method Summary
Modifier and TypeMethodDescriptionstatic LetterBuilderbuilder()Creates a fresh mutable Java letter builder with default page, region and text settings.static HtmlLetterBuilderStarts a builder for already-resolved markup in the supported<letter>format.static LetterDocumentParses strict schema-version-one JSON into the shared immutable model.static HtmlLetterBuilderStarts a template builder that substitutes${name}bindings in parsed text and attribute values.
-
Field Details
-
PAGE_BREAK
Form-feed marker accepted byLetterBuilder.body(String...). Use it as a separate body argument or inside a body string to insert a page break. Header, footer and plain signature text reject this marker.- See Also:
-
-
Method Details
-
builder
Creates a fresh mutable Java letter builder with default page, region and text settings.- Returns:
- an independent builder with no body content
-
fromJson
Parses strict schema-version-one JSON into the shared immutable model. This does not run model validation or PDF layout; pass the result to the generator for either operation.- Parameters:
json- nonnull JSON document- Returns:
- parsed document, or null for the JSON null literal
- Throws:
InvalidLetterException- for malformed or incompatible input
-
template
Starts a template builder that substitutes${name}bindings in parsed text and attribute values. Replacement text cannot introduce markup nodes. The source must use the supported single<letter>root format, checked when built.- Parameters:
markup- non-null letter template source- Returns:
- a fresh builder that accepts placeholder values and named image assets
- Throws:
IllegalArgumentException- ifmarkupis null
-
fromHtml
Starts a builder for already-resolved markup in the supported<letter>format. Placeholder substitution is disabled; supplying values to this builder is rejected. Parsing and markup validation occur when the builder is built.- Parameters:
resolvedMarkup- non-null letter markup whose values have already been resolved- Returns:
- a fresh builder that accepts named image assets
- Throws:
IllegalArgumentException- ifresolvedMarkupis null
-