func CreateCircleAnnotation(circDef CircleAnnotationDef) (*pdf.PdfAnnotation, error)
CreateCircleAnnotation creates a circle/ellipse annotation object with appearance stream that can be added to page PDF annotations.
func CreateLineAnnotation(lineDef LineAnnotationDef) (*pdf.PdfAnnotation, error)
CreateLineAnnotation creates a line annotation object that can be added to page PDF annotations.
func CreateRectangleAnnotation(rectDef RectangleAnnotationDef) (*pdf.PdfAnnotation, error)
CreateRectangleAnnotation creates a rectangle annotation object that can be added to page PDF annotations.
func NewCheckboxField(page *model.PdfPage, name string, rect []float64, opt CheckboxFieldOptions) (*model.PdfFieldButton, error)
NewCheckboxField generates a new checkbox field with partial name `name` at location `rect` on specified `page` and with field specific options `opt`.
func NewComboboxField(page *model.PdfPage, name string, rect []float64, opt ComboboxFieldOptions) (*model.PdfFieldChoice, error)
NewComboboxField generates a new combobox form field with partial name `name` at location `rect` on specified `page` and with field specific options `opt`.
func NewSignatureField(signature *model.PdfSignature, lines []*SignatureLine, opts *SignatureFieldOpts) (*model.PdfFieldSignature, error)
NewSignatureField returns a new signature field with a visible appearance containing the specified signature lines and styled according to the specified options.
func NewTextField(page *model.PdfPage, name string, rect []float64, opt TextFieldOptions) (*model.PdfFieldText, error)
NewTextField generates a new text field with partial name `name` at location specified by `rect` on given `page` and with field specific options `opt`.
AppearanceFont represents a font used for generating the appearance of a field in the filling/flattening process.
type AppearanceFont struct { // Name represents the name of the font which will be added to the // AcroForm resources (DR). Name string // Font represents the actual font used for the field appearance. Font *model.PdfFont // Size represents the size of the font used for the field appearance. // If size is 0, a default font size will be used. // The default font size is calculated using the available annotation // height and the AutoFontSizeFraction of the AppearanceStyle. Size float64 }
AppearanceFontStyle defines font style characteristics for form fields, used in the filling/flattening process.
type AppearanceFontStyle struct { // Fallback represents a global font fallback, used for fields which do // not specify a font in their default appearance (DA). The fallback is // also used if there is a font specified in the DA, but it is not // found in the AcroForm resources (DR). Fallback *AppearanceFont // FieldFallbacks defines font fallbacks for specific fields. The map keys // represent the names of the fields (which can be specified by their // partial or full names). Specific field fallback fonts take precedence // over the global font fallback. FieldFallbacks map[string]*AppearanceFont // ForceReplace forces the replacement of fonts in the filling/flattening // process, even if the default appearance (DA) specify a valid font. // If no fallback font is provided, setting this field has no effect. ForceReplace bool }
AppearanceStyle defines style parameters for appearance stream generation.
type AppearanceStyle struct { // How much of Rect height to fill when autosizing text. AutoFontSizeFraction float64 // CheckmarkRune is a rune used for check mark in checkboxes (for ZapfDingbats font). CheckmarkRune rune BorderSize float64 BorderColor model.PdfColor FillColor model.PdfColor // Multiplier for lineheight for multi line text. MultilineLineHeight float64 MultilineVAlignMiddle bool // Defaults to top. // Visual guide checking alignment of field contents (debugging). DrawAlignmentReticle bool // Allow field MK appearance characteristics to override style settings. AllowMK bool // Fonts holds appearance styles for fonts. Fonts *AppearanceFontStyle }
CheckboxFieldOptions defines optional parameters for a checkbox field a form.
type CheckboxFieldOptions struct { Checked bool }
CircleAnnotationDef defines a circle annotation or ellipse at position (X, Y) and Width and Height. The annotation has various style parameters including Fill and Border options and Opacity.
type CircleAnnotationDef struct { X float64 Y float64 Width float64 Height float64 FillEnabled bool // Show fill? FillColor *pdf.PdfColorDeviceRGB BorderEnabled bool // Show border? BorderWidth float64 BorderColor *pdf.PdfColorDeviceRGB Opacity float64 // Alpha value (0-1). }
ComboboxFieldOptions defines optional parameters for a combobox form field.
type ComboboxFieldOptions struct { // Choices is the list of string values that can be selected. Choices []string }
FieldAppearance implements interface model.FieldAppearanceGenerator and generates appearance streams for fields taking into account what value is in the field. A common use case is for generating the appearance stream prior to flattening fields.
If `OnlyIfMissing` is true, the field appearance is generated only for fields that do not have an appearance stream specified. If `RegenerateTextFields` is true, all text fields are regenerated (even if OnlyIfMissing is true).
type FieldAppearance struct { OnlyIfMissing bool RegenerateTextFields bool // contains filtered or unexported fields }
func (fa FieldAppearance) GenerateAppearanceDict(form *model.PdfAcroForm, field *model.PdfField, wa *model.PdfAnnotationWidget) (*core.PdfObjectDictionary, error)
GenerateAppearanceDict generates an appearance dictionary for widget annotation `wa` for the `field` in `form`. Implements interface model.FieldAppearanceGenerator.
func (fa *FieldAppearance) SetStyle(style AppearanceStyle)
SetStyle applies appearance `style` to `fa`.
func (fa FieldAppearance) Style() AppearanceStyle
Style returns the appearance style of `fa`. If not specified, returns default style.
func (fa FieldAppearance) WrapContentStream(page *model.PdfPage) error
WrapContentStream ensures that the entire content stream for a `page` is wrapped within q ... Q operands. Ensures that following operands that are added are not affected by additional operands that are added. Implements interface model.ContentStreamWrapper.
LineAnnotationDef defines a line between point 1 (X1,Y1) and point 2 (X2,Y2). The line ending styles can be none (regular line), or arrows at either end. The line also has a specified width, color and opacity.
type LineAnnotationDef struct { X1 float64 Y1 float64 X2 float64 Y2 float64 LineColor *pdf.PdfColorDeviceRGB Opacity float64 // Alpha value (0-1). LineWidth float64 LineEndingStyle1 draw.LineEndingStyle // Line ending style of point 1. LineEndingStyle2 draw.LineEndingStyle // Line ending style of point 2. }
RectangleAnnotationDef is a rectangle defined with a specified Width and Height and a lower left corner at (X,Y). The rectangle can optionally have a border and a filling color. The Width/Height includes the border (if any specified).
type RectangleAnnotationDef struct { X float64 Y float64 Width float64 Height float64 FillEnabled bool // Show fill? FillColor *pdf.PdfColorDeviceRGB BorderEnabled bool // Show border? BorderWidth float64 BorderColor *pdf.PdfColorDeviceRGB Opacity float64 // Alpha value (0-1). }
SignatureFieldOpts represents a set of options used to configure an appearance widget dictionary.
type SignatureFieldOpts struct { // Rect represents the area the signature annotation is displayed on. Rect []float64 // AutoSize specifies if the content of the appearance should be // scaled to fit in the annotation rectangle. AutoSize bool // Font specifies the font of the text content. Font *model.PdfFont // FontSize specifies the size of the text content. FontSize float64 // LineHeight specifies the height of a line of text in the appearance annotation. LineHeight float64 // TextColor represents the color of the text content displayed. TextColor model.PdfColor // FillColor represents the background color of the appearance annotation area. FillColor model.PdfColor // BorderSize represents border size of the appearance annotation area. BorderSize float64 // BorderColor represents the border color of the appearance annotation area. BorderColor model.PdfColor // WatermarkImage specifies the image used as a watermark that will be rendered // behind the signature. WatermarkImage image.Image // Image represents the image used for the signature appearance. Image image.Image // Encoder specifies the image encoder used for image signature. Defaults to flate encoder. Encoder core.StreamEncoder // ImagePosition specifies the image location relative to the text signature. ImagePosition SignatureImagePosition }
func NewSignatureFieldOpts() *SignatureFieldOpts
NewSignatureFieldOpts returns a new initialized instance of options used to generate a signature appearance.
SignatureImagePosition specifies the image signature location relative to the text signature. If text signature is not defined, this position will be ignored.
type SignatureImagePosition int
const ( // SignatureImageLeft specifies that the image is rendered on the left of the text signature. SignatureImageLeft SignatureImagePosition = iota // SignatureImageRight specifies that the image is rendered on the right of the text signature. SignatureImageRight // SignatureImageTop specifies that the image is rendered on the top of the text signature. SignatureImageTop // SignatureImageBottom specifies that the image is rendered on the bottom of the text signature. SignatureImageBottom )
SignatureLine represents a line of information in the signature field appearance.
type SignatureLine struct { Desc string Text string }
func NewSignatureLine(desc, text string) *SignatureLine
NewSignatureLine returns a new signature line displayed as a part of the signature field appearance.
TextFieldOptions defines optional parameter for a text field in a form.
type TextFieldOptions struct { MaxLen int // Ignored if <= 0. Value string // Ignored if empty (""). }