Documentation
¶
Overview ¶
Package config implements custom configuration builder.
Index ¶
- func NormalizeConfig(cfg *entity.Config) *entity.Config
- type Builder
- type CfgBuilder
- func (b *CfgBuilder) Build() *entity.Config
- func (b *CfgBuilder) WithAcroForm(form *entity.AcroForm) Builder
- func (b *CfgBuilder) WithAdditionalFirstPageFinalForegroundImage(bytes []byte, ext extension.Type) Builder
- func (b *CfgBuilder) WithAdditionalFirstPageFinalForegroundImageAt(bytes []byte, ext extension.Type, x, y, width, height float64) Builder
- func (b *CfgBuilder) WithAdditionalFirstPageFinalForegroundImageAtFit(bytes []byte, ext extension.Type, x, y, width, height float64, ...) Builder
- func (b *CfgBuilder) WithAdditionalFirstPageForegroundImage(bytes []byte, ext extension.Type) Builder
- func (b *CfgBuilder) WithAdditionalFirstPageForegroundImageAt(bytes []byte, ext extension.Type, x, y, width, height float64) Builder
- func (b *CfgBuilder) WithAdditionalFirstPageForegroundImageAtFit(bytes []byte, ext extension.Type, x, y, width, height float64, ...) Builder
- func (b *CfgBuilder) WithAnnotations(annotations ...entity.PageAnnotation) Builder
- func (b *CfgBuilder) WithAuthor(author string, isUTF8 bool) Builder
- func (b *CfgBuilder) WithBackgroundImage(bytes []byte, ext extension.Type) Builder
- func (b *CfgBuilder) WithBackgroundImageAt(bytes []byte, ext extension.Type, x, y, width, height float64) Builder
- func (b *CfgBuilder) WithBackgroundImageAtFit(bytes []byte, ext extension.Type, x, y, width, height float64, ...) Builder
- func (b *CfgBuilder) WithBottomMargin(bottom float64) Builder
- func (b *CfgBuilder) WithCompression(compression bool) Builder
- func (b *CfgBuilder) WithCreationDate(creationDate time.Time) Builder
- func (b *CfgBuilder) WithCreator(creator string, isUTF8 bool) Builder
- func (b *CfgBuilder) WithCustomFonts(customFonts []entity.CustomFont) Builder
- func (b *CfgBuilder) WithDebug(on bool) Builder
- func (b *CfgBuilder) WithDefaultFont(font *props.Font) Builder
- func (b *CfgBuilder) WithDeterministic(deterministic bool) Builder
- func (b *CfgBuilder) WithDimensions(width, height float64) Builder
- func (b *CfgBuilder) WithDisableAutoPageBreak(disabled bool) Builder
- func (b *CfgBuilder) WithFileAttachments(attachments ...entity.FileAttachment) Builder
- func (b *CfgBuilder) WithFileID(id []byte) Builder
- func (b *CfgBuilder) WithFirstPageBackgroundImage(bytes []byte, ext extension.Type) Builder
- func (b *CfgBuilder) WithFirstPageBackgroundImageAt(bytes []byte, ext extension.Type, x, y, width, height float64) Builder
- func (b *CfgBuilder) WithFirstPageBackgroundImageAtFit(bytes []byte, ext extension.Type, x, y, width, height float64, ...) Builder
- func (b *CfgBuilder) WithFirstPageFinalForegroundImage(bytes []byte, ext extension.Type) Builder
- func (b *CfgBuilder) WithFirstPageFinalForegroundImageAt(bytes []byte, ext extension.Type, x, y, width, height float64) Builder
- func (b *CfgBuilder) WithFirstPageFinalForegroundImageAtFit(bytes []byte, ext extension.Type, x, y, width, height float64, ...) Builder
- func (b *CfgBuilder) WithFirstPageForegroundImage(bytes []byte, ext extension.Type) Builder
- func (b *CfgBuilder) WithFirstPageForegroundImageAt(bytes []byte, ext extension.Type, x, y, width, height float64) Builder
- func (b *CfgBuilder) WithFirstPageForegroundImageAtFit(bytes []byte, ext extension.Type, x, y, width, height float64, ...) Builder
- func (b *CfgBuilder) WithHTMLLimits(limits entity.HTMLLimits) Builder
- func (b *CfgBuilder) WithKeywords(keywordsStr string, isUTF8 bool) Builder
- func (b *CfgBuilder) WithLanguage(language string) Builder
- func (b *CfgBuilder) WithLeftMargin(left float64) Builder
- func (b *CfgBuilder) WithMaxGridSize(maxGridSize int) Builder
- func (b *CfgBuilder) WithNamedDestinations(destinations ...entity.NamedDestination) Builder
- func (b *CfgBuilder) WithOrientation(pageOrientation consts.Orientation) Builder
- func (b *CfgBuilder) WithOutlineFromHeadings(enabled bool) Builder
- func (b *CfgBuilder) WithPageGeometries(geometries ...entity.PageGeometry) Builder
- func (b *CfgBuilder) WithPageLabels(labels ...entity.PageLabelRange) Builder
- func (b *CfgBuilder) WithPageNumber(pageNumber ...props.PageNumber) Builder
- func (b *CfgBuilder) WithPageSize(size pagesize.Type) Builder
- func (b *CfgBuilder) WithParallelPagesMode(chunkWorkers int) Builder
- func (b *CfgBuilder) WithPdfA(config entity.PdfAConfig) Builder
- func (b *CfgBuilder) WithProtection(protectionType protection.Type, userPassword, ownerPassword string) Builder
- func (b *CfgBuilder) WithProtectionAlgorithm(algorithm protection.Encryption) Builder
- func (b *CfgBuilder) WithRightMargin(right float64) Builder
- func (b *CfgBuilder) WithSequentialLowMemoryMode(chunkWorkers int) Builder
- func (b *CfgBuilder) WithSequentialMode() Builder
- func (b *CfgBuilder) WithSubject(subject string, isUTF8 bool) Builder
- func (b *CfgBuilder) WithTaggedPDF(enabled bool) Builder
- func (b *CfgBuilder) WithTitle(title string, isUTF8 bool) Builder
- func (b *CfgBuilder) WithTopMargin(top float64) Builder
- func (b *CfgBuilder) WithUnsafeNoHTMLLimits() Builder
- func (b *CfgBuilder) WithViewerPreferences(prefs entity.ViewerPreferences) Builder
- func (b *CfgBuilder) WithWatermark(text string, ps ...props.Watermark) Builder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
Builder is the abstraction responsible for global customizations on the document.
func NewBuilder ¶
func NewBuilder() Builder
NewBuilder is responsible to create an instance of Builder.
type CfgBuilder ¶
type CfgBuilder struct {
// contains filtered or unexported fields
}
CfgBuilder collects configuration through chained setters. Call Build to turn it into an entity.Config.
func NewCfgBuilder ¶
func NewCfgBuilder() *CfgBuilder
NewCfgBuilder creates a concrete configuration builder. NewBuilder keeps returning the public Builder interface, while this function exposes the concrete builder for callers that need fluent methods.
func (*CfgBuilder) Build ¶
func (b *CfgBuilder) Build() *entity.Config
Build finalizes the customization returning the entity.Config.
func (*CfgBuilder) WithAcroForm ¶ added in v0.2.2
func (b *CfgBuilder) WithAcroForm(form *entity.AcroForm) Builder
WithAcroForm attaches interactive form fields to the generated PDF. The form is cloned so later mutations of the input do not leak into the config.
func (*CfgBuilder) WithAdditionalFirstPageFinalForegroundImage ¶ added in v0.2.2
func (b *CfgBuilder) WithAdditionalFirstPageFinalForegroundImage(bytes []byte, ext extension.Type) Builder
WithAdditionalFirstPageFinalForegroundImage adds a foreground image applied only on the first page after page rows and page numbers are rendered.
func (*CfgBuilder) WithAdditionalFirstPageFinalForegroundImageAt ¶ added in v0.2.2
func (b *CfgBuilder) WithAdditionalFirstPageFinalForegroundImageAt(bytes []byte, ext extension.Type, x, y, width, height float64) Builder
WithAdditionalFirstPageFinalForegroundImageAt adds a foreground image placed in physical page coordinates only on the first page after rows and numbers.
func (*CfgBuilder) WithAdditionalFirstPageFinalForegroundImageAtFit ¶ added in v0.2.2
func (b *CfgBuilder) WithAdditionalFirstPageFinalForegroundImageAtFit( bytes []byte, ext extension.Type, x, y, width, height float64, objectFit string, ) Builder
WithAdditionalFirstPageFinalForegroundImageAtFit adds a foreground image placed in physical page coordinates only on the first page after rows and numbers with object-fit behavior.
func (*CfgBuilder) WithAdditionalFirstPageForegroundImage ¶ added in v0.2.2
func (b *CfgBuilder) WithAdditionalFirstPageForegroundImage(bytes []byte, ext extension.Type) Builder
WithAdditionalFirstPageForegroundImage adds a foreground image applied only on the first page after page rows are rendered.
func (*CfgBuilder) WithAdditionalFirstPageForegroundImageAt ¶ added in v0.2.2
func (b *CfgBuilder) WithAdditionalFirstPageForegroundImageAt(bytes []byte, ext extension.Type, x, y, width, height float64) Builder
WithAdditionalFirstPageForegroundImageAt adds a foreground image placed in physical page coordinates only on the first page after page rows are rendered.
func (*CfgBuilder) WithAdditionalFirstPageForegroundImageAtFit ¶ added in v0.2.2
func (b *CfgBuilder) WithAdditionalFirstPageForegroundImageAtFit( bytes []byte, ext extension.Type, x, y, width, height float64, objectFit string, ) Builder
WithAdditionalFirstPageForegroundImageAtFit adds a foreground image placed in physical page coordinates only on the first page after page rows are rendered with object-fit behavior.
func (*CfgBuilder) WithAnnotations ¶ added in v0.2.2
func (b *CfgBuilder) WithAnnotations(annotations ...entity.PageAnnotation) Builder
WithAnnotations adds page annotations to the generated PDF.
func (*CfgBuilder) WithAuthor ¶
func (b *CfgBuilder) WithAuthor(author string, isUTF8 bool) Builder
WithAuthor defines the author name metadata.
func (*CfgBuilder) WithBackgroundImage ¶
func (b *CfgBuilder) WithBackgroundImage(bytes []byte, ext extension.Type) Builder
WithBackgroundImage defines the background image that will be applied in every page.
func (*CfgBuilder) WithBackgroundImageAt ¶ added in v0.2.2
func (b *CfgBuilder) WithBackgroundImageAt(bytes []byte, ext extension.Type, x, y, width, height float64) Builder
WithBackgroundImageAt defines a background image placed in physical page coordinates on every page.
func (*CfgBuilder) WithBackgroundImageAtFit ¶ added in v0.2.2
func (b *CfgBuilder) WithBackgroundImageAtFit( bytes []byte, ext extension.Type, x, y, width, height float64, objectFit string, ) Builder
WithBackgroundImageAtFit defines a background image placed in physical page coordinates on every page with object-fit behavior.
func (*CfgBuilder) WithBottomMargin ¶
func (b *CfgBuilder) WithBottomMargin(bottom float64) Builder
WithBottomMargin customize margin.
func (*CfgBuilder) WithCompression ¶
func (b *CfgBuilder) WithCompression(compression bool) Builder
WithCompression defines compression.
func (*CfgBuilder) WithCreationDate ¶
func (b *CfgBuilder) WithCreationDate(creationDate time.Time) Builder
WithCreationDate defines the creation date metadata.
func (*CfgBuilder) WithCreator ¶
func (b *CfgBuilder) WithCreator(creator string, isUTF8 bool) Builder
WithCreator defines the creator name metadata.
func (*CfgBuilder) WithCustomFonts ¶
func (b *CfgBuilder) WithCustomFonts(customFonts []entity.CustomFont) Builder
WithCustomFonts add custom fonts.
func (*CfgBuilder) WithDebug ¶
func (b *CfgBuilder) WithDebug(on bool) Builder
WithDebug defines a debug behaviour where paper will draw borders in everything.
func (*CfgBuilder) WithDefaultFont ¶
func (b *CfgBuilder) WithDefaultFont(font *props.Font) Builder
WithDefaultFont defines a custom font, other than arial. This can be used to define a custom font as default.
func (*CfgBuilder) WithDeterministic ¶ added in v0.2.2
func (b *CfgBuilder) WithDeterministic(deterministic bool) Builder
WithDeterministic makes repeated builds of the same document byte-identical (fixed implicit dates, sorted resources, content-derived trailer /ID).
func (*CfgBuilder) WithDimensions ¶
func (b *CfgBuilder) WithDimensions(width, height float64) Builder
WithDimensions defines custom page dimensions, this overrides page size.
func (*CfgBuilder) WithDisableAutoPageBreak ¶
func (b *CfgBuilder) WithDisableAutoPageBreak(disabled bool) Builder
WithDisableAutoPageBreak defines the option to disable automatic page breaks.
func (*CfgBuilder) WithFileAttachments ¶ added in v0.2.2
func (b *CfgBuilder) WithFileAttachments(attachments ...entity.FileAttachment) Builder
WithFileAttachments embeds files in the generated PDF.
func (*CfgBuilder) WithFileID ¶ added in v0.2.2
func (b *CfgBuilder) WithFileID(id []byte) Builder
WithFileID sets an explicit trailer /ID for the generated PDF.
func (*CfgBuilder) WithFirstPageBackgroundImage ¶ added in v0.2.2
func (b *CfgBuilder) WithFirstPageBackgroundImage(bytes []byte, ext extension.Type) Builder
WithFirstPageBackgroundImage defines a background image that will be applied only on the first page.
func (*CfgBuilder) WithFirstPageBackgroundImageAt ¶ added in v0.2.2
func (b *CfgBuilder) WithFirstPageBackgroundImageAt(bytes []byte, ext extension.Type, x, y, width, height float64) Builder
WithFirstPageBackgroundImageAt defines a background image placed in physical page coordinates only on the first page.
func (*CfgBuilder) WithFirstPageBackgroundImageAtFit ¶ added in v0.2.2
func (b *CfgBuilder) WithFirstPageBackgroundImageAtFit( bytes []byte, ext extension.Type, x, y, width, height float64, objectFit string, ) Builder
WithFirstPageBackgroundImageAtFit defines a background image placed in physical page coordinates only on the first page with object-fit behavior.
func (*CfgBuilder) WithFirstPageFinalForegroundImage ¶ added in v0.2.2
func (b *CfgBuilder) WithFirstPageFinalForegroundImage(bytes []byte, ext extension.Type) Builder
WithFirstPageFinalForegroundImage defines a foreground image applied only on the first page after page rows and page numbers are rendered.
func (*CfgBuilder) WithFirstPageFinalForegroundImageAt ¶ added in v0.2.2
func (b *CfgBuilder) WithFirstPageFinalForegroundImageAt(bytes []byte, ext extension.Type, x, y, width, height float64) Builder
WithFirstPageFinalForegroundImageAt defines a foreground image placed in physical page coordinates only on the first page after rows and page numbers.
func (*CfgBuilder) WithFirstPageFinalForegroundImageAtFit ¶ added in v0.2.2
func (b *CfgBuilder) WithFirstPageFinalForegroundImageAtFit( bytes []byte, ext extension.Type, x, y, width, height float64, objectFit string, ) Builder
WithFirstPageFinalForegroundImageAtFit defines a foreground image placed in physical page coordinates only on the first page after rows and page numbers with object-fit behavior.
func (*CfgBuilder) WithFirstPageForegroundImage ¶ added in v0.2.2
func (b *CfgBuilder) WithFirstPageForegroundImage(bytes []byte, ext extension.Type) Builder
WithFirstPageForegroundImage defines a foreground image applied only on the first page after page rows are rendered.
func (*CfgBuilder) WithFirstPageForegroundImageAt ¶ added in v0.2.2
func (b *CfgBuilder) WithFirstPageForegroundImageAt(bytes []byte, ext extension.Type, x, y, width, height float64) Builder
WithFirstPageForegroundImageAt defines a foreground image placed in physical page coordinates only on the first page after page rows are rendered.
func (*CfgBuilder) WithFirstPageForegroundImageAtFit ¶ added in v0.2.2
func (b *CfgBuilder) WithFirstPageForegroundImageAtFit( bytes []byte, ext extension.Type, x, y, width, height float64, objectFit string, ) Builder
WithFirstPageForegroundImageAtFit defines a foreground image placed in physical page coordinates only on the first page after page rows are rendered with object-fit behavior.
func (*CfgBuilder) WithHTMLLimits ¶
func (b *CfgBuilder) WithHTMLLimits(limits entity.HTMLLimits) Builder
WithHTMLLimits configures resource limits for AddHTML/FromHTML translation.
func (*CfgBuilder) WithKeywords ¶
func (b *CfgBuilder) WithKeywords(keywordsStr string, isUTF8 bool) Builder
WithKeywords defines the document's keyword metadata.
func (*CfgBuilder) WithLanguage ¶ added in v0.2.2
func (b *CfgBuilder) WithLanguage(language string) Builder
WithLanguage sets the document language written to the catalog /Lang entry.
func (*CfgBuilder) WithLeftMargin ¶
func (b *CfgBuilder) WithLeftMargin(left float64) Builder
WithLeftMargin customize margin.
func (*CfgBuilder) WithMaxGridSize ¶
func (b *CfgBuilder) WithMaxGridSize(maxGridSize int) Builder
WithMaxGridSize defines a custom max grid sum which it will change the sum of column sizes.
func (*CfgBuilder) WithNamedDestinations ¶ added in v0.2.2
func (b *CfgBuilder) WithNamedDestinations(destinations ...entity.NamedDestination) Builder
WithNamedDestinations defines named destinations in the generated PDF.
func (*CfgBuilder) WithOrientation ¶
func (b *CfgBuilder) WithOrientation(pageOrientation consts.Orientation) Builder
WithOrientation defines the page orientation. The default orientation is vertical, if horizontal is defined width and height will be flipped.
func (*CfgBuilder) WithOutlineFromHeadings ¶ added in v0.2.0
func (b *CfgBuilder) WithOutlineFromHeadings(enabled bool) Builder
WithOutlineFromHeadings makes HTML conversion (AddHTML/FromHTML) add h1-h6 headings to the PDF document outline: h1 becomes a level-0 entry, h2 a level-1 entry, and so on. Hidden headings are skipped. Default: off.
func (*CfgBuilder) WithPageGeometries ¶ added in v0.2.2
func (b *CfgBuilder) WithPageGeometries(geometries ...entity.PageGeometry) Builder
WithPageGeometries configures per-page rotation and geometry boxes.
func (*CfgBuilder) WithPageLabels ¶ added in v0.2.2
func (b *CfgBuilder) WithPageLabels(labels ...entity.PageLabelRange) Builder
WithPageLabels defines the labels viewers show instead of physical page numbers.
func (*CfgBuilder) WithPageNumber ¶
func (b *CfgBuilder) WithPageNumber(pageNumber ...props.PageNumber) Builder
WithPageNumber defines a string pattern to write the current page and total.
func (*CfgBuilder) WithPageSize ¶
func (b *CfgBuilder) WithPageSize(size pagesize.Type) Builder
WithPageSize defines the page size, ex: A4, A4 and etc.
func (*CfgBuilder) WithParallelPagesMode ¶ added in v0.2.2
func (b *CfgBuilder) WithParallelPagesMode(chunkWorkers int) Builder
WithParallelPagesMode renders pages concurrently into one document, splicing the rendered pages together instead of merging separate PDFs. chunkWorkers defines how many page groups are rendered concurrently.
func (*CfgBuilder) WithPdfA ¶ added in v0.2.2
func (b *CfgBuilder) WithPdfA(config entity.PdfAConfig) Builder
WithPdfA configures PDF/A conformance metadata and output intent. Level-A conformance profiles require a tagged PDF, so they enable WithTaggedPDF implicitly.
func (*CfgBuilder) WithProtection ¶
func (b *CfgBuilder) WithProtection(protectionType protection.Type, userPassword, ownerPassword string) Builder
WithProtection defines protection types to the PDF document.
Protection uses the PDF standard security handler. RC4 is the compatibility default; use WithProtectionAlgorithm to select AES-128. Protection deters casual copying or printing, but is not confidentiality-grade encryption. For confidentiality, encrypt the file at rest or in transit.
func (*CfgBuilder) WithProtectionAlgorithm ¶
func (b *CfgBuilder) WithProtectionAlgorithm(algorithm protection.Encryption) Builder
WithProtectionAlgorithm selects the protection encryption algorithm.
The default remains the legacy RC4 security handler for compatibility. AES128 selects AESV2, PDF standard security handler revision 4.
func (*CfgBuilder) WithRightMargin ¶
func (b *CfgBuilder) WithRightMargin(right float64) Builder
WithRightMargin customize margin.
func (*CfgBuilder) WithSequentialLowMemoryMode ¶
func (b *CfgBuilder) WithSequentialLowMemoryMode(chunkWorkers int) Builder
WithSequentialLowMemoryMode defines that paper will run focusing in reduce memory consumption, chunk workers define how many divisions the work will have.
func (*CfgBuilder) WithSequentialMode ¶
func (b *CfgBuilder) WithSequentialMode() Builder
WithSequentialMode defines that paper will run in default mode.
func (*CfgBuilder) WithSubject ¶
func (b *CfgBuilder) WithSubject(subject string, isUTF8 bool) Builder
WithSubject defines the subject metadata.
func (*CfgBuilder) WithTaggedPDF ¶ added in v0.2.2
func (b *CfgBuilder) WithTaggedPDF(enabled bool) Builder
WithTaggedPDF enables tagged (accessible) PDF output.
func (*CfgBuilder) WithTitle ¶
func (b *CfgBuilder) WithTitle(title string, isUTF8 bool) Builder
WithTitle defines the title metadata.
func (*CfgBuilder) WithTopMargin ¶
func (b *CfgBuilder) WithTopMargin(top float64) Builder
WithTopMargin customize margin.
func (*CfgBuilder) WithUnsafeNoHTMLLimits ¶
func (b *CfgBuilder) WithUnsafeNoHTMLLimits() Builder
WithUnsafeNoHTMLLimits disables resource limits for AddHTML/FromHTML.
func (*CfgBuilder) WithViewerPreferences ¶ added in v0.2.2
func (b *CfgBuilder) WithViewerPreferences(prefs entity.ViewerPreferences) Builder
WithViewerPreferences configures catalog viewer hints.
func (*CfgBuilder) WithWatermark ¶ added in v0.2.0
func (b *CfgBuilder) WithWatermark(text string, ps ...props.Watermark) Builder
WithWatermark stamps every page with translucent diagonal text, drawn under the page content. Optional props customize font, size, color, opacity, and angle; zero values fall back to defaults (48pt, alpha 0.12, 45 degrees). An empty text removes the watermark.