Documentation
¶
Overview ¶
Package entity contains all core entities.
Index ¶
- type AcroForm
- type AnnotationType
- type Cell
- type Config
- type CustomFont
- type DestinationFitType
- type Dimensions
- type Field
- func CloneField(field *Field) *Field
- func NewCheckbox(name string, rect [4]float64, pageIndex int, checked bool) *Field
- func NewDropdown(name string, rect [4]float64, pageIndex int, options []string) *Field
- func NewListBox(name string, rect [4]float64, pageIndex int, options []string) *Field
- func NewMultilineTextField(name string, rect [4]float64, pageIndex int) *Field
- func NewPasswordField(name string, rect [4]float64, pageIndex int) *Field
- func NewRadioGroup(name string, options []RadioOption) *Field
- func NewSignatureField(name string, rect [4]float64, pageIndex int) *Field
- func NewTextField(name string, rect [4]float64, pageIndex int) *Field
- type FieldFlags
- type FieldType
- type FileAttachment
- type HTMLLimits
- type Image
- type LabelStyle
- type Margins
- type MarkupType
- type Metadata
- type NamedDest
- type NamedDestination
- type PageAnnotation
- type PageGeometry
- type PageLabelRange
- type PageLayout
- type PageMode
- type PdfAConfig
- type PdfALevel
- type Protection
- type RadioOption
- type Utf8Text
- type ViewerPreferences
- type XMPProperty
- type XMPPropertyBlock
- type XMPSchema
- type XMPSchemaProperty
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcroForm ¶ added in v0.2.2
type AcroForm struct {
// contains filtered or unexported fields
}
AcroForm manages generated PDF interactive form fields.
func CloneAcroForm ¶ added in v0.2.2
CloneAcroForm returns a deep copy of form.
func NewAcroForm ¶ added in v0.2.2
func NewAcroForm() *AcroForm
NewAcroForm creates an empty AcroForm.
type AnnotationType ¶ added in v0.2.2
type AnnotationType string
AnnotationType identifies a PDF annotation subtype supported by Paper.
const ( AnnotationLink AnnotationType = "Link" AnnotationText AnnotationType = "Text" AnnotationHighlight AnnotationType = "Highlight" AnnotationUnderline AnnotationType = "Underline" AnnotationSquiggly AnnotationType = "Squiggly" AnnotationStrikeOut AnnotationType = "StrikeOut" )
The annotation subtypes Paper can emit.
type Cell ¶
Cell represents a cell inside the PDF.
func NewRootCell ¶
NewRootCell creates the main Cell.
func (Cell) GetDimensions ¶
func (c Cell) GetDimensions() *Dimensions
GetDimensions returns the dimensions of the Cell (width and height).
type Config ¶
type Config struct {
ProviderType consts.ProviderType
Dimensions *Dimensions
Margins *Margins
DefaultFont *props.Font
CustomFonts []CustomFont
GenerationMode consts.GenerationMode
ChunkWorkers int
Debug bool
MaxGridSize int
PageNumber *props.PageNumber
Protection *Protection
Compression bool
Metadata *Metadata
BackgroundImage *Image
FirstPageBackgroundImage *Image
FirstPageForegroundImage *Image
FirstPageForegroundImages []*Image
FirstPageFinalForegroundImages []*Image
DisableAutoPageBreak bool
HTMLLimits HTMLLimits
OutlineFromHeadings bool
Watermark *props.Watermark
Annotations []PageAnnotation
PageGeometries []PageGeometry
AcroForm *AcroForm
PdfA *PdfAConfig
TaggedPDF bool
Language string
ViewerPreferences *ViewerPreferences
PageLabels []PageLabelRange
Attachments []FileAttachment
NamedDestinations []NamedDestination
FileID []byte
Deterministic bool
}
Config is the configuration of a paper instance.
func (*Config) HasDocumentCatalog ¶ added in v0.2.2
HasDocumentCatalog reports whether any document-catalog feature is configured. These features are written once per document.
func (*Config) RequiresSingleDocumentGeneration ¶ added in v0.2.2
RequiresSingleDocumentGeneration reports whether the document carries a feature that page-chunked generation cannot reproduce, so it must be built in a single pass.
Deterministic output is deliberately excluded: it only affects the dates and /ID written once when the document is serialized, which page splicing preserves because it serializes exactly one document. Chunk-and-merge strategies do not, so callers relying on those must check Deterministic too.
type CustomFont ¶
type CustomFont interface {
GetFamily() string
GetStyle() fontstyle.Type
GetFile() string
GetBytes() []byte
}
CustomFont is the representation of a font that can be added to the pdf.
type DestinationFitType ¶ added in v0.2.2
type DestinationFitType string
DestinationFitType is the PDF destination fit operator for a named destination.
const ( // DestinationFit fits the full page in the viewer. DestinationFit DestinationFitType = "Fit" // DestinationFitH fits the page width at the provided top coordinate. DestinationFitH DestinationFitType = "FitH" // DestinationXYZ opens the page at the provided left/top/zoom values. DestinationXYZ DestinationFitType = "XYZ" )
type Dimensions ¶
Dimensions is the representation of a width and height.
type Field ¶ added in v0.2.2
type Field struct {
Name string
Type FieldType
Value string
Default string
Flags FieldFlags
Rect [4]float64
PageIndex int
FontSize float64
FontName string
TextColor [3]float64
BGColor *[3]float64
BorderColor *[3]float64
BorderWidth float64
Options []string
ExportValue string
// contains filtered or unexported fields
}
Field represents a generated PDF AcroForm field.
func CloneField ¶ added in v0.2.2
CloneField returns a deep copy of field.
func NewCheckbox ¶ added in v0.2.2
NewCheckbox creates a checkbox field.
func NewDropdown ¶ added in v0.2.2
NewDropdown creates a combo-box choice field.
func NewListBox ¶ added in v0.2.2
NewListBox creates a list-box choice field.
func NewMultilineTextField ¶ added in v0.2.2
NewMultilineTextField creates a multi-line text area field.
func NewPasswordField ¶ added in v0.2.2
NewPasswordField creates a password text field.
func NewRadioGroup ¶ added in v0.2.2
func NewRadioGroup(name string, options []RadioOption) *Field
NewRadioGroup creates a radio button group.
func NewSignatureField ¶ added in v0.2.2
NewSignatureField creates an unsigned signature field.
func NewTextField ¶ added in v0.2.2
NewTextField creates a single-line text input field.
func (*Field) Children ¶ added in v0.2.2
Children returns radio widget children for a radio group field.
func (*Field) SetBackgroundColor ¶ added in v0.2.2
SetBackgroundColor sets the field widget background color as RGB values in [0, 1].
func (*Field) SetBorderColor ¶ added in v0.2.2
SetBorderColor sets the field widget border color as RGB values in [0, 1].
func (*Field) SetReadOnly ¶ added in v0.2.2
SetReadOnly marks the field read-only.
func (*Field) SetRequired ¶ added in v0.2.2
SetRequired marks the field required.
type FieldFlags ¶ added in v0.2.2
type FieldFlags uint32
FieldFlags are AcroForm field flags from ISO 32000 section 12.7.3.
const ( FlagReadOnly FieldFlags = 1 << 0 FlagRequired FieldFlags = 1 << 1 FlagNoExport FieldFlags = 1 << 2 FlagMultiline FieldFlags = 1 << 12 FlagPassword FieldFlags = 1 << 13 FlagFileSelect FieldFlags = 1 << 20 FlagDoNotSpellCheck FieldFlags = 1 << 22 FlagDoNotScroll FieldFlags = 1 << 23 FlagComb FieldFlags = 1 << 24 FlagRichText FieldFlags = 1 << 25 FlagCombo FieldFlags = 1 << 17 FlagEdit FieldFlags = 1 << 18 FlagSort FieldFlags = 1 << 19 FlagMultiSelect FieldFlags = 1 << 21 FlagNoToggleToOff FieldFlags = 1 << 14 FlagRadioFlag FieldFlags = 1 << 15 FlagPushButtonFlag FieldFlags = 1 << 16 )
Field flags, grouped by the field kind they apply to: any field, text fields, choice fields, then button fields. Combine them with bitwise OR.
type FieldType ¶ added in v0.2.2
type FieldType int
FieldType identifies the kind of interactive AcroForm field.
type FileAttachment ¶ added in v0.2.2
type FileAttachment struct {
// FileName is the name shown by PDF viewers and stored in the file
// specification dictionary.
FileName string
// MIMEType is written as the embedded file stream subtype. It defaults to
// application/octet-stream when empty.
MIMEType string
// Description is an optional human-readable file description.
Description string
// AFRelationship is the PDF associated-file relationship name. It defaults
// to Unspecified when empty.
AFRelationship string
// Data is the raw file content to embed.
Data []byte
// CreationDate is written to the embedded file parameters. If zero, the
// document creation date or generation time is used.
CreationDate time.Time
}
FileAttachment describes a file embedded in the generated PDF.
func CloneAttachments ¶ added in v0.2.2
func CloneAttachments(attachments []FileAttachment) []FileAttachment
CloneAttachments returns an independent copy of attachments, including the embedded data bytes.
type HTMLLimits ¶
type HTMLLimits = htmllimits.Limits
HTMLLimits caps resource use while translating untrusted HTML.
type Image ¶
type Image struct {
Bytes []byte
Extension extension.Type
Dimensions *Dimensions
// PageCell optionally places the image in physical page coordinates,
// measured from the page's top-left corner.
PageCell *Cell
// ObjectFit controls how a positioned page image is sized inside PageCell.
ObjectFit string
}
Image is the representation of an image that can be added to the pdf.
type LabelStyle ¶ added in v0.2.2
type LabelStyle string
LabelStyle is how a page label numbers its pages.
const ( LabelDecimal LabelStyle = "D" LabelRomanUpper LabelStyle = "R" LabelRomanLower LabelStyle = "r" LabelAlphaUpper LabelStyle = "A" LabelAlphaLower LabelStyle = "a" LabelNone LabelStyle = "" )
The page numbering styles: decimal, upper/lower roman, upper/lower letters, or no number at all.
type MarkupType ¶ added in v0.2.2
type MarkupType int
MarkupType identifies the kind of text markup annotation.
const ( MarkupHighlight MarkupType = iota MarkupUnderline MarkupSquiggly MarkupStrikeOut )
The text markup styles a markup annotation can use.
type Metadata ¶
type Metadata struct {
Author *Utf8Text
Creator *Utf8Text
Subject *Utf8Text
Title *Utf8Text
CreationDate *time.Time
KeywordsStr *Utf8Text
}
Metadata is the representation of a PDF metadata.
type NamedDest ¶ added in v0.2.2
type NamedDest = NamedDestination
NamedDest is a compatibility alias for Folio-style naming.
type NamedDestination ¶ added in v0.2.2
type NamedDestination struct {
Name string
PageIndex int
FitType DestinationFitType
Top float64
Left float64
Zoom float64
}
NamedDestination defines a named location in the generated PDF.
type PageAnnotation ¶ added in v0.2.2
type PageAnnotation struct {
PageIndex int
Type AnnotationType
Rect [4]float64
URI string
DestName string
DestPage *int
Contents string
Icon string
Open bool
Color *[3]float64
QuadPoints [][8]float64
}
PageAnnotation describes an annotation emitted on a generated PDF page.
func CloneAnnotations ¶ added in v0.2.2
func CloneAnnotations(annotations []PageAnnotation) []PageAnnotation
CloneAnnotations returns an independent copy of annotations.
type PageGeometry ¶ added in v0.2.2
type PageGeometry struct {
PageIndex int
Rotate int
CropBox *[4]float64
BleedBox *[4]float64
TrimBox *[4]float64
ArtBox *[4]float64
}
PageGeometry configures generated PDF page dictionary geometry entries.
func ClonePageGeometries ¶ added in v0.2.2
func ClonePageGeometries(geometries []PageGeometry) []PageGeometry
ClonePageGeometries returns an independent copy of page geometries.
type PageLabelRange ¶ added in v0.2.2
type PageLabelRange struct {
PageIndex int
Style LabelStyle
Prefix string
Start int
}
PageLabelRange labels the run of pages starting at PageIndex. Start is the number the run counts from, and Prefix is put in front of each number.
type PageLayout ¶ added in v0.2.2
type PageLayout string
PageLayout is how a reader should arrange pages on screen.
const ( LayoutSinglePage PageLayout = "SinglePage" LayoutOneColumn PageLayout = "OneColumn" LayoutTwoColumnLeft PageLayout = "TwoColumnLeft" LayoutTwoColumnRight PageLayout = "TwoColumnRight" LayoutTwoPageLeft PageLayout = "TwoPageLeft" LayoutTwoPageRight PageLayout = "TwoPageRight" )
The page arrangements a reader can be asked to use.
type PageMode ¶ added in v0.2.2
type PageMode string
PageMode is what a reader should show alongside the page when the document opens, such as the bookmark or thumbnail panel.
const ( ModeUseNone PageMode = "UseNone" ModeUseOutlines PageMode = "UseOutlines" ModeUseThumbs PageMode = "UseThumbs" ModeFullScreen PageMode = "FullScreen" ModeUseOC PageMode = "UseOC" ModeUseAttachments PageMode = "UseAttachments" )
The side panels (or full-screen mode) a reader can open the document with.
type PdfAConfig ¶ added in v0.2.2
type PdfAConfig struct {
Level PdfALevel
ICCProfile []byte
OutputCondition string
XMPSchemas []XMPSchema
XMPProperties []XMPPropertyBlock
}
PdfAConfig configures generated PDF/A identification metadata.
func ClonePdfAConfig ¶ added in v0.2.2
func ClonePdfAConfig(config *PdfAConfig) *PdfAConfig
ClonePdfAConfig returns a deep copy of config.
type PdfALevel ¶ added in v0.2.2
type PdfALevel int
PdfALevel identifies the requested PDF/A part and conformance profile.
type Protection ¶
type Protection struct {
Type protection.Type
UserPassword string
OwnerPassword string
Algorithm protection.Encryption
}
Protection is the representation of a pdf protection.
type RadioOption ¶ added in v0.2.2
RadioOption defines one button in a radio group.
type ViewerPreferences ¶ added in v0.2.2
type ViewerPreferences struct {
PageLayout PageLayout
PageMode PageMode
HideToolbar bool
HideMenubar bool
HideWindowUI bool
FitWindow bool
CenterWindow bool
DisplayDocTitle bool
OpenPage int
OpenZoom string
}
ViewerPreferences asks the reader how to present the document when it opens. Every field is optional; a zero field leaves that choice to the reader.
type XMPProperty ¶ added in v0.2.2
XMPProperty is a single custom XMP property value.
type XMPPropertyBlock ¶ added in v0.2.2
type XMPPropertyBlock struct {
Namespace string
Prefix string
Properties []XMPProperty
}
XMPPropertyBlock carries actual XMP property values for a namespace.