const ( // RC4_128bit uses RC4 encryption (128 bit) RC4_128bit = EncryptionAlgorithm(iota) // AES_128bit uses AES encryption (128 bit, PDF 1.6) AES_128bit // AES_256bit uses AES encryption (256 bit, PDF 2.0) AES_256bit )
Errors when parsing/loading data in PDF. TODO(gunnsth): Unexport errors except if there is a clear use case.
var ( ErrRequiredAttributeMissing = errors.New("required attribute missing") ErrInvalidAttribute = errors.New("invalid attribute") ErrTypeCheck = errors.New("type check") ErrEncrypted = errors.New("file needs to be decrypted first") ErrNoFont = errors.New("font not defined") ErrFontNotSupported = xerrors.Errorf("unsupported font (%w)", core.ErrNotSupported) ErrType1CFontNotSupported = xerrors.Errorf("Type1C fonts are not currently supported (%w)", core.ErrNotSupported) ErrType3FontNotSupported = xerrors.Errorf("Type3 fonts are not currently supported (%w)", core.ErrNotSupported) ErrTTCmapNotSupported = xerrors.Errorf("unsupported TrueType cmap format (%w)", core.ErrNotSupported) ErrSignNotEnoughSpace = xerrors.Errorf("insufficient space allocated for the signature contents") ErrSignNoCertificates = xerrors.Errorf("could not retrieve certificate chain") )
Names of the standard 14 fonts.
var ( CourierName = fonts.CourierName CourierBoldName = fonts.CourierBoldName CourierObliqueName = fonts.CourierObliqueName CourierBoldObliqueName = fonts.CourierBoldObliqueName HelveticaName = fonts.HelveticaName HelveticaBoldName = fonts.HelveticaBoldName HelveticaObliqueName = fonts.HelveticaObliqueName HelveticaBoldObliqueName = fonts.HelveticaBoldObliqueName SymbolName = fonts.SymbolName ZapfDingbatsName = fonts.ZapfDingbatsName TimesRomanName = fonts.TimesRomanName TimesBoldName = fonts.TimesBoldName TimesItalicName = fonts.TimesItalicName TimesBoldItalicName = fonts.TimesBoldItalicName )
ErrColorOutOfRange returned when value of a color is out of colorspace range.
var ErrColorOutOfRange = errors.New("color out of range")
func DetermineColorspaceNameFromPdfObject(obj core.PdfObject) (core.PdfObjectName, error)
DetermineColorspaceNameFromPdfObject determines PDF colorspace from a PdfObject. Returns the colorspace name and an error on failure. If the colorspace was not found, will return an empty string.
func GetAlphabet(text string) map[rune]int
GetAlphabet returns a map of the runes in `text` and their frequencies.
func SetImageHandler(imgHandling ImageHandler)
SetImageHandler sets the image handler used by the package.
func SetPdfAuthor(author string)
SetPdfAuthor sets the Author attribute of the output PDF.
func SetPdfCreationDate(creationDate time.Time)
SetPdfCreationDate sets the CreationDate attribute of the output PDF.
func SetPdfCreator(creator string)
SetPdfCreator sets the Creator attribute of the output PDF.
func SetPdfKeywords(keywords string)
SetPdfKeywords sets the Keywords attribute of the output PDF.
func SetPdfModifiedDate(modifiedDate time.Time)
SetPdfModifiedDate sets the ModDate attribute of the output PDF.
func SetPdfProducer(producer string)
SetPdfProducer sets the Producer attribute of the output PDF.
func SetPdfSubject(subject string)
SetPdfSubject sets the Subject attribute of the output PDF.
func SetPdfTitle(title string)
SetPdfTitle sets the Title attribute of the output PDF.
AcroFormRepairOptions contains options for rebuilding the AcroForm.
type AcroFormRepairOptions struct { }
AlphaMapFunc represents a alpha mapping function: byte -> byte. Can be used for thresholding the alpha channel, i.e. setting all alpha values below threshold to transparent.
type AlphaMapFunc func(alpha byte) byte
AnnotFilterFunc represents a PDF annotation filtering function. If the function returns true, the annotation is kept, otherwise it is discarded.
type AnnotFilterFunc func(*PdfAnnotation) bool
BorderEffect represents a border effect (Table 167 p. 395).
type BorderEffect int
const ( // BorderEffectNoEffect represents no border effect. BorderEffectNoEffect BorderEffect = iota // BorderEffectCloudy represents a cloudy border effect. BorderEffectCloudy BorderEffect = iota )
BorderStyle defines border type, typically used for annotations.
type BorderStyle int
const ( // BorderStyleSolid represents a solid border. BorderStyleSolid BorderStyle = iota // BorderStyleDashed represents a dashed border. BorderStyleDashed BorderStyle = iota // BorderStyleBeveled represents a beveled border. BorderStyleBeveled BorderStyle = iota // BorderStyleInset represents an inset border. BorderStyleInset BorderStyle = iota // BorderStyleUnderline represents an underline border. BorderStyleUnderline BorderStyle = iota )
func (bs *BorderStyle) GetPdfName() string
GetPdfName returns the PDF name used to indicate the border style. (Table 166 p. 395).
ButtonType represents the subtype of a button field, can be one of: - Checkbox (ButtonTypeCheckbox) - PushButton (ButtonTypePushButton) - RadioButton (ButtonTypeRadioButton)
type ButtonType int
Definitions for field button types
const ( ButtonTypeCheckbox ButtonType = iota ButtonTypePush ButtonType = iota ButtonTypeRadio ButtonType = iota )
CharMetrics represents width and height metrics of a glyph.
type CharMetrics = fonts.CharMetrics
CompliancePdfReader is a wrapper over PdfReader that is used for verifying if the input Pdf document matches the compliance rules of standards like PDF/A. NOTE: This implementation is in experimental development state.
Keep in mind that it might change in the subsequent minor versions.
type CompliancePdfReader struct { *PdfReader // contains filtered or unexported fields }
func NewCompliancePdfReader(rs io.ReadSeeker) (*CompliancePdfReader, error)
NewCompliancePdfReader creates a PdfReader or an input io.ReadSeeker that during reading will scan the files for the metadata details. It could be used for the PDF standard implementations like PDF/A or PDF/X. NOTE: This implementation is in experimental development state.
Keep in mind that it might change in the subsequent minor versions.
func (r *CompliancePdfReader) ParserMetadata() core.ParserMetadata
ParserMetadata gets the parser metadata.
ContentStreamWrapper wraps the Page's contentstream into q ... Q blocks.
type ContentStreamWrapper interface { WrapContentStream(page *PdfPage) error }
DSS represents a Document Security Store dictionary. The DSS dictionary contains both global and signature specific validation information. The certificates and revocation data in the `Certs`, `OCSPs`, and `CRLs` fields can be used to validate any signature in the document. Additionally, the VRI entry contains validation data per signature. The keys in the VRI entry are calculated as upper(hex(sha1(sig.Contents))). The values are VRI dictionaries containing certificates and revocation information used for validating a single signature. See ETSI TS 102 778-4 V1.1.1 for more information.
type DSS struct { Certs []*core.PdfObjectStream OCSPs []*core.PdfObjectStream CRLs []*core.PdfObjectStream VRI map[string]*VRI // contains filtered or unexported fields }
func NewDSS() *DSS
NewDSS returns a new DSS dictionary.
func (dss *DSS) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject returns the container of the DSS (indirect object).
func (dss *DSS) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the DSS dictionary.
DefaultImageHandler is the default implementation of the ImageHandler using the standard go library.
type DefaultImageHandler struct{}
func (ih DefaultImageHandler) Compress(input *Image, quality int64) (*Image, error)
Compress is yet to be implemented. Should be able to compress in terms of JPEG quality parameter, and DPI threshold (need to know bounding area dimensions).
func (ih DefaultImageHandler) NewGrayImageFromGoImage(goimg goimage.Image) (*Image, error)
NewGrayImageFromGoImage creates a new grayscale unidoc Image from a golang Image.
func (ih DefaultImageHandler) NewImageFromGoImage(goimg goimage.Image) (*Image, error)
NewImageFromGoImage creates a new NRGBA32 unidoc Image from a golang Image. If `goimg` is grayscale (*goimage.Gray8) then calls NewGrayImageFromGoImage instead.
func (ih DefaultImageHandler) Read(reader io.Reader) (*Image, error)
Read reads an image and loads into a new Image object with an RGB colormap and 8 bits per component.
EncryptOptions represents encryption options for an output PDF.
type EncryptOptions struct { Permissions security.Permissions Algorithm EncryptionAlgorithm }
EncryptionAlgorithm is used in EncryptOptions to change the default algorithm used to encrypt the document.
type EncryptionAlgorithm int
FieldAppearanceGenerator generates appearance stream for a given field.
type FieldAppearanceGenerator interface { ContentStreamWrapper GenerateAppearanceDict(form *PdfAcroForm, field *PdfField, wa *PdfAnnotationWidget) (*core.PdfObjectDictionary, error) }
FieldFilterFunc represents a PDF field filtering function. If the function returns true, the PDF field is kept, otherwise it is discarded.
type FieldFilterFunc func(*PdfField) bool
FieldFlag represents form field flags. Some of the flags can apply to all types of fields whereas other flags are specific.
type FieldFlag uint32
The following constants define bitwise flag representing different attributes of a form field.
const ( // FieldFlagClear has no flags. FieldFlagClear FieldFlag = 0 FieldFlagReadOnly FieldFlag = 1 FieldFlagRequired FieldFlag = (1 << 1) FieldFlagNoExport FieldFlag = (2 << 1) FieldFlagNoToggleToOff FieldFlag = (1 << 14) FieldFlagRadio FieldFlag = (1 << 15) FieldFlag = (1 << 16) FieldFlagRadiosInUnision FieldFlag = (1 << 25) FieldFlagMultiline FieldFlag = (1 << 12) FieldFlagPassword FieldFlag = (1 << 13) FieldFlagFileSelect FieldFlag = (1 << 20) FieldFlagDoNotScroll FieldFlag = (1 << 23) FieldFlagComb FieldFlag = (1 << 24) FieldFlagRichText FieldFlag = (1 << 26) FieldFlagDoNotSpellCheck FieldFlag = (1 << 22) FieldFlagCombo FieldFlag = (1 << 17) FieldFlagEdit FieldFlag = (1 << 18) FieldFlagSort FieldFlag = (1 << 19) FieldFlagMultiSelect FieldFlag = (1 << 21) FieldFlagCommitOnSelChange FieldFlag = (1 << 27) )
func (flag FieldFlag) Clear(fl FieldFlag) FieldFlag
Clear clears flag fl from the flag and returns the resulting flag.
func (flag FieldFlag) Has(fl FieldFlag) bool
Has checks if flag fl is set in flag and returns true if so, false otherwise.
func (flag FieldFlag) Mask() uint32
Mask returns the uin32 bitmask for the specific flag.
func (flag FieldFlag) Set(fl FieldFlag) FieldFlag
Set applies flag fl to the flag's bitmask and returns the combined flag.
func (flag FieldFlag) String() string
String returns a string representation of what flags are set.
FieldFlattenOpts defines a set of options which can be used to configure the field flattening process.
type FieldFlattenOpts struct { // FilterFunc allows filtering the form fields used in the flattening // process. If the filter function returns true, the field is flattened, // otherwise it is skipped. // If a non-terminal field is discarded, all of its children (the fields // present in the Kids array) are discarded as well. // Non-terminal fields are kept in the AcroForm if one or more of their // child fields have not been selected for flattening. // If a filter function is not provided, all form fields are flattened. FilterFunc FieldFilterFunc // AnnotFilterFunc allows filtering the annotations in the flattening // process. If the filter function returns true, the annotation is flattened, // otherwise it is skipped. AnnotFilterFunc AnnotFilterFunc }
FieldImageProvider provides fields images for specified fields.
type FieldImageProvider interface { FieldImageValues() (map[string]*Image, error) }
FieldValueProvider provides field values from a data source such as FDF, JSON or any other.
type FieldValueProvider interface { FieldValues() (map[string]core.PdfObject, error) }
Hasher is the interface that wraps the basic Write method.
type Hasher interface { Write(p []byte) (n int, err error) }
Image interface is a basic representation of an image used in PDF. The colorspace is not specified, but must be known when handling the image.
type Image struct { Width int64 // The width of the image in samples Height int64 // The height of the image in samples BitsPerComponent int64 // The number of bits per color component ColorComponents int // Color components per pixel Data []byte // Image data stored as bytes. // contains filtered or unexported fields }
func (img *Image) AlphaMap(mapFunc AlphaMapFunc)
AlphaMap performs mapping of alpha data for transformations. Allows custom filtering of alpha data etc.
func (img *Image) ColorAt(x, y int) (gocolor.Color, error)
ColorAt returns the color of the image pixel specified by the x and y coordinates.
func (img *Image) ConvertToBinary() error
ConvertToBinary converts current image into binary (bi-level) format. Binary images are composed of single bits per pixel (only black or white). If provided image has more color components, then it would be converted into binary image using histogram auto threshold function.
func (img *Image) GetParamsDict() *core.PdfObjectDictionary
GetParamsDict returns *core.PdfObjectDictionary with a set of basic image parameters.
func (img *Image) GetSamples() []uint32
GetSamples converts the raw byte slice into samples which are stored in a uint32 bit array. Each sample is represented by BitsPerComponent consecutive bits in the raw data. NOTE: The method resamples the image byte data before returning the result and this could lead to high memory usage, especially on large images. It should be avoided, when possible. It is recommended to access the Data field of the image directly or use the ColorAt method to extract individual pixels.
func (img *Image) Resample(targetBitsPerComponent int64)
Resample resamples the image data converting from current BitsPerComponent to a target BitsPerComponent value. Sets the image's BitsPerComponent to the target value following resampling.
For example, converting an 8-bit RGB image to 1-bit grayscale (common for scanned images):
// Convert RGB image to grayscale. rgbColorSpace := pdf.NewPdfColorspaceDeviceRGB() grayImage, err := rgbColorSpace.ImageToGray(rgbImage) if err != nil { return err } // Resample as 1 bit. grayImage.Resample(1)
func (img *Image) SetAlpha(alpha []byte)
SetAlpha sets the alpha layer for the image.
func (img *Image) SetDecode(decode []float64)
SetDecode sets the decode image float slice.
func (img *Image) SetSamples(samples []uint32)
SetSamples convert samples to byte-data and sets for the image. NOTE: The method resamples the data and this could lead to high memory usage, especially on large images. It should be used only when it is not possible to work with the image byte data directly.
func (img *Image) ToGoImage() (goimage.Image, error)
ToGoImage converts the unidoc Image to a golang Image structure.
func (img *Image) ToJBIG2Image() (*core.JBIG2Image, error)
ToJBIG2Image converts current image to the core.JBIG2Image.
ImageHandler interface implements common image loading and processing tasks. Implementing as an interface allows for the possibility to use non-standard libraries for faster loading and processing of images.
type ImageHandler interface { // Read any image type and load into a new Image object. Read(r io.Reader) (*Image, error) // NewImageFromGoImage loads a NRGBA32 unidoc Image from a standard Go image structure. NewImageFromGoImage(goimg goimage.Image) (*Image, error) // NewGrayImageFromGoImage loads a grayscale unidoc Image from a standard Go image structure. NewGrayImageFromGoImage(goimg goimage.Image) (*Image, error) // Compress an image. Compress(input *Image, quality int64) (*Image, error) }
ImageHandling is used for handling images.
var ImageHandling ImageHandler = DefaultImageHandler{}
LTV represents an LTV (Long-Term Validation) client. It is used to LTV enable signatures by adding validation and revocation data (certificate, OCSP and CRL information) to the DSS dictionary of a PDF document.
LTV is added through the DSS by: - Adding certificates, OCSP and CRL information in the global scope of the
DSS. The global data is used for validating any of the signatures present in the document.
- Adding certificates, OCSP and CRL information for a single signature,
through an entry in the VRI dictionary of the DSS. The added data is used for validating that particular signature only. This is the recommended method for adding validation data for a signature. However, this is not is not possible in the same revision the signature is applied. Validation data for a signature is added based on the Contents entry of the signature, which is known only after the revision is written. Even if the Contents are known (e.g. when signing externally), updating the DSS at that point would invalidate the calculated signature. As a result, if adding LTV in the same revision is a requirement, use the first method. See LTV.EnableChain.
The client applies both methods, when possible.
If `LTV.SkipExisting` is set to true (the default), validations are not added for signatures which are already present in the VRI entry of the document's DSS dictionary.
type LTV struct { // CertClient is the client used to retrieve certificates. CertClient *sigutil.CertClient // OCSPClient is the client used to retrieve OCSP validation information. OCSPClient *sigutil.OCSPClient // CRLClient is the client used to retrieve CRL validation information. CRLClient *sigutil.CRLClient // SkipExisting specifies whether existing signature validations // should be skipped. SkipExisting bool // contains filtered or unexported fields }
func NewLTV(appender *PdfAppender) (*LTV, error)
NewLTV returns a new LTV client.
func (l *LTV) Enable(sig *PdfSignature, extraCerts []*x509.Certificate) error
Enable LTV enables the specified signature. The signing certificate chain is extracted from the signature dictionary. Optionally, additional certificates can be specified through the `extraCerts` parameter. The LTV client attempts to build the certificate chain up to a trusted root by downloading any missing certificates.
func (l *LTV) EnableAll(extraCerts []*x509.Certificate) error
EnableAll LTV enables all signatures in the PDF document. The signing certificate chain is extracted from each signature dictionary. Optionally, additional certificates can be specified through the `extraCerts` parameter. The LTV client attempts to build the certificate chain up to a trusted root by downloading any missing certificates.
func (l *LTV) EnableByName(name string, extraCerts []*x509.Certificate) error
EnableByName LTV enables the signature dictionary of the PDF AcroForm field identified the specified name. The signing certificate chain is extracted from the signature dictionary. Optionally, additional certificates can be specified through the `extraCerts` parameter. The LTV client attempts to build the certificate chain up to a trusted root by downloading any missing certificates.
func (l *LTV) EnableChain(chain []*x509.Certificate) error
EnableChain adds the specified certificate chain and validation data (OCSP and CRL information) for it to the global scope of the document DSS. The added data is used for validating any of the signatures present in the document. The LTV client attempts to build the certificate chain up to a trusted root by downloading any missing certificates.
Optimizer is the interface that performs optimization of PDF object structure for output writing.
Optimize receives a slice of input `objects`, performs optimization, including removing, replacing objects and output the optimized slice of objects.
type Optimizer interface { Optimize(objects []core.PdfObject) ([]core.PdfObject, error) }
Outline represents a PDF outline dictionary (Table 152 - p. 376). Currently, the Outline object can only be used to construct PDF outlines.
type Outline struct { Entries []*OutlineItem `json:"entries,omitempty"` }
func NewOutline() *Outline
NewOutline returns a new outline instance.
func (o *Outline) Add(item *OutlineItem)
Add appends a top level outline item to the outline.
func (o *Outline) Insert(index uint, item *OutlineItem)
Insert adds a top level outline item in the outline, at the specified index.
func (o *Outline) Items() []*OutlineItem
Items returns all children outline items.
func (o *Outline) ToOutlineTree() *PdfOutlineTreeNode
ToOutlineTree returns a low level PdfOutlineTreeNode object, based on the current instance.
func (o *Outline) ToPdfObject() core.PdfObject
ToPdfObject returns a PDF object representation of the outline.
func (o *Outline) ToPdfOutline() *PdfOutline
ToPdfOutline returns a low level PdfOutline object, based on the current instance.
OutlineDest represents the destination of an outline item. It holds the page and the position on the page an outline item points to.
type OutlineDest struct { PageObj *core.PdfIndirectObject `json:"-"` Page int64 `json:"page"` Mode string `json:"mode"` X float64 `json:"x"` Y float64 `json:"y"` Zoom float64 `json:"zoom"` }
func NewOutlineDest(page int64, x, y float64) OutlineDest
NewOutlineDest returns a new outline destination which can be used with outline items.
func (od OutlineDest) ToPdfObject() core.PdfObject
ToPdfObject returns a PDF object representation of the outline destination.
OutlineItem represents a PDF outline item dictionary (Table 153 - pp. 376 - 377).
type OutlineItem struct { Title string `json:"title"` Dest OutlineDest `json:"dest"` Entries []*OutlineItem `json:"entries,omitempty"` }
func NewOutlineItem(title string, dest OutlineDest) *OutlineItem
NewOutlineItem returns a new outline item instance.
func (oi *OutlineItem) Add(item *OutlineItem)
Add appends an outline item as a child of the current outline item.
func (oi *OutlineItem) Insert(index uint, item *OutlineItem)
Insert adds an outline item as a child of the current outline item, at the specified index.
func (oi *OutlineItem) Items() []*OutlineItem
Items returns all children outline items.
func (oi *OutlineItem) ToPdfObject() core.PdfObject
ToPdfObject returns a PDF object representation of the outline item.
func (oi *OutlineItem) ToPdfOutlineItem() (*PdfOutlineItem, int64)
ToPdfOutlineItem returns a low level PdfOutlineItem object, based on the current instance.
PageCallback callback function used in page loading that could be used to modify the page content.
Deprecated: will be removed in v4. Use PageProcessCallback instead.
type PageCallback func(pageNum int, page *PdfPage)
PageProcessCallback callback function used in page loading that could be used to modify the page content.
If an error is returned, the `ToWriter` process would fail.
This callback, if defined, will take precedence over `PageCallback` callback.
type PageProcessCallback func(pageNum int, page *PdfPage) error
PdfAcroForm represents the AcroForm dictionary used for representation of form data in PDF.
type PdfAcroForm struct { Fields *[]*PdfField NeedAppearances *core.PdfObjectBool SigFlags *core.PdfObjectInteger CO *core.PdfObjectArray DR *PdfPageResources DA *core.PdfObjectString Q *core.PdfObjectInteger XFA core.PdfObject // contains filtered or unexported fields }
func NewPdfAcroForm() *PdfAcroForm
NewPdfAcroForm returns a new PdfAcroForm with an intialized container (indirect object).
func (form *PdfAcroForm) AllFields() []*PdfField
AllFields returns a flattened list of all fields in the form.
func (form *PdfAcroForm) Fill(provider FieldValueProvider) error
Fill populates `form` with values provided by `provider`.
func (form *PdfAcroForm) FillWithAppearance(provider FieldValueProvider, appGen FieldAppearanceGenerator) error
FillWithAppearance populates `form` with values provided by `provider`. If not nil, `appGen` is used to generate appearance dictionaries for the field annotations, based on the specified settings. Otherwise, appearance generation is skipped. e.g.: appGen := annotator.FieldAppearance{OnlyIfMissing: true, RegenerateTextFields: true} NOTE: In next major version this functionality will be part of Fill. (v4)
func (form *PdfAcroForm) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject returns the container of the PdfAcroForm (indirect object).
func (form *PdfAcroForm) ToPdfObject() core.PdfObject
ToPdfObject converts PdfAcroForm to a PdfObject, i.e. an indirect object containing the AcroForm dictionary.
PdfAction represents an action in PDF (section 12.6 p. 412).
type PdfAction struct { Type core.PdfObject S core.PdfObject Next core.PdfObject // contains filtered or unexported fields }
func NewPdfAction() *PdfAction
NewPdfAction returns an initialized generic PDF action model.
func (a *PdfAction) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject implements interface PdfModel.
func (a *PdfAction) GetContext() PdfModel
GetContext returns the action context which contains the specific type-dependent context. The context represents the subaction.
func (a *PdfAction) SetContext(ctx PdfModel)
SetContext sets the sub action (context).
func (a *PdfAction) String() string
String implements interface PdfObject.
func (a *PdfAction) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionGoTo represents a GoTo action.
type PdfActionGoTo struct { *PdfAction D core.PdfObject // name, byte string or array }
func NewPdfActionGoTo() *PdfActionGoTo
NewPdfActionGoTo returns a new "go to" action.
func (gotoAct *PdfActionGoTo) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionGoTo3DView represents a GoTo3DView action.
type PdfActionGoTo3DView struct { *PdfAction TA core.PdfObject V core.PdfObject }
func NewPdfActionGoTo3DView() *PdfActionGoTo3DView
NewPdfActionGoTo3DView returns a new "goTo3DView" action.
func (goTo3DViewAct *PdfActionGoTo3DView) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionGoToE represents a GoToE action.
type PdfActionGoToE struct { *PdfAction F *PdfFilespec D core.PdfObject // name, byte string or array NewWindow core.PdfObject T core.PdfObject }
func NewPdfActionGoToE() *PdfActionGoToE
NewPdfActionGoToE returns a new "go to embedded" action.
func (gotoEAct *PdfActionGoToE) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionGoToR represents a GoToR action.
type PdfActionGoToR struct { *PdfAction F *PdfFilespec D core.PdfObject // name, byte string or array NewWindow core.PdfObject }
func NewPdfActionGoToR() *PdfActionGoToR
NewPdfActionGoToR returns a new "go to remote" action.
func (gotoRAct *PdfActionGoToR) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionHide represents a hide action.
type PdfActionHide struct { *PdfAction T core.PdfObject H core.PdfObject }
func NewPdfActionHide() *PdfActionHide
NewPdfActionHide returns a new "hide" action.
func (hideAct *PdfActionHide) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionImportData represents a importData action.
type PdfActionImportData struct { *PdfAction F *PdfFilespec }
func NewPdfActionImportData() *PdfActionImportData
NewPdfActionImportData returns a new "import data" action.
func (importDataAct *PdfActionImportData) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionJavaScript represents a javaScript action.
type PdfActionJavaScript struct { *PdfAction JS core.PdfObject }
func NewPdfActionJavaScript() *PdfActionJavaScript
NewPdfActionJavaScript returns a new "javaScript" action.
func (javaScriptAct *PdfActionJavaScript) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionLaunch represents a launch action.
type PdfActionLaunch struct { *PdfAction F *PdfFilespec Win core.PdfObject Mac core.PdfObject Unix core.PdfObject NewWindow core.PdfObject }
func NewPdfActionLaunch() *PdfActionLaunch
NewPdfActionLaunch returns a new "launch" action.
func (launchAct *PdfActionLaunch) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionMovie represents a movie action.
type PdfActionMovie struct { *PdfAction Annotation core.PdfObject T core.PdfObject Operation core.PdfObject }
func NewPdfActionMovie() *PdfActionMovie
NewPdfActionMovie returns a new "movie" action.
func (movieAct *PdfActionMovie) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionNamed represents a named action.
type PdfActionNamed struct { *PdfAction N core.PdfObject }
func NewPdfActionNamed() *PdfActionNamed
NewPdfActionNamed returns a new "named" action.
func (namedAct *PdfActionNamed) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionRendition represents a Rendition action.
type PdfActionRendition struct { *PdfAction R core.PdfObject AN core.PdfObject OP core.PdfObject JS core.PdfObject }
func NewPdfActionRendition() *PdfActionRendition
NewPdfActionRendition returns a new "rendition" action.
func (renditionAct *PdfActionRendition) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionResetForm represents a resetForm action.
type PdfActionResetForm struct { *PdfAction Fields core.PdfObject Flags core.PdfObject }
func NewPdfActionResetForm() *PdfActionResetForm
NewPdfActionResetForm returns a new "reset form" action.
func (resetFormAct *PdfActionResetForm) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionSetOCGState represents a SetOCGState action.
type PdfActionSetOCGState struct { *PdfAction State core.PdfObject PreserveRB core.PdfObject }
func NewPdfActionSetOCGState() *PdfActionSetOCGState
NewPdfActionSetOCGState returns a new "named" action.
func (setOCGStateAct *PdfActionSetOCGState) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionSound represents a sound action.
type PdfActionSound struct { *PdfAction Sound core.PdfObject Volume core.PdfObject Synchronous core.PdfObject Repeat core.PdfObject Mix core.PdfObject }
func NewPdfActionSound() *PdfActionSound
NewPdfActionSound returns a new "sound" action.
func (soundAct *PdfActionSound) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionSubmitForm represents a submitForm action.
type PdfActionSubmitForm struct { *PdfAction F *PdfFilespec Fields core.PdfObject Flags core.PdfObject }
func NewPdfActionSubmitForm() *PdfActionSubmitForm
NewPdfActionSubmitForm returns a new "submit form" action.
func (submitFormAct *PdfActionSubmitForm) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionThread represents a thread action.
type PdfActionThread struct { *PdfAction F *PdfFilespec D core.PdfObject B core.PdfObject }
func NewPdfActionThread() *PdfActionThread
NewPdfActionThread returns a new "thread" action.
func (threadAct *PdfActionThread) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionTrans represents a trans action.
type PdfActionTrans struct { *PdfAction Trans core.PdfObject }
func NewPdfActionTrans() *PdfActionTrans
NewPdfActionTrans returns a new "trans" action.
func (transAct *PdfActionTrans) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfActionType represents an action type in PDF (section 12.6.4 p. 417).
type PdfActionType string
(Section 12.6.4 p. 417). See Table 198 - Action types
const ( ActionTypeGoTo PdfActionType = "GoTo" // Go to a destination in the current document ActionTypeGoTo3DView PdfActionType = "GoTo3DView" // Set the current view of a 3D annotation ActionTypeGoToE PdfActionType = "GoToE" // Go to embedded, PDF 1.6, Got to a destination in an embedded file ActionTypeGoToR PdfActionType = "GoToR" // Go to remote, Go to a destination in another document ActionTypeHide PdfActionType = "Hide" // Set an annotation's Hidden flag ActionTypeImportData PdfActionType = "ImportData" // Import field values from a file ActionTypeJavaScript PdfActionType = "JavaScript" // Execute a JavaScript script ActionTypeLaunch PdfActionType = "Launch" // Launch an application, usually to open a file ActionTypeMovie PdfActionType = "Movie" // Play a movie ActionTypeNamed PdfActionType = "Named" // Execute an action predefined by the conforming reader ActionTypeRendition PdfActionType = "Rendition" // Controls the playing of multimedia content ActionTypeResetForm PdfActionType = "ResetForm" // Set fields to their default values ActionTypeSetOCGState PdfActionType = "SetOCGState" // Set the states of optional content groups ActionTypeSound PdfActionType = "Sound" // Play a sound ActionTypeSubmitForm PdfActionType = "SubmitForm" // Send data to a uniform resource locator ActionTypeThread PdfActionType = "Thread" // Begin reading an article thread ActionTypeTrans PdfActionType = "Trans" // Updates the display of a document, using a transition dictionary ActionTypeURI PdfActionType = "URI" // Resolves a uniform resource identifier )
PdfActionURI represents an URI action.
type PdfActionURI struct { *PdfAction URI core.PdfObject IsMap core.PdfObject }
func NewPdfActionURI() *PdfActionURI
NewPdfActionURI returns a new "Uri" action.
func (uriAct *PdfActionURI) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotation represents an annotation in PDF (section 12.5 p. 389).
type PdfAnnotation struct { Rect core.PdfObject Contents core.PdfObject P core.PdfObject // Reference to page object. NM core.PdfObject M core.PdfObject F core.PdfObject AP core.PdfObject AS core.PdfObject Border core.PdfObject C core.PdfObject StructParent core.PdfObject OC core.PdfObject // contains filtered or unexported fields }
func NewPdfAnnotation() *PdfAnnotation
NewPdfAnnotation returns an initialized generic PDF annotation model.
func (a *PdfAnnotation) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject implements interface PdfModel.
func (a *PdfAnnotation) GetContext() PdfModel
GetContext returns the annotation context which contains the specific type-dependent context. The context represents the subannotation.
func (a *PdfAnnotation) SetContext(ctx PdfModel)
SetContext sets the sub annotation (context).
func (a *PdfAnnotation) String() string
func (a *PdfAnnotation) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel. Note: Call the sub-annotation's ToPdfObject to set both the generic and non-generic information.
PdfAnnotation3D represents 3D annotations. (Section 13.6.2).
type PdfAnnotation3D struct { *PdfAnnotation T3DD core.PdfObject T3DV core.PdfObject T3DA core.PdfObject T3DI core.PdfObject T3DB core.PdfObject }
func NewPdfAnnotation3D() *PdfAnnotation3D
NewPdfAnnotation3D returns a new 3d annotation.
func (a3d *PdfAnnotation3D) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationCaret represents Caret annotations. (Section 12.5.6.11).
type PdfAnnotationCaret struct { *PdfAnnotation *PdfAnnotationMarkup RD core.PdfObject Sy core.PdfObject }
func NewPdfAnnotationCaret() *PdfAnnotationCaret
NewPdfAnnotationCaret returns a new caret annotation.
func (caret *PdfAnnotationCaret) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationCircle represents Circle annotations. (Section 12.5.6.8).
type PdfAnnotationCircle struct { *PdfAnnotation *PdfAnnotationMarkup BS core.PdfObject IC core.PdfObject BE core.PdfObject RD core.PdfObject }
func NewPdfAnnotationCircle() *PdfAnnotationCircle
NewPdfAnnotationCircle returns a new circle annotation.
func (circle *PdfAnnotationCircle) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationFileAttachment represents FileAttachment annotations. (Section 12.5.6.15).
type PdfAnnotationFileAttachment struct { *PdfAnnotation *PdfAnnotationMarkup FS core.PdfObject Name core.PdfObject }
func NewPdfAnnotationFileAttachment() *PdfAnnotationFileAttachment
NewPdfAnnotationFileAttachment returns a new file attachment annotation.
func (file *PdfAnnotationFileAttachment) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationFreeText represents FreeText annotations. (Section 12.5.6.6).
type PdfAnnotationFreeText struct { *PdfAnnotation *PdfAnnotationMarkup DA core.PdfObject Q core.PdfObject RC core.PdfObject DS core.PdfObject CL core.PdfObject IT core.PdfObject BE core.PdfObject RD core.PdfObject BS core.PdfObject LE core.PdfObject }
func NewPdfAnnotationFreeText() *PdfAnnotationFreeText
NewPdfAnnotationFreeText returns a new free text annotation.
func (ft *PdfAnnotationFreeText) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationHighlight represents Highlight annotations. (Section 12.5.6.10).
type PdfAnnotationHighlight struct { *PdfAnnotation *PdfAnnotationMarkup QuadPoints core.PdfObject }
func NewPdfAnnotationHighlight() *PdfAnnotationHighlight
NewPdfAnnotationHighlight returns a new text highlight annotation.
func (hl *PdfAnnotationHighlight) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationInk represents Ink annotations. (Section 12.5.6.13).
type PdfAnnotationInk struct { *PdfAnnotation *PdfAnnotationMarkup InkList core.PdfObject BS core.PdfObject }
func NewPdfAnnotationInk() *PdfAnnotationInk
NewPdfAnnotationInk returns a new ink annotation.
func (ink *PdfAnnotationInk) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationLine represents Line annotations. (Section 12.5.6.7).
type PdfAnnotationLine struct { *PdfAnnotation *PdfAnnotationMarkup L core.PdfObject BS core.PdfObject LE core.PdfObject IC core.PdfObject LL core.PdfObject LLE core.PdfObject Cap core.PdfObject IT core.PdfObject LLO core.PdfObject CP core.PdfObject Measure core.PdfObject CO core.PdfObject }
func NewPdfAnnotationLine() *PdfAnnotationLine
NewPdfAnnotationLine returns a new line annotation.
func (line *PdfAnnotationLine) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationLink represents Link annotations. (Section 12.5.6.5 p. 403).
type PdfAnnotationLink struct { *PdfAnnotation A core.PdfObject Dest core.PdfObject H core.PdfObject PA core.PdfObject QuadPoints core.PdfObject BS core.PdfObject // contains filtered or unexported fields }
func NewPdfAnnotationLink() *PdfAnnotationLink
NewPdfAnnotationLink returns a new link annotation.
func (link *PdfAnnotationLink) GetAction() (*PdfAction, error)
GetAction returns the PDF action for the annotation link.
func (link *PdfAnnotationLink) SetAction(action *PdfAction)
SetAction sets the PDF action for the annotation link.
func (link *PdfAnnotationLink) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationMarkup represents additional fields for mark-up annotations. (Section 12.5.6.2 p. 399).
type PdfAnnotationMarkup struct { T core.PdfObject Popup *PdfAnnotationPopup CA core.PdfObject RC core.PdfObject CreationDate core.PdfObject IRT core.PdfObject Subj core.PdfObject RT core.PdfObject IT core.PdfObject ExData core.PdfObject }
PdfAnnotationMovie represents Movie annotations. (Section 12.5.6.17).
type PdfAnnotationMovie struct { *PdfAnnotation T core.PdfObject Movie core.PdfObject A core.PdfObject }
func NewPdfAnnotationMovie() *PdfAnnotationMovie
NewPdfAnnotationMovie returns a new movie annotation.
func (mov *PdfAnnotationMovie) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationPolyLine represents PolyLine annotations. (Section 12.5.6.9).
type PdfAnnotationPolyLine struct { *PdfAnnotation *PdfAnnotationMarkup Vertices core.PdfObject LE core.PdfObject BS core.PdfObject IC core.PdfObject BE core.PdfObject IT core.PdfObject Measure core.PdfObject }
func NewPdfAnnotationPolyLine() *PdfAnnotationPolyLine
NewPdfAnnotationPolyLine returns a new polyline annotation.
func (polyl *PdfAnnotationPolyLine) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationPolygon represents Polygon annotations. (Section 12.5.6.9).
type PdfAnnotationPolygon struct { *PdfAnnotation *PdfAnnotationMarkup Vertices core.PdfObject LE core.PdfObject BS core.PdfObject IC core.PdfObject BE core.PdfObject IT core.PdfObject Measure core.PdfObject }
func NewPdfAnnotationPolygon() *PdfAnnotationPolygon
NewPdfAnnotationPolygon returns a new polygon annotation.
func (poly *PdfAnnotationPolygon) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationPopup represents Popup annotations. (Section 12.5.6.14).
type PdfAnnotationPopup struct { *PdfAnnotation Parent core.PdfObject Open core.PdfObject }
func NewPdfAnnotationPopup() *PdfAnnotationPopup
NewPdfAnnotationPopup returns a new popup annotation.
func (popup *PdfAnnotationPopup) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationPrinterMark represents PrinterMark annotations. (Section 12.5.6.20).
type PdfAnnotationPrinterMark struct { *PdfAnnotation MN core.PdfObject }
func NewPdfAnnotationPrinterMark() *PdfAnnotationPrinterMark
NewPdfAnnotationPrinterMark returns a new printermark annotation.
func (pm *PdfAnnotationPrinterMark) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationProjection represents Projection annotations.
type PdfAnnotationProjection struct { *PdfAnnotation *PdfAnnotationMarkup }
func NewPdfAnnotationProjection() *PdfAnnotationProjection
NewPdfAnnotationProjection returns a new projection annotation.
func (proj *PdfAnnotationProjection) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationRedact represents Redact annotations. (Section 12.5.6.23).
type PdfAnnotationRedact struct { *PdfAnnotation *PdfAnnotationMarkup QuadPoints core.PdfObject IC core.PdfObject RO core.PdfObject OverlayText core.PdfObject Repeat core.PdfObject DA core.PdfObject Q core.PdfObject }
func NewPdfAnnotationRedact() *PdfAnnotationRedact
NewPdfAnnotationRedact returns a new redact annotation.
func (redact *PdfAnnotationRedact) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationRichMedia represents Rich Media annotations.
type PdfAnnotationRichMedia struct { *PdfAnnotation RichMediaSettings core.PdfObject RichMediaContent core.PdfObject }
func NewPdfAnnotationRichMedia() *PdfAnnotationRichMedia
NewPdfAnnotationRichMedia returns a new rich media annotation.
func (rm *PdfAnnotationRichMedia) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationScreen represents Screen annotations. (Section 12.5.6.18).
type PdfAnnotationScreen struct { *PdfAnnotation T core.PdfObject MK core.PdfObject A core.PdfObject AA core.PdfObject }
func NewPdfAnnotationScreen() *PdfAnnotationScreen
NewPdfAnnotationScreen returns a new screen annotation.
func (scr *PdfAnnotationScreen) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationSound represents Sound annotations. (Section 12.5.6.16).
type PdfAnnotationSound struct { *PdfAnnotation *PdfAnnotationMarkup Sound core.PdfObject Name core.PdfObject }
func NewPdfAnnotationSound() *PdfAnnotationSound
NewPdfAnnotationSound returns a new sound annotation.
func (snd *PdfAnnotationSound) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationSquare represents Square annotations. (Section 12.5.6.8).
type PdfAnnotationSquare struct { *PdfAnnotation *PdfAnnotationMarkup BS core.PdfObject IC core.PdfObject BE core.PdfObject RD core.PdfObject }
func NewPdfAnnotationSquare() *PdfAnnotationSquare
NewPdfAnnotationSquare returns a new square annotation.
func (sq *PdfAnnotationSquare) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationSquiggly represents Squiggly annotations. (Section 12.5.6.10).
type PdfAnnotationSquiggly struct { *PdfAnnotation *PdfAnnotationMarkup QuadPoints core.PdfObject }
func NewPdfAnnotationSquiggly() *PdfAnnotationSquiggly
NewPdfAnnotationSquiggly returns a new text squiggly annotation.
func (squiggly *PdfAnnotationSquiggly) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationStamp represents Stamp annotations. (Section 12.5.6.12).
type PdfAnnotationStamp struct { *PdfAnnotation *PdfAnnotationMarkup Name core.PdfObject }
func NewPdfAnnotationStamp() *PdfAnnotationStamp
NewPdfAnnotationStamp returns a new stamp annotation.
func (stamp *PdfAnnotationStamp) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationStrikeOut represents StrikeOut annotations. (Section 12.5.6.10).
type PdfAnnotationStrikeOut struct { *PdfAnnotation *PdfAnnotationMarkup QuadPoints core.PdfObject }
func NewPdfAnnotationStrikeOut() *PdfAnnotationStrikeOut
NewPdfAnnotationStrikeOut returns a new text strikeout annotation.
func (strikeo *PdfAnnotationStrikeOut) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationText represents Text annotations. (Section 12.5.6.4 p. 402).
type PdfAnnotationText struct { *PdfAnnotation *PdfAnnotationMarkup Open core.PdfObject Name core.PdfObject State core.PdfObject StateModel core.PdfObject }
func NewPdfAnnotationText() *PdfAnnotationText
NewPdfAnnotationText returns a new text annotation.
func (text *PdfAnnotationText) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationTrapNet represents TrapNet annotations. (Section 12.5.6.21).
type PdfAnnotationTrapNet struct { *PdfAnnotation }
func NewPdfAnnotationTrapNet() *PdfAnnotationTrapNet
NewPdfAnnotationTrapNet returns a new trapnet annotation.
func (trapn *PdfAnnotationTrapNet) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationUnderline represents Underline annotations. (Section 12.5.6.10).
type PdfAnnotationUnderline struct { *PdfAnnotation *PdfAnnotationMarkup QuadPoints core.PdfObject }
func NewPdfAnnotationUnderline() *PdfAnnotationUnderline
NewPdfAnnotationUnderline returns a new text underline annotation.
func (underline *PdfAnnotationUnderline) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationWatermark represents Watermark annotations. (Section 12.5.6.22).
type PdfAnnotationWatermark struct { *PdfAnnotation FixedPrint core.PdfObject }
func NewPdfAnnotationWatermark() *PdfAnnotationWatermark
NewPdfAnnotationWatermark returns a new watermark annotation.
func (wm *PdfAnnotationWatermark) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAnnotationWidget represents Widget annotations. Note: Widget annotations are used to display form fields. (Section 12.5.6.19).
type PdfAnnotationWidget struct { *PdfAnnotation H core.PdfObject MK core.PdfObject A core.PdfObject AA core.PdfObject BS core.PdfObject Parent core.PdfObject // contains filtered or unexported fields }
func NewPdfAnnotationWidget() *PdfAnnotationWidget
NewPdfAnnotationWidget returns an initialized annotation widget.
func (widget *PdfAnnotationWidget) Field() *PdfField
Field returns the parent form field of the widget annotation, if one exists. NOTE: the method returns nil if the parent form field has not been parsed.
func (widget *PdfAnnotationWidget) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfAppender appends new PDF content to an existing PDF document via incremental updates.
type PdfAppender struct { Reader *PdfReader // contains filtered or unexported fields }
func NewPdfAppender(reader *PdfReader) (*PdfAppender, error)
NewPdfAppender creates a new Pdf appender from a Pdf reader.
func NewPdfAppenderWithOpts(reader *PdfReader, opts *ReaderOpts, encryptOptions *EncryptOptions) (*PdfAppender, error)
NewPdfAppenderWithOpts creates a new Pdf appender from a Pdf reader with options.
func (a *PdfAppender) AddPages(pages ...*PdfPage)
AddPages adds pages to be appended to the end of the source PDF.
func (a *PdfAppender) MergePageWith(pageNum int, page *PdfPage) error
MergePageWith appends page content to source Pdf file page content.
func (a *PdfAppender) RemovePage(pageNum int)
RemovePage removes a page by number.
func (a *PdfAppender) ReplaceAcroForm(acroForm *PdfAcroForm)
ReplaceAcroForm replaces the acrobat form. It appends a new form to the Pdf which replaces the original AcroForm.
func (a *PdfAppender) ReplacePage(pageNum int, page *PdfPage)
ReplacePage replaces the original page to a new page.
func (a *PdfAppender) SetDSS(dss *DSS)
SetDSS sets the DSS dictionary (ETSI TS 102 778-4 V1.1.1) of the current document revision.
func (a *PdfAppender) SetDocInfo(info *PdfInfo)
SetDocInfo sets the document /Info metadata. This will overwrite any globally declared document info.
func (a *PdfAppender) Sign(pageNum int, field *PdfFieldSignature) error
Sign signs a specific page with a digital signature. The signature field parameter must have a valid signature dictionary specified by its V field.
func (a *PdfAppender) UpdateObject(obj core.PdfObject)
UpdateObject marks `obj` as updated and to be included in the following revision.
func (a *PdfAppender) UpdatePage(page *PdfPage)
UpdatePage updates the `page` in the new revision if it has changed.
func (a *PdfAppender) Write(w io.Writer) error
Write writes the Appender output to io.Writer. It can only be called once and further invocations will result in an error.
func (a *PdfAppender) WriteToFile(outputPath string) error
WriteToFile writes the Appender output to file specified by path.
PdfBorderEffect represents a PDF border effect.
type PdfBorderEffect struct { S *BorderEffect // Border effect type I *float64 // Intensity of the effect }
PdfBorderStyle represents a border style dictionary (12.5.4 Border Styles p. 394).
type PdfBorderStyle struct { W *float64 // Border width S *BorderStyle // Border style D *[]int // Dash array. // contains filtered or unexported fields }
func NewBorderStyle() *PdfBorderStyle
NewBorderStyle returns an initialized PdfBorderStyle.
func (bs *PdfBorderStyle) GetBorderWidth() float64
GetBorderWidth returns the border style's width.
func (bs *PdfBorderStyle) SetBorderWidth(width float64)
SetBorderWidth sets the style's border width.
func (bs *PdfBorderStyle) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfColor interface represents a generic color in PDF.
type PdfColor interface { }
PdfColorCalGray represents a CalGray colorspace.
type PdfColorCalGray float64
func NewPdfColorCalGray(grayVal float64) *PdfColorCalGray
NewPdfColorCalGray returns a new CalGray color.
func (col *PdfColorCalGray) GetNumComponents() int
GetNumComponents returns the number of color components (1 for CalGray).
func (col *PdfColorCalGray) ToInteger(bits int) uint32
ToInteger convert to an integer format.
func (col *PdfColorCalGray) Val() float64
Val returns the value of the color.
PdfColorCalRGB represents a color in the Colorimetric CIE RGB colorspace. A, B, C components Each component is defined in the range 0.0 - 1.0 where 1.0 is the primary intensity.
type PdfColorCalRGB [3]float64
func NewPdfColorCalRGB(a, b, c float64) *PdfColorCalRGB
NewPdfColorCalRGB returns a new CalRBG color.
func (col *PdfColorCalRGB) A() float64
A returns the value of the A component of the color.
func (col *PdfColorCalRGB) B() float64
B returns the value of the B component of the color.
func (col *PdfColorCalRGB) C() float64
C returns the value of the C component of the color.
func (col *PdfColorCalRGB) GetNumComponents() int
GetNumComponents returns the number of color components (3 for CalRGB).
func (col *PdfColorCalRGB) ToInteger(bits int) [3]uint32
ToInteger convert to an integer format.
PdfColorDeviceCMYK is a CMYK32 color, where each component is defined in the range 0.0 - 1.0 where 1.0 is the primary intensity.
type PdfColorDeviceCMYK [4]float64
func NewPdfColorDeviceCMYK(c, m, y, k float64) *PdfColorDeviceCMYK
NewPdfColorDeviceCMYK returns a new CMYK32 color.
func (col *PdfColorDeviceCMYK) C() float64
C returns the value of the cyan component of the color.
func (col *PdfColorDeviceCMYK) GetNumComponents() int
GetNumComponents returns the number of color components (4 for CMYK32).
func (col *PdfColorDeviceCMYK) K() float64
K returns the value of the key component of the color.
func (col *PdfColorDeviceCMYK) M() float64
M returns the value of the magenta component of the color.
func (col *PdfColorDeviceCMYK) ToInteger(bits int) [4]uint32
ToInteger convert to an integer format.
func (col *PdfColorDeviceCMYK) Y() float64
Y returns the value of the yellow component of the color.
PdfColorDeviceGray represents a grayscale color value that shall be represented by a single number in the range 0.0 to 1.0 where 0.0 corresponds to black and 1.0 to white.
type PdfColorDeviceGray float64
func NewPdfColorDeviceGray(grayVal float64) *PdfColorDeviceGray
NewPdfColorDeviceGray returns a new grayscale color based on an input grayscale float value in range [0-1].
func (col *PdfColorDeviceGray) GetNumComponents() int
GetNumComponents returns the number of color components (1 for grayscale).
func (col *PdfColorDeviceGray) ToInteger(bits int) uint32
ToInteger convert to an integer format.
func (col *PdfColorDeviceGray) Val() float64
Val returns the color value.
PdfColorDeviceRGB represents a color in DeviceRGB colorspace with R, G, B components, where component is defined in the range 0.0 - 1.0 where 1.0 is the primary intensity.
type PdfColorDeviceRGB [3]float64
func NewPdfColorDeviceRGB(r, g, b float64) *PdfColorDeviceRGB
NewPdfColorDeviceRGB returns a new PdfColorDeviceRGB based on the r,g,b component values.
func (col *PdfColorDeviceRGB) B() float64
B returns the value of the blue component of the color.
func (col *PdfColorDeviceRGB) G() float64
G returns the value of the green component of the color.
func (col *PdfColorDeviceRGB) GetNumComponents() int
GetNumComponents returns the number of color components (3 for RGB).
func (col *PdfColorDeviceRGB) R() float64
R returns the value of the red component of the color.
func (col *PdfColorDeviceRGB) ToGray() *PdfColorDeviceGray
ToGray returns a PdfColorDeviceGray color based on the current RGB color.
func (col *PdfColorDeviceRGB) ToInteger(bits int) [3]uint32
ToInteger convert to an integer format.
PdfColorLab represents a color in the L*, a*, b* 3 component colorspace. Each component is defined in the range 0.0 - 1.0 where 1.0 is the primary intensity.
type PdfColorLab [3]float64
func NewPdfColorLab(l, a, b float64) *PdfColorLab
NewPdfColorLab returns a new Lab color.
func (col *PdfColorLab) A() float64
A returns the value of the A component of the color.
func (col *PdfColorLab) B() float64
B returns the value of the B component of the color.
func (col *PdfColorLab) GetNumComponents() int
GetNumComponents returns the number of color components (3 for Lab).
func (col *PdfColorLab) L() float64
L returns the value of the L component of the color.
func (col *PdfColorLab) ToInteger(bits int) [3]uint32
ToInteger convert to an integer format.
PdfColorPattern represents a pattern color.
type PdfColorPattern struct { Color PdfColor // Color defined in underlying colorspace. PatternName core.PdfObjectName // Name of the pattern (reference via resource dicts). }
PdfColorspace interface defines the common methods of a PDF colorspace. The colorspace defines the data storage format for each color and color representation.
Device based colorspace, specified by name - /DeviceGray - /DeviceRGB - /DeviceCMYK
CIE based colorspace specified by [name, dictionary] - [/CalGray dict] - [/CalRGB dict] - [/Lab dict] - [/ICCBased dict]
Special colorspaces - /Pattern - /Indexed - /Separation - /DeviceN
Work is in progress to support all colorspaces. At the moment ICCBased color spaces fall back to the alternate colorspace which works OK in most cases. For full color support, will need fully featured ICC support.
type PdfColorspace interface { // String returns the PdfColorspace's name. String() string // ImageToRGB converts an Image in a given PdfColorspace to an RGB image. ImageToRGB(Image) (Image, error) // ColorToRGB converts a single color in a given PdfColorspace to an RGB color. ColorToRGB(color PdfColor) (PdfColor, error) // GetNumComponents returns the number of components in the PdfColorspace. GetNumComponents() int // ToPdfObject returns a PdfObject representation of the PdfColorspace. ToPdfObject() core.PdfObject // ColorFromPdfObjects returns a PdfColor in the given PdfColorspace from an array of PdfObject where each // PdfObject represents a numeric value. ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error) // ColorFromFloats returns a new PdfColor based on input color components for a given PdfColorspace. ColorFromFloats(vals []float64) (PdfColor, error) // DecodeArray returns the Decode array for the PdfColorSpace, i.e. the range of each component. DecodeArray() []float64 }
func NewPdfColorspaceFromPdfObject(obj core.PdfObject) (PdfColorspace, error)
NewPdfColorspaceFromPdfObject loads a PdfColorspace from a PdfObject. Returns an error if there is a failure in loading.
PdfColorspaceCalGray represents CalGray color space.
type PdfColorspaceCalGray struct { WhitePoint []float64 // [XW, YW, ZW]: Required BlackPoint []float64 // [XB, YB, ZB] Gamma float64 // contains filtered or unexported fields }
func NewPdfColorspaceCalGray() *PdfColorspaceCalGray
NewPdfColorspaceCalGray returns a new CalGray colorspace object.
func (cs *PdfColorspaceCalGray) ColorFromFloats(vals []float64) (PdfColor, error)
ColorFromFloats returns a new PdfColor based on the input slice of color components. The slice should contain a single element between 0 and 1.
func (cs *PdfColorspaceCalGray) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)
ColorFromPdfObjects returns a new PdfColor based on the input slice of color components. The slice should contain a single PdfObjectFloat element in range 0-1.
func (cs *PdfColorspaceCalGray) ColorToRGB(color PdfColor) (PdfColor, error)
ColorToRGB converts a CalGray color to an RGB color.
func (cs *PdfColorspaceCalGray) DecodeArray() []float64
DecodeArray returns the range of color component values in CalGray colorspace.
func (cs *PdfColorspaceCalGray) GetNumComponents() int
GetNumComponents returns the number of color components of the colorspace device. Returns 1 for a CalGray device.
func (cs *PdfColorspaceCalGray) ImageToRGB(img Image) (Image, error)
ImageToRGB converts image in CalGray color space to RGB (A, B, C -> X, Y, Z).
func (cs *PdfColorspaceCalGray) String() string
func (cs *PdfColorspaceCalGray) ToPdfObject() core.PdfObject
ToPdfObject return the CalGray colorspace as a PDF object (name dictionary).
PdfColorspaceCalRGB stores A, B, C components
type PdfColorspaceCalRGB struct { WhitePoint []float64 BlackPoint []float64 Gamma []float64 Matrix []float64 // [XA YA ZA XB YB ZB XC YC ZC] ; default value identity [1 0 0 0 1 0 0 0 1] // contains filtered or unexported fields }
func NewPdfColorspaceCalRGB() *PdfColorspaceCalRGB
NewPdfColorspaceCalRGB returns a new CalRGB colorspace object.
func (cs *PdfColorspaceCalRGB) ColorFromFloats(vals []float64) (PdfColor, error)
ColorFromFloats returns a new PdfColor based on the input slice of color components. The slice should contain three elements representing the A, B and C components of the color. The values of the elements should be between 0 and 1.
func (cs *PdfColorspaceCalRGB) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)
ColorFromPdfObjects returns a new PdfColor based on the input slice of color components. The slice should contain three PdfObjectFloat elements representing the A, B and C components of the color.
func (cs *PdfColorspaceCalRGB) ColorToRGB(color PdfColor) (PdfColor, error)
ColorToRGB converts a CalRGB color to an RGB color.
func (cs *PdfColorspaceCalRGB) DecodeArray() []float64
DecodeArray returns the range of color component values in CalRGB colorspace.
func (cs *PdfColorspaceCalRGB) GetNumComponents() int
GetNumComponents returns the number of color components of the colorspace device. Returns 3 for a CalRGB device.
func (cs *PdfColorspaceCalRGB) ImageToRGB(img Image) (Image, error)
ImageToRGB converts CalRGB colorspace image to RGB and returns the result.
func (cs *PdfColorspaceCalRGB) String() string
func (cs *PdfColorspaceCalRGB) ToPdfObject() core.PdfObject
ToPdfObject returns colorspace in a PDF object format [name dictionary]
PdfColorspaceDeviceCMYK represents a CMYK32 colorspace.
type PdfColorspaceDeviceCMYK struct{}
func NewPdfColorspaceDeviceCMYK() *PdfColorspaceDeviceCMYK
NewPdfColorspaceDeviceCMYK returns a new CMYK32 colorspace object.
func (cs *PdfColorspaceDeviceCMYK) ColorFromFloats(vals []float64) (PdfColor, error)
ColorFromFloats returns a new PdfColorDevice based on the input slice of color components. The slice should contain four elements representing the cyan, magenta, yellow and key components of the color. The values of the elements should be between 0 and 1.
func (cs *PdfColorspaceDeviceCMYK) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)
ColorFromPdfObjects gets the color from a series of pdf objects (4 for cmyk).
func (cs *PdfColorspaceDeviceCMYK) ColorToRGB(color PdfColor) (PdfColor, error)
ColorToRGB converts a CMYK32 color to an RGB color.
func (cs *PdfColorspaceDeviceCMYK) DecodeArray() []float64
DecodeArray returns the range of color component values in DeviceCMYK colorspace.
func (cs *PdfColorspaceDeviceCMYK) GetNumComponents() int
GetNumComponents returns the number of color components of the colorspace device. Returns 4 for a CMYK32 device.
func (cs *PdfColorspaceDeviceCMYK) ImageToRGB(img Image) (Image, error)
ImageToRGB converts an image in CMYK32 colorspace to an RGB image.
func (cs *PdfColorspaceDeviceCMYK) String() string
func (cs *PdfColorspaceDeviceCMYK) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the colorspace.
PdfColorspaceDeviceGray represents a grayscale colorspace.
type PdfColorspaceDeviceGray struct{}
func NewPdfColorspaceDeviceGray() *PdfColorspaceDeviceGray
NewPdfColorspaceDeviceGray returns a new grayscale colorspace.
func (cs *PdfColorspaceDeviceGray) ColorFromFloats(vals []float64) (PdfColor, error)
ColorFromFloats returns a new PdfColor based on the input slice of color components. The slice should contain a single element between 0 and 1.
func (cs *PdfColorspaceDeviceGray) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)
ColorFromPdfObjects returns a new PdfColor based on the input slice of color components. The slice should contain a single PdfObjectFloat element in range 0-1.
func (cs *PdfColorspaceDeviceGray) ColorToRGB(color PdfColor) (PdfColor, error)
ColorToRGB converts gray -> rgb for a single color component.
func (cs *PdfColorspaceDeviceGray) DecodeArray() []float64
DecodeArray returns the range of color component values in DeviceGray colorspace.
func (cs *PdfColorspaceDeviceGray) GetNumComponents() int
GetNumComponents returns the number of color components of the colorspace device. Returns 1 for a grayscale device.
func (cs *PdfColorspaceDeviceGray) ImageToRGB(img Image) (Image, error)
ImageToRGB convert 1-component grayscale data to 3-component RGB.
func (cs *PdfColorspaceDeviceGray) String() string
func (cs *PdfColorspaceDeviceGray) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the colorspace.
PdfColorspaceDeviceN represents a DeviceN color space. DeviceN color spaces are similar to Separation color spaces, except they can contain an arbitrary number of color components.
Format: [/DeviceN names alternateSpace tintTransform]
or: [/DeviceN names alternateSpace tintTransform attributes]
type PdfColorspaceDeviceN struct { ColorantNames *core.PdfObjectArray AlternateSpace PdfColorspace TintTransform PdfFunction Attributes *PdfColorspaceDeviceNAttributes // contains filtered or unexported fields }
func NewPdfColorspaceDeviceN() *PdfColorspaceDeviceN
NewPdfColorspaceDeviceN returns an initialized PdfColorspaceDeviceN.
func (cs *PdfColorspaceDeviceN) ColorFromFloats(vals []float64) (PdfColor, error)
ColorFromFloats returns a new PdfColor based on input color components.
func (cs *PdfColorspaceDeviceN) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)
ColorFromPdfObjects returns a new PdfColor based on input color components. The input PdfObjects should be numeric.
func (cs *PdfColorspaceDeviceN) ColorToRGB(color PdfColor) (PdfColor, error)
ColorToRGB converts a DeviceN color to an RGB color.
func (cs *PdfColorspaceDeviceN) DecodeArray() []float64
DecodeArray returns the component range values for the DeviceN colorspace. [0 1.0 0 1.0 ...] for each color component.
func (cs *PdfColorspaceDeviceN) GetNumComponents() int
GetNumComponents returns the number of input color components, i.e. that are input to the tint transform.
func (cs *PdfColorspaceDeviceN) ImageToRGB(img Image) (Image, error)
ImageToRGB converts an Image in a given PdfColorspace to an RGB image.
func (cs *PdfColorspaceDeviceN) String() string
String returns the name of the colorspace (DeviceN).
func (cs *PdfColorspaceDeviceN) ToPdfObject() core.PdfObject
ToPdfObject returns a *PdfIndirectObject containing a *PdfObjectArray representation of the DeviceN colorspace. Format: [/DeviceN names alternateSpace tintTransform]
or: [/DeviceN names alternateSpace tintTransform attributes]
PdfColorspaceDeviceNAttributes contains additional information about the components of colour space that conforming readers may use. Conforming readers need not use the alternateSpace and tintTransform parameters, and may instead use a custom blending algorithms, along with other information provided in the attributes dictionary if present.
type PdfColorspaceDeviceNAttributes struct { Subtype *core.PdfObjectName // DeviceN or NChannel (DeviceN default) Colorants core.PdfObject Process core.PdfObject MixingHints core.PdfObject // contains filtered or unexported fields }
func (cs *PdfColorspaceDeviceNAttributes) ToPdfObject() core.PdfObject
ToPdfObject returns a PdfObject representation of PdfColorspaceDeviceNAttributes as a PdfObjectDictionary directly or indirectly within an indirect object container.
PdfColorspaceDeviceRGB represents an RGB colorspace.
type PdfColorspaceDeviceRGB struct{}
func NewPdfColorspaceDeviceRGB() *PdfColorspaceDeviceRGB
NewPdfColorspaceDeviceRGB returns a new RGB colorspace object.
func (cs *PdfColorspaceDeviceRGB) ColorFromFloats(vals []float64) (PdfColor, error)
ColorFromFloats returns a new PdfColor based on the input slice of color components. The slice should contain three elements representing the red, green and blue components of the color. The values of the elements should be between 0 and 1.
func (cs *PdfColorspaceDeviceRGB) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)
ColorFromPdfObjects gets the color from a series of pdf objects (3 for rgb).
func (cs *PdfColorspaceDeviceRGB) ColorToRGB(color PdfColor) (PdfColor, error)
ColorToRGB verifies that the input color is an RGB color. Method exists in order to satisfy the PdfColorspace interface.
func (cs *PdfColorspaceDeviceRGB) DecodeArray() []float64
DecodeArray returns the range of color component values in DeviceRGB colorspace.
func (cs *PdfColorspaceDeviceRGB) GetNumComponents() int
GetNumComponents returns the number of color components of the colorspace device. Returns 3 for an RGB device.
func (cs *PdfColorspaceDeviceRGB) ImageToGray(img Image) (Image, error)
ImageToGray returns a new grayscale image based on the passed in RGB image.
func (cs *PdfColorspaceDeviceRGB) ImageToRGB(img Image) (Image, error)
ImageToRGB returns the passed in image. Method exists in order to satisfy the PdfColorspace interface.
func (cs *PdfColorspaceDeviceRGB) String() string
func (cs *PdfColorspaceDeviceRGB) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the colorspace.
PdfColorspaceICCBased format [/ICCBased stream]
The stream shall contain the ICC profile. A conforming reader shall support ICC.1:2004:10 as required by PDF 1.7, which will enable it to properly render all embedded ICC profiles regardless of the PDF version
In the current implementation, we rely on the alternative colormap provided.
type PdfColorspaceICCBased struct { N int // Number of color components (Required). Can be 1,3, or 4. Alternate PdfColorspace // Alternate colorspace for non-conforming readers. // If omitted ICC not supported: then use DeviceGray, // DeviceRGB or DeviceCMYK for N=1,3,4 respectively. Range []float64 // Array of 2xN numbers, specifying range of each color component. Metadata *core.PdfObjectStream // Metadata stream. Data []byte // ICC colormap data. // contains filtered or unexported fields }
func NewPdfColorspaceICCBased(N int) (*PdfColorspaceICCBased, error)
NewPdfColorspaceICCBased returns a new ICCBased colorspace object.
func (cs *PdfColorspaceICCBased) ColorFromFloats(vals []float64) (PdfColor, error)
ColorFromFloats returns a new PdfColor based on the input slice of color components.
func (cs *PdfColorspaceICCBased) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)
ColorFromPdfObjects returns a new PdfColor based on the input slice of color component PDF objects.
func (cs *PdfColorspaceICCBased) ColorToRGB(color PdfColor) (PdfColor, error)
ColorToRGB converts a ICCBased color to an RGB color.
func (cs *PdfColorspaceICCBased) DecodeArray() []float64
DecodeArray returns the range of color component values in the ICCBased colorspace.
func (cs *PdfColorspaceICCBased) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject gets the primitive used to parse the color space.
func (cs *PdfColorspaceICCBased) GetNumComponents() int
GetNumComponents returns the number of color components.
func (cs *PdfColorspaceICCBased) ImageToRGB(img Image) (Image, error)
ImageToRGB converts ICCBased colorspace image to RGB and returns the result.
func (cs *PdfColorspaceICCBased) String() string
func (cs *PdfColorspaceICCBased) ToPdfObject() core.PdfObject
ToPdfObject returns colorspace in a PDF object format [name stream]
PdfColorspaceLab is a L*, a*, b* 3 component colorspace.
type PdfColorspaceLab struct { WhitePoint []float64 // Required. BlackPoint []float64 Range []float64 // [amin amax bmin bmax] // contains filtered or unexported fields }
func NewPdfColorspaceLab() *PdfColorspaceLab
NewPdfColorspaceLab returns a new Lab colorspace object.
func (cs *PdfColorspaceLab) ColorFromFloats(vals []float64) (PdfColor, error)
ColorFromFloats returns a new PdfColor based on the input slice of color components. The slice should contain three elements representing the L (range 0-100), A (range -100-100) and B (range -100-100) components of the color.
func (cs *PdfColorspaceLab) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)
ColorFromPdfObjects returns a new PdfColor based on the input slice of color components. The slice should contain three PdfObjectFloat elements representing the L, A and B components of the color.
func (cs *PdfColorspaceLab) ColorToRGB(color PdfColor) (PdfColor, error)
ColorToRGB converts a Lab color to an RGB color.
func (cs *PdfColorspaceLab) DecodeArray() []float64
DecodeArray returns the range of color component values in the Lab colorspace.
func (cs *PdfColorspaceLab) GetNumComponents() int
GetNumComponents returns the number of color components of the colorspace device. Returns 3 for a Lab device.
func (cs *PdfColorspaceLab) ImageToRGB(img Image) (Image, error)
ImageToRGB converts Lab colorspace image to RGB and returns the result.
func (cs *PdfColorspaceLab) String() string
func (cs *PdfColorspaceLab) ToPdfObject() core.PdfObject
ToPdfObject returns colorspace in a PDF object format [name dictionary]
PdfColorspaceSpecialIndexed is an indexed color space is a lookup table, where the input element is an index to the lookup table and the output is a color defined in the lookup table in the Base colorspace. [/Indexed base hival lookup]
type PdfColorspaceSpecialIndexed struct { Base PdfColorspace HiVal int Lookup core.PdfObject // contains filtered or unexported fields }
func NewPdfColorspaceSpecialIndexed() *PdfColorspaceSpecialIndexed
NewPdfColorspaceSpecialIndexed returns a new Indexed color.
func (cs *PdfColorspaceSpecialIndexed) ColorFromFloats(vals []float64) (PdfColor, error)
ColorFromFloats returns a new PdfColor based on the input slice of color components. The slice should contain a single element.
func (cs *PdfColorspaceSpecialIndexed) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)
ColorFromPdfObjects returns a new PdfColor based on the input slice of color components. The slice should contain a single PdfObjectFloat element.
func (cs *PdfColorspaceSpecialIndexed) ColorToRGB(color PdfColor) (PdfColor, error)
ColorToRGB converts an Indexed color to an RGB color.
func (cs *PdfColorspaceSpecialIndexed) DecodeArray() []float64
DecodeArray returns the component range values for the Indexed colorspace.
func (cs *PdfColorspaceSpecialIndexed) GetNumComponents() int
GetNumComponents returns the number of color components (1 for Indexed).
func (cs *PdfColorspaceSpecialIndexed) ImageToRGB(img Image) (Image, error)
ImageToRGB convert an indexed image to RGB.
func (cs *PdfColorspaceSpecialIndexed) String() string
func (cs *PdfColorspaceSpecialIndexed) ToPdfObject() core.PdfObject
ToPdfObject converts colorspace to a PDF object. [/Indexed base hival lookup]
PdfColorspaceSpecialPattern is a Pattern colorspace. Can be defined either as /Pattern or with an underlying colorspace [/Pattern cs].
type PdfColorspaceSpecialPattern struct { UnderlyingCS PdfColorspace // contains filtered or unexported fields }
func NewPdfColorspaceSpecialPattern() *PdfColorspaceSpecialPattern
NewPdfColorspaceSpecialPattern returns a new pattern color.
func (cs *PdfColorspaceSpecialPattern) ColorFromFloats(vals []float64) (PdfColor, error)
ColorFromFloats returns a new PdfColor based on the input slice of color components.
func (cs *PdfColorspaceSpecialPattern) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)
ColorFromPdfObjects loads the color from PDF objects. The first objects (if present) represent the color in underlying colorspace. The last one represents the name of the pattern.
func (cs *PdfColorspaceSpecialPattern) ColorToRGB(color PdfColor) (PdfColor, error)
ColorToRGB only converts color used with uncolored patterns (defined in underlying colorspace). Does not go into the pattern objects and convert those. If that is desired, needs to be done separately. See for example grayscale conversion example in unidoc-examples repo.
func (cs *PdfColorspaceSpecialPattern) DecodeArray() []float64
DecodeArray returns an empty slice as there are no components associated with pattern colorspace.
func (cs *PdfColorspaceSpecialPattern) GetNumComponents() int
GetNumComponents returns the number of color components of the underlying colorspace device.
func (cs *PdfColorspaceSpecialPattern) ImageToRGB(img Image) (Image, error)
ImageToRGB returns an error since an image cannot be defined in a pattern colorspace.
func (cs *PdfColorspaceSpecialPattern) String() string
func (cs *PdfColorspaceSpecialPattern) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the colorspace.
PdfColorspaceSpecialSeparation is a Separation colorspace. At the moment the colour space is set to a Separation space, the conforming reader shall determine whether the device has an available colorant (e.g. dye) corresponding to the name of the requested space. If so, the conforming reader shall ignore the alternateSpace and tintTransform parameters; subsequent painting operations within the space shall apply the designated colorant directly, according to the tint values supplied.
Format: [/Separation name alternateSpace tintTransform]
type PdfColorspaceSpecialSeparation struct { ColorantName *core.PdfObjectName AlternateSpace PdfColorspace TintTransform PdfFunction // contains filtered or unexported fields }
func NewPdfColorspaceSpecialSeparation() *PdfColorspaceSpecialSeparation
NewPdfColorspaceSpecialSeparation returns a new separation color.
func (cs *PdfColorspaceSpecialSeparation) ColorFromFloats(vals []float64) (PdfColor, error)
ColorFromFloats returns a new PdfColor based on the input slice of color components. The slice should contain a single element.
func (cs *PdfColorspaceSpecialSeparation) ColorFromPdfObjects(objects []core.PdfObject) (PdfColor, error)
ColorFromPdfObjects returns a new PdfColor based on the input slice of color components. The slice should contain a single PdfObjectFloat element.
func (cs *PdfColorspaceSpecialSeparation) ColorToRGB(color PdfColor) (PdfColor, error)
ColorToRGB converts a color in Separation colorspace to RGB colorspace.
func (cs *PdfColorspaceSpecialSeparation) DecodeArray() []float64
DecodeArray returns the component range values for the Separation colorspace.
func (cs *PdfColorspaceSpecialSeparation) GetNumComponents() int
GetNumComponents returns the number of color components (1 for Separation).
func (cs *PdfColorspaceSpecialSeparation) ImageToRGB(img Image) (Image, error)
ImageToRGB converts an image with samples in Separation CS to an image with samples specified in DeviceRGB CS.
func (cs *PdfColorspaceSpecialSeparation) String() string
func (cs *PdfColorspaceSpecialSeparation) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the colorspace.
PdfDate represents a date, which is a PDF string of the form: (D:YYYYMMDDHHmmSSOHH'mm)
type PdfDate struct {
// contains filtered or unexported fields
}
func NewPdfDate(dateStr string) (PdfDate, error)
NewPdfDate returns a new PdfDate object from a PDF date string (see 7.9.4 Dates). format: "D: YYYYMMDDHHmmSSOHH'mm"
func NewPdfDateFromTime(timeObj time.Time) (PdfDate, error)
NewPdfDateFromTime will create a PdfDate based on the given time
func (d PdfDate) ToGoTime() time.Time
ToGoTime returns the date in time.Time format.
func (d *PdfDate) ToPdfObject() core.PdfObject
ToPdfObject converts date to a PDF string object.
PdfField contains the common attributes of a form field. The context object contains the specific field data which can represent a button, text, choice or signature. The PdfField is typically not used directly, but is encapsulated by the more specific field types such as PdfFieldButton etc (i.e. the context attribute).
type PdfField struct { Parent *PdfField Annotations []*PdfAnnotationWidget Kids []*PdfField FT *core.PdfObjectName T *core.PdfObjectString TU *core.PdfObjectString TM *core.PdfObjectString Ff *core.PdfObjectInteger V core.PdfObject DV core.PdfObject AA core.PdfObject VariableText *VariableText // contains filtered or unexported fields }
func NewPdfField() *PdfField
NewPdfField returns an initialized PdfField.
func (f *PdfField) Flags() FieldFlag
Flags returns the field flags for the field accounting for any inherited flags.
func (f *PdfField) FullName() (string, error)
FullName returns the full name of the field as in rootname.parentname.partialname.
func (f *PdfField) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject returns the containing object for the PdfField, i.e. an indirect object containing the field dictionary.
func (f *PdfField) GetContext() PdfModel
GetContext returns the PdfField context which is the more specific field data type, e.g. PdfFieldButton for a button field.
func (f *PdfField) IsTerminal() bool
IsTerminal returns true for terminal fields, false otherwise. Terminal fields are fields whose descendants are only widget annotations.
func (f *PdfField) PartialName() string
PartialName returns the partial name of the field.
func (f *PdfField) SetContext(ctx PdfModel)
SetContext sets the specific fielddata type, e.g. would be PdfFieldButton for a button field.
func (f *PdfField) SetFlag(flag FieldFlag)
SetFlag sets the flag for the field.
func (f *PdfField) String() string
String returns a string representation of the field.
func (f *PdfField) ToPdfObject() core.PdfObject
ToPdfObject sets the common field elements. Note: Call the more field context's ToPdfObject to set both the generic and non-generic information.
PdfFieldButton represents a button field which includes push buttons, checkboxes, and radio buttons.
type PdfFieldButton struct { *PdfField Opt *core.PdfObjectArray // contains filtered or unexported fields }
func (fb *PdfFieldButton) GetFillImage() *Image
GetFillImage get attached model.Image in push button.
func (fb *PdfFieldButton) GetType() ButtonType
GetType returns the button field type which returns one of the following - PdfFieldButtonPush for push button fields - PdfFieldButtonCheckbox for checkbox fields - PdfFieldButtonRadio for radio button fields
func (fb *PdfFieldButton) IsCheckbox() bool
IsCheckbox returns true if the button field represents a checkbox, false otherwise.
func (fb *PdfFieldButton) IsPush() bool
IsPush returns true if the button field represents a push button, false otherwise.
func (fb *PdfFieldButton) IsRadio() bool
IsRadio returns true if the button field represents a radio button, false otherwise.
func (fb *PdfFieldButton) SetFillImage(image *Image)
SetFillImage attach a model.Image to push button.
func (fb *PdfFieldButton) SetType(btype ButtonType)
SetType sets the field button's type. Can be one of: - PdfFieldButtonPush for push button fields - PdfFieldButtonCheckbox for checkbox fields - PdfFieldButtonRadio for radio button fields This sets the field's flag appropriately.
func (fb *PdfFieldButton) ToPdfObject() core.PdfObject
ToPdfObject returns the button field dictionary within an indirect object.
PdfFieldChoice represents a choice field which includes scrollable list boxes and combo boxes.
type PdfFieldChoice struct { *PdfField Opt *core.PdfObjectArray TI *core.PdfObjectInteger I *core.PdfObjectArray }
func (ch *PdfFieldChoice) ToPdfObject() core.PdfObject
ToPdfObject returns the choice field dictionary within an indirect object (container).
PdfFieldSignature signature field represents digital signatures and optional data for authenticating the name of the signer and verifying document contents.
type PdfFieldSignature struct { *PdfField *PdfAnnotationWidget V *PdfSignature Lock *core.PdfIndirectObject SV *core.PdfIndirectObject }
func NewPdfFieldSignature(signature *PdfSignature) *PdfFieldSignature
NewPdfFieldSignature returns an initialized signature field.
func (sig *PdfFieldSignature) ToPdfObject() core.PdfObject
ToPdfObject returns an indirect object containing the signature field dictionary.
PdfFieldText represents a text field where user can enter text.
type PdfFieldText struct { *PdfField DA *core.PdfObjectString Q *core.PdfObjectInteger DS *core.PdfObjectString RV core.PdfObject MaxLen *core.PdfObjectInteger }
func (ft *PdfFieldText) ToPdfObject() core.PdfObject
ToPdfObject returns the text field dictionary within an indirect object (container).
PdfFilespec represents a file specification which can either refer to an external or embedded file.
type PdfFilespec struct { Type core.PdfObject FS core.PdfObject F core.PdfObject // A file specification string UF core.PdfObject // A Unicode text string that provides file specification DOS core.PdfObject // A file specification string representing a DOS file name. OBSOLETE Mac core.PdfObject // A file specification string representing a Mac OS file name. OBSOLETE Unix core.PdfObject // A file specification string representing a UNIX file name. OBSOLETE ID core.PdfObject // An array of two byte strings constituting a file identifier V core.PdfObject // A flag indicating whether the file referenced by the file specification is volatile (changes frequently with time). EF core.PdfObject // A dictionary containing a subset of the keys F, UF, DOS, Mac, and Unix, corresponding to the entries by those names in the file specification dictionary RF core.PdfObject Desc core.PdfObject // Descriptive text associated with the file specification CI core.PdfObject // A collection item dictionary, which shall be used to create the user interface for portable collections // contains filtered or unexported fields }
func NewPdfFilespec() *PdfFilespec
NewPdfFilespec returns an initialized generic PDF filespec model.
func NewPdfFilespecFromObj(obj core.PdfObject) (*PdfFilespec, error)
NewPdfFilespecFromObj creates and returns a new PdfFilespec object.
func (f *PdfFilespec) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject implements interface PdfModel.
func (f *PdfFilespec) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfFont represents an underlying font structure which can be of type: - Type0 - Type1 - TrueType etc.
type PdfFont struct {
// contains filtered or unexported fields
}
func DefaultFont() *PdfFont
DefaultFont returns the default font, which is currently the built in Helvetica.
func NewCompositePdfFontFromTTF(r io.ReadSeeker) (*PdfFont, error)
NewCompositePdfFontFromTTF loads a composite TTF font. Composite fonts can be used to represent unicode fonts which can have multi-byte character codes, representing a wide range of values. They are often used for symbolic languages, including Chinese, Japanese and Korean. It is represented by a Type0 Font with an underlying CIDFontType2 and an Identity-H encoding map. TODO: May be extended in the future to support a larger variety of CMaps and vertical fonts. NOTE: For simple fonts, use NewPdfFontFromTTF.
func NewCompositePdfFontFromTTFFile(filePath string) (*PdfFont, error)
NewCompositePdfFontFromTTFFile loads a composite font from a TTF font file. Composite fonts can be used to represent unicode fonts which can have multi-byte character codes, representing a wide range of values. They are often used for symbolic languages, including Chinese, Japanese and Korean. It is represented by a Type0 Font with an underlying CIDFontType2 and an Identity-H encoding map. TODO: May be extended in the future to support a larger variety of CMaps and vertical fonts. NOTE: For simple fonts, use NewPdfFontFromTTFFile.
func NewPdfFontFromPdfObject(fontObj core.PdfObject) (*PdfFont, error)
NewPdfFontFromPdfObject loads a PdfFont from the dictionary `fontObj`. If there is a problem an error is returned.
func NewPdfFontFromTTF(r io.ReadSeeker) (*PdfFont, error)
NewPdfFontFromTTF loads a TTF font and returns a PdfFont type that can be used in text styling functions. Uses a WinAnsiTextEncoder and loads only character codes 32-255. NOTE: For composite fonts such as used in symbolic languages, use NewCompositePdfFontFromTTF.
func NewPdfFontFromTTFFile(filePath string) (*PdfFont, error)
NewPdfFontFromTTFFile loads a TTF font file and returns a PdfFont type that can be used in text styling functions. Uses a WinAnsiTextEncoder and loads only character codes 32-255. NOTE: For composite fonts such as used in symbolic languages, use NewCompositePdfFontFromTTFFile.
func NewStandard14Font(basefont StdFontName) (*PdfFont, error)
NewStandard14Font returns the standard 14 font named `basefont` as a *PdfFont, or an error if it `basefont` is not one of the standard 14 font names.
func NewStandard14FontMustCompile(basefont StdFontName) *PdfFont
NewStandard14FontMustCompile returns the standard 14 font named `basefont` as a *PdfFont. If `basefont` is one of the 14 Standard14Font values defined above then NewStandard14FontMustCompile is guaranteed to succeed.
func NewStandard14FontWithEncoding(basefont StdFontName, alphabet map[rune]int) (*PdfFont, textencoding.SimpleEncoder, error)
NewStandard14FontWithEncoding returns the standard 14 font named `basefont` as a *PdfFont and a TextEncoder that encodes all the runes in `alphabet`, or an error if this is not possible. An error can occur if `basefont` is not one the standard 14 font names.
func (font *PdfFont) BaseFont() string
BaseFont returns the font's "BaseFont" field.
func (font *PdfFont) BytesToCharcodes(data []byte) []textencoding.CharCode
BytesToCharcodes converts the bytes in a PDF string to character codes.
func (font *PdfFont) CharcodeBytesToUnicode(data []byte) (string, int, int)
CharcodeBytesToUnicode converts PDF character codes `data` to a Go unicode string.
9.10 Extraction of Text Content (page 292) The process of finding glyph descriptions in OpenType fonts by a conforming reader shall be the following: • For Type 1 fonts using “CFF” tables, the process shall be as described in 9.6.6.2, "Encodings
for Type 1 Fonts".
• For TrueType fonts using “glyf” tables, the process shall be as described in 9.6.6.4,
"Encodings for TrueType Fonts". Since this process sometimes produces ambiguous results, conforming writers, instead of using a simple font, shall use a Type 0 font with an Identity-H encoding and use the glyph indices as character codes, as described following Table 118.
func (font *PdfFont) CharcodesToStrings(charcodes []textencoding.CharCode) ([]string, int, int)
CharcodesToStrings returns the unicode strings corresponding to `charcodes`. The int returns are the number of strings and the number of unconvereted codes. NOTE: The number of strings returned is equal to the number of charcodes
func (font *PdfFont) CharcodesToUnicode(charcodes []textencoding.CharCode) []rune
CharcodesToUnicode converts the character codes `charcodes` to a slice of runes. How it works:
1) Use the ToUnicode CMap if there is one. 2) Use the underlying font's encoding.
func (font *PdfFont) CharcodesToUnicodeWithStats(charcodes []textencoding.CharCode) (runelist []rune, numHits, numMisses int)
CharcodesToUnicodeWithStats is identical to CharcodesToUnicode except it returns more statistical information about hits and misses from the reverse mapping process. NOTE: The number of runes returned may be greater than the number of charcodes. TODO(peterwilliams97): Deprecate in v4 and use only CharcodesToStrings()
func (font *PdfFont) Encoder() textencoding.TextEncoder
Encoder returns the font's text encoder.
func (font *PdfFont) FontDescriptor() *PdfFontDescriptor
FontDescriptor returns font's PdfFontDescriptor. This may be a builtin descriptor for standard 14 fonts but must be an explicit descriptor for other fonts.
func (font *PdfFont) GetCharMetrics(code textencoding.CharCode) (CharMetrics, bool)
GetCharMetrics returns the char metrics for character code `code`. How it works:
1) It calls the GetCharMetrics function for the underlying font, either a simple font or a Type0 font. The underlying font GetCharMetrics() functions do direct charcode ➞ metrics mappings. 2) If the underlying font's GetCharMetrics() doesn't have a CharMetrics for `code` then a a CharMetrics with the FontDescriptor's /MissingWidth is returned. 3) If there is no /MissingWidth then a failure is returned.
TODO(peterwilliams97) There is nothing callers can do if no CharMetrics are found so we might as
well give them 0 width. There is no need for the bool return.
TODO(gunnsth): Reconsider whether needed or if can map via GlyphName.
func (font PdfFont) GetFontDescriptor() (*PdfFontDescriptor, error)
GetFontDescriptor returns the font descriptor for `font`.
func (font *PdfFont) GetRuneMetrics(r rune) (CharMetrics, bool)
GetRuneMetrics returns the char metrics for a rune. TODO(peterwilliams97) There is nothing callers can do if no CharMetrics are found so we might as
well give them 0 width. There is no need for the bool return.
func (font *PdfFont) IsCID() bool
IsCID returns true if the underlying font is CID.
func (font *PdfFont) IsSimple() bool
IsSimple returns true if `font` is a simple font.
func (font *PdfFont) RunesToCharcodeBytes(data []rune) ([]byte, int)
RunesToCharcodeBytes maps the provided runes to charcode bytes and it returns the resulting slice of bytes, along with the number of runes which could not be converted. If the number of misses is 0, all runes were successfully converted.
func (font *PdfFont) String() string
String returns a string that describes `font`.
func (font *PdfFont) StringToCharcodeBytes(str string) ([]byte, int)
StringToCharcodeBytes maps the provided string runes to charcode bytes and it returns the resulting slice of bytes, along with the number of runes which could not be converted. If the number of misses is 0, all string runes were successfully converted.
func (font *PdfFont) SubsetRegistered() error
SubsetRegistered subsets the font to only the glyphs that have been registered by the encoder. NOTE: This only works on fonts that support subsetting. For unsupported fonts this is a no-op, although a debug
message is emitted. Currently supported fonts are embedded Truetype CID fonts (type 0).
NOTE: Make sure to call this soon before writing (once all needed runes have been registered). If using package creator, use its EnableFontSubsetting method instead.
func (font *PdfFont) Subtype() string
Subtype returns the font's "Subtype" field.
func (font *PdfFont) ToPdfObject() core.PdfObject
ToPdfObject converts the PdfFont object to its PDF representation.
func (font *PdfFont) ToUnicode() string
ToUnicode returns the name of the font's "ToUnicode" field if there is one, or "" if there isn't.
PdfFontDescriptor specifies metrics and other attributes of a font and can refer to a FontFile for embedded fonts. 9.8 Font Descriptors (page 281)
type PdfFontDescriptor struct { FontName core.PdfObject FontFamily core.PdfObject FontStretch core.PdfObject FontWeight core.PdfObject Flags core.PdfObject FontBBox core.PdfObject ItalicAngle core.PdfObject Ascent core.PdfObject Descent core.PdfObject Leading core.PdfObject CapHeight core.PdfObject XHeight core.PdfObject StemV core.PdfObject StemH core.PdfObject AvgWidth core.PdfObject MaxWidth core.PdfObject MissingWidth core.PdfObject FontFile core.PdfObject // PFB FontFile2 core.PdfObject // TTF FontFile3 core.PdfObject // OTF / CFF CharSet core.PdfObject // Additional entries for CIDFonts Style core.PdfObject Lang core.PdfObject FD core.PdfObject CIDSet core.PdfObject // contains filtered or unexported fields }
func (desc *PdfFontDescriptor) GetAscent() (float64, error)
GetAscent returns the Ascent of the font `descriptor`.
func (desc *PdfFontDescriptor) GetCapHeight() (float64, error)
GetCapHeight returns the CapHeight of the font `descriptor`.
func (desc *PdfFontDescriptor) GetDescent() (float64, error)
GetDescent returns the Descent of the font `descriptor`.
func (desc *PdfFontDescriptor) String() string
String returns a string describing the font descriptor.
func (desc *PdfFontDescriptor) ToPdfObject() core.PdfObject
ToPdfObject returns the PdfFontDescriptor as a PDF dictionary inside an indirect object.
PdfFunction interface represents the common methods of a function in PDF.
type PdfFunction interface { Evaluate([]float64) ([]float64, error) ToPdfObject() core.PdfObject }
PdfFunctionType0 uses a sequence of sample values (contained in a stream) to provide an approximation for functions whose domains and ranges are bounded. The samples are organized as an m-dimensional table in which each entry has n components
type PdfFunctionType0 struct { Domain []float64 // required; 2*m length; where m is the number of input values Range []float64 // required (type 0); 2*n length; where n is the number of output values NumInputs int NumOutputs int Size []int BitsPerSample int Order int // Values 1 or 3 (linear or cubic spline interpolation) Encode []float64 Decode []float64 // contains filtered or unexported fields }
func (f *PdfFunctionType0) Evaluate(x []float64) ([]float64, error)
Evaluate runs the function on the passed in slice and returns the results.
func (f *PdfFunctionType0) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the function.
PdfFunctionType2 defines an exponential interpolation of one input value and n output values:
f(x) = y_0, ..., y_(n-1)
y_j = C0_j + x^N * (C1_j - C0_j); for 0 <= j < n When N=1 ; linear interpolation between C0 and C1.
type PdfFunctionType2 struct { Domain []float64 Range []float64 C0 []float64 C1 []float64 N float64 // contains filtered or unexported fields }
func (f *PdfFunctionType2) Evaluate(x []float64) ([]float64, error)
Evaluate runs the function on the passed in slice and returns the results.
func (f *PdfFunctionType2) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the function.
PdfFunctionType3 defines stitching of the subdomains of several 1-input functions to produce a single new 1-input function.
type PdfFunctionType3 struct { Domain []float64 Range []float64 Functions []PdfFunction // k-1 input functions Bounds []float64 // k-1 numbers; defines the intervals where each function applies Encode []float64 // Array of 2k numbers.. // contains filtered or unexported fields }
func (f *PdfFunctionType3) Evaluate(x []float64) ([]float64, error)
Evaluate runs the function on the passed in slice and returns the results.
func (f *PdfFunctionType3) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the function.
PdfFunctionType4 is a Postscript calculator functions.
type PdfFunctionType4 struct { Domain []float64 Range []float64 Program *ps.PSProgram // contains filtered or unexported fields }
func (f *PdfFunctionType4) Evaluate(xVec []float64) ([]float64, error)
Evaluate runs the function. Input is [x1 x2 x3].
func (f *PdfFunctionType4) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the function.
PdfInfo holds document information that will overwrite document information global variables defined above.
type PdfInfo struct { Title *core.PdfObjectString Author *core.PdfObjectString Subject *core.PdfObjectString Keywords *core.PdfObjectString Creator *core.PdfObjectString Producer *core.PdfObjectString CreationDate *PdfDate ModifiedDate *PdfDate Trapped *core.PdfObjectName // contains filtered or unexported fields }
func NewPdfInfoFromObject(obj core.PdfObject) (*PdfInfo, error)
NewPdfInfoFromObject creates a new PdfInfo from the input core.PdfObject.
func (info *PdfInfo) AddCustomInfo(name string, value string) error
AddCustomInfo adds a custom info into document info dictionary.
func (info *PdfInfo) CustomKeys() []string
CustomKeys returns all custom info keys as list.
func (info *PdfInfo) GetCustomInfo(name string) *core.PdfObjectString
GetCustomInfo returns a custom info value for the specified name.
func (info *PdfInfo) ToPdfObject() core.PdfObject
ToPdfObject convert PdfInfo to pdf object.
PdfInfoTrapped specifies pdf trapped information.
type PdfInfoTrapped string
const ( // TrappedUnknown specifies that either it is unknown whether the document has been trapped or // it has been partly but not yet fully trapped; // some additional trapping may still be needed. // This is the default value. TrappedUnknown PdfInfoTrapped = "Unknown" // TrappedTrue specifies that the document has been fully trapped; // no further trapping shall be needed. TrappedTrue PdfInfoTrapped = "True" // TrappedFalse specifies that the document has not yet been trapped. TrappedFalse PdfInfoTrapped = "False" )
PdfModel is a higher level PDF construct which can be collapsed into a PdfObject. Each PdfModel has an underlying PdfObject and vice versa (one-to-one). Under normal circumstances there should only be one copy of each. Copies can be made, but care must be taken to do it properly.
type PdfModel interface { ToPdfObject() core.PdfObject GetContainingPdfObject() core.PdfObject }
PdfOutline represents a PDF outline dictionary (Table 152 - p. 376).
type PdfOutline struct { PdfOutlineTreeNode Parent *PdfOutlineTreeNode Count *int64 // contains filtered or unexported fields }
func NewPdfOutline() *PdfOutline
NewPdfOutline returns an initialized PdfOutline.
func NewPdfOutlineTree() *PdfOutline
NewPdfOutlineTree returns an initialized PdfOutline tree.
func (o *PdfOutline) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject returns the container of the outline (indirect object).
func (o *PdfOutline) ToPdfObject() core.PdfObject
ToPdfObject recursively builds the Outline tree PDF object.
PdfOutlineItem represents an outline item dictionary (Table 153 - pp. 376 - 377).
type PdfOutlineItem struct { PdfOutlineTreeNode Title *core.PdfObjectString Parent *PdfOutlineTreeNode Prev *PdfOutlineTreeNode Next *PdfOutlineTreeNode Count *int64 Dest core.PdfObject A core.PdfObject SE core.PdfObject C core.PdfObject F core.PdfObject // contains filtered or unexported fields }
func NewOutlineBookmark(title string, page *core.PdfIndirectObject) *PdfOutlineItem
NewOutlineBookmark returns an initialized PdfOutlineItem for a given bookmark title and page.
func NewPdfOutlineItem() *PdfOutlineItem
NewPdfOutlineItem returns an initialized PdfOutlineItem.
func (oi *PdfOutlineItem) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject returns the container of the outline item (indirect object).
func (oi *PdfOutlineItem) ToPdfObject() core.PdfObject
ToPdfObject recursively builds the Outline tree PDF object.
PdfOutlineTreeNode contains common fields used by the outline and outline item objects.
type PdfOutlineTreeNode struct { First *PdfOutlineTreeNode Last *PdfOutlineTreeNode // contains filtered or unexported fields }
func (n *PdfOutlineTreeNode) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject returns the container of the outline tree node (indirect object).
func (n *PdfOutlineTreeNode) GetContext() PdfModel
GetContext returns the context of the outline tree node, which is either a *PdfOutline or a *PdfOutlineItem. The method returns nil for uninitialized tree nodes.
func (n *PdfOutlineTreeNode) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the outline tree node.
PdfOutputIntent provides a means for matching the color characteristics of a PDF document with those of a target output device. Multiple PdfOutputIntents allows the production process to be customized to the expected workflow and the specific tools available.
type PdfOutputIntent struct { // Type is an optional PDF object that this dictionary describes. // If present, must be OutputIntent for an output intent dictionary. Type string // S defines the OutputIntent subtype which should match the standard used in given document i.e: // for PDF/X use PdfOutputIntentTypeX. S PdfOutputIntentType // OutputCondition is an optional field that is identifying the intended output device or production condition in // human-readable form. This is preferred method of defining such a string for presentation to the user. OutputCondition string // OutputConditionIdentifier is a required field identifying the intended output device or production condition in // human or machine-readable form. If human-readable, this string may be used // in lieu of an OutputCondition for presentation to the user. // A typical value for this entry would be the name of a production condition maintained // in an industry-standard registry such as the ICC Characterization Data Registry // If the intended production condition is not a recognized standard, the value Custom is recommended for this entry. // the DestOutputProfile entry defines the ICC profile, and the Info entry is used for further // human-readable identification. OutputConditionIdentifier string // RegistryName is an optional string field (conventionally URI) identifying the registry in which the condition // designated by OutputConditionIdentifier is defined. RegistryName string // Info is a required field if OutputConditionIdentifier does not specify a standard production condition. // A human-readable text string containing additional information or comments about intended // target device or production condition. Info string // DestOutputProfile is required if OutputConditionIdentifier does not specify a standard production condition. // It is an ICC profile stream defining the transformation from the PDF document's source colors to output device colorants. DestOutputProfile []byte // ColorComponents is the number of color components supported by given output profile. ColorComponents int // contains filtered or unexported fields }
func NewCustomPdfOutputIntent(outputCondition, outputConditionIdentifier, info string, destOutputProfile []byte, colorComponents int) *PdfOutputIntent
NewCustomPdfOutputIntent creates a new custom PdfOutputIntent.
func NewPdfOutputIntentFromPdfObject(object core.PdfObject) (*PdfOutputIntent, error)
NewPdfOutputIntentFromPdfObject creates a new PdfOutputIntent from the input core.PdfObject.
func NewStandardPdfOutputIntent(outputCondition, outputConditionIdentifier, registryName string, destOutputProfile []byte, colorComponents int) *PdfOutputIntent
NewStandardPdfOutputIntent creates a new standard PdfOutputIntent.
func (p *PdfOutputIntent) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject implements model.PdfModel interface.
func (p *PdfOutputIntent) ParsePdfObject(object core.PdfObject) error
ParsePdfObject parses input pdf object into given output intent.
func (p *PdfOutputIntent) SetSubtype(subtype PdfOutputIntentType) error
SetSubtype sets the Subtype S for given PdfOutputIntent.
func (p *PdfOutputIntent) ToPdfObject() core.PdfObject
ToPdfObject implements model.PdfModel interface.
PdfOutputIntentType is the subtype of the given PdfOutputIntent.
type PdfOutputIntentType int
const ( // PdfOutputIntentTypeA1 is the PdfOutputIntentType used with the standard PDF/A-1 PdfOutputIntentTypeA1 PdfOutputIntentType // PdfOutputIntentTypeA2 is the PdfOutputIntentType used with the standard PDF/A-2 PdfOutputIntentTypeA2 // PdfOutputIntentTypeA3 is the PdfOutputIntentType used with the standard PDF/A-3 PdfOutputIntentTypeA3 // PdfOutputIntentTypeA4 is the PdfOutputIntentType used with the standard PDF/A-4 PdfOutputIntentTypeA4 // PdfOutputIntentTypeX is the PdfOutputIntentType used with the standard PDF/X PdfOutputIntentTypeX )
func (p PdfOutputIntentType) IsValid() bool
IsValid checks if the given pdf output intent type is valid.
func (p PdfOutputIntentType) String() string
String returns string value of output intent for given type ISO_19005-2 6.2.3: GTS_PDFA1 value should be used for PDF/A-1, A-2 and A-3 at least
PdfPage represents a page in a PDF document. (7.7.3.3 - Table 30).
type PdfPage struct { Parent core.PdfObject LastModified *PdfDate Resources *PdfPageResources CropBox *PdfRectangle MediaBox *PdfRectangle BleedBox *PdfRectangle TrimBox *PdfRectangle ArtBox *PdfRectangle BoxColorInfo core.PdfObject Contents core.PdfObject Rotate *int64 Group core.PdfObject Thumb core.PdfObject B core.PdfObject Dur core.PdfObject Trans core.PdfObject AA core.PdfObject Metadata core.PdfObject PieceInfo core.PdfObject StructParents core.PdfObject ID core.PdfObject PZ core.PdfObject SeparationInfo core.PdfObject Tabs core.PdfObject TemplateInstantiated core.PdfObject PresSteps core.PdfObject UserUnit core.PdfObject VP core.PdfObject Annots core.PdfObject // contains filtered or unexported fields }
func NewPdfPage() *PdfPage
NewPdfPage returns a new PDF page.
func (p *PdfPage) AddAnnotation(annot *PdfAnnotation)
AddAnnotation appends `annot` to the list of page annotations.
func (p *PdfPage) AddContentStreamByString(contentStr string) error
AddContentStreamByString adds content stream by string. Puts the content string into a stream object and points the content stream towards it.
func (p *PdfPage) AddExtGState(name core.PdfObjectName, egs *core.PdfObjectDictionary) error
AddExtGState adds a graphics state to the XObject resources.
func (p *PdfPage) AddFont(name core.PdfObjectName, font core.PdfObject) error
AddFont adds a font dictionary to the Font resources.
func (p *PdfPage) AddImageResource(name core.PdfObjectName, ximg *XObjectImage) error
AddImageResource adds an image to the XObject resources.
func (p *PdfPage) AddWatermarkImage(ximg *XObjectImage, opt WatermarkImageOptions) error
AddWatermarkImage adds a watermark to the page.
func (p *PdfPage) AppendContentBytes(cs []byte, wrapContents bool) error
AppendContentBytes creates a PDF stream from `cs` and appends it to the array of streams specified by the pages's Contents entry. If `wrapContents` is true, the content stream of the page is wrapped using a `q/Q` operator pair, so that its state does not affect the appended content stream.
func (p *PdfPage) AppendContentStream(contentStr string) error
AppendContentStream adds content stream by string. Appends to the last contentstream instance if many.
func (p *PdfPage) Duplicate() *PdfPage
Duplicate creates a duplicate page based on the current one and returns it.
func (p *PdfPage) GetAllContentStreams() (string, error)
GetAllContentStreams gets all the content streams for a page as one string.
func (p *PdfPage) GetAnnotations() ([]*PdfAnnotation, error)
GetAnnotations returns the list of page annotations for `page`. If not loaded attempts to load the annotations, otherwise returns the loaded list.
func (p *PdfPage) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject returns the page as a dictionary within an PdfIndirectObject.
func (p *PdfPage) GetContentStreamObjs() []core.PdfObject
GetContentStreamObjs returns a slice of PDF objects containing the content streams of the page.
func (p *PdfPage) GetContentStreams() ([]string, error)
GetContentStreams returns the content stream as an array of strings.
func (p *PdfPage) GetMediaBox() (*PdfRectangle, error)
GetMediaBox gets the inheritable media box value, either from the page or a higher up page/pages struct.
func (p *PdfPage) GetPageAsIndirectObject() *core.PdfIndirectObject
GetPageAsIndirectObject returns the page as a dictionary within an PdfIndirectObject.
func (p *PdfPage) GetPageDict() *core.PdfObjectDictionary
GetPageDict converts the Page to a PDF object dictionary.
func (p *PdfPage) GetRotate() (int64, error)
GetRotate gets the inheritable rotate value, either from the page or a higher up page/pages struct.
func (p *PdfPage) GetXObjectByName(name core.PdfObjectName) (core.PdfObject, bool)
GetXObjectByName gets XObject by name.
func (p *PdfPage) HasExtGState(name core.PdfObjectName) bool
HasExtGState checks if ExtGState name is available.
func (p *PdfPage) HasFontByName(name core.PdfObjectName) bool
HasFontByName checks if has font resource by name.
func (p *PdfPage) HasXObjectByName(name core.PdfObjectName) bool
HasXObjectByName checks if has XObject resource by name.
func (p *PdfPage) SetAnnotations(annotations []*PdfAnnotation)
SetAnnotations sets the annotations list.
func (p *PdfPage) SetContentStreams(cStreams []string, encoder core.StreamEncoder) error
SetContentStreams sets the content streams based on a string array. Will make 1 object stream for each string and reference from the page Contents. Each stream will be encoded using the encoding specified by the StreamEncoder, if empty, will use identity encoding (raw data).
func (p *PdfPage) Size() (float64, float64, error)
Size returns the width and the height of the page. The method reports the page dimensions as displayed by a PDF viewer (i.e. page rotation is taken into account).
func (p *PdfPage) ToPdfObject() core.PdfObject
ToPdfObject converts the PdfPage to a dictionary within an indirect object container.
PdfPageResources is a Page resources model. Implements PdfModel.
type PdfPageResources struct { ExtGState core.PdfObject ColorSpace core.PdfObject Pattern core.PdfObject Shading core.PdfObject XObject core.PdfObject Font core.PdfObject ProcSet core.PdfObject Properties core.PdfObject // contains filtered or unexported fields }
func NewPdfPageResources() *PdfPageResources
NewPdfPageResources returns a new PdfPageResources object.
func NewPdfPageResourcesFromDict(dict *core.PdfObjectDictionary) (*PdfPageResources, error)
NewPdfPageResourcesFromDict creates and returns a new PdfPageResources object from the input dictionary.
func (r *PdfPageResources) AddExtGState(gsName core.PdfObjectName, gsDict core.PdfObject) error
AddExtGState add External Graphics State (GState). The gsDict can be specified either directly as a dictionary or an indirect object containing a dictionary.
func (r *PdfPageResources) GenerateXObjectName() core.PdfObjectName
GenerateXObjectName generates an unused XObject name that can be used for adding new XObjects. Uses format XObj1, XObj2, ...
func (r *PdfPageResources) GetColorspaceByName(keyName core.PdfObjectName) (PdfColorspace, bool)
GetColorspaceByName returns the colorspace with the specified name from the page resources.
func (r *PdfPageResources) GetColorspaces() (*PdfPageResourcesColorspaces, error)
GetColorspaces loads PdfPageResourcesColorspaces from `r.ColorSpace` and returns an error if there is a problem loading. Once loaded, the same object is returned on multiple calls.
func (r *PdfPageResources) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject returns the container of the resources object (indirect object).
func (r *PdfPageResources) GetExtGState(keyName core.PdfObjectName) (core.PdfObject, bool)
GetExtGState gets the ExtGState specified by keyName. Returns a bool indicating whether it was found or not.
func (r *PdfPageResources) GetFontByName(keyName core.PdfObjectName) (core.PdfObject, bool)
GetFontByName gets the font specified by keyName. Returns the PdfObject which the entry refers to. Returns a bool value indicating whether or not the entry was found.
func (r *PdfPageResources) GetPatternByName(keyName core.PdfObjectName) (*PdfPattern, bool)
GetPatternByName gets the pattern specified by keyName. Returns nil if not existing. The bool flag indicated whether it was found or not.
func (r *PdfPageResources) GetShadingByName(keyName core.PdfObjectName) (*PdfShading, bool)
GetShadingByName gets the shading specified by keyName. Returns nil if not existing. The bool flag indicated whether it was found or not.
func (r *PdfPageResources) GetXObjectByName(keyName core.PdfObjectName) (*core.PdfObjectStream, XObjectType)
GetXObjectByName returns the XObject with the specified keyName and the object type.
func (r *PdfPageResources) GetXObjectFormByName(keyName core.PdfObjectName) (*XObjectForm, error)
GetXObjectFormByName returns the XObjectForm with the specified name from the page resources, if it exists.
func (r *PdfPageResources) GetXObjectImageByName(keyName core.PdfObjectName) (*XObjectImage, error)
GetXObjectImageByName returns the XObjectImage with the specified name from the page resources, if it exists.
func (r *PdfPageResources) HasColorspaceByName(keyName core.PdfObjectName) bool
HasColorspaceByName checks if the colorspace with the specified name exists in the page resources.
func (r *PdfPageResources) HasExtGState(keyName core.PdfObjectName) bool
HasExtGState checks whether a font is defined by the specified keyName.
func (r *PdfPageResources) HasFontByName(keyName core.PdfObjectName) bool
HasFontByName checks whether a font is defined by the specified keyName.
func (r *PdfPageResources) HasXObjectByName(keyName core.PdfObjectName) bool
HasXObjectByName checks if an XObject with a specified keyName is defined.
func (r *PdfPageResources) SetColorSpace(colorspace *PdfPageResourcesColorspaces)
SetColorSpace sets `r` colorspace object to `colorspace`.
func (r *PdfPageResources) SetColorspaceByName(keyName core.PdfObjectName, cs PdfColorspace) error
SetColorspaceByName adds the provided colorspace to the page resources.
func (r *PdfPageResources) SetFontByName(keyName core.PdfObjectName, obj core.PdfObject) error
SetFontByName sets the font specified by keyName to the given object.
func (r *PdfPageResources) SetPatternByName(keyName core.PdfObjectName, pattern core.PdfObject) error
SetPatternByName sets a pattern resource specified by keyName.
func (r *PdfPageResources) SetShadingByName(keyName core.PdfObjectName, shadingObj core.PdfObject) error
SetShadingByName sets a shading resource specified by keyName.
func (r *PdfPageResources) SetXObjectByName(keyName core.PdfObjectName, stream *core.PdfObjectStream) error
SetXObjectByName adds the XObject from the passed in stream to the page resources. The added XObject is identified by the specified name.
func (r *PdfPageResources) SetXObjectFormByName(keyName core.PdfObjectName, xform *XObjectForm) error
SetXObjectFormByName adds the provided XObjectForm to the page resources. The added XObjectForm is identified by the specified name.
func (r *PdfPageResources) SetXObjectImageByName(keyName core.PdfObjectName, ximg *XObjectImage) error
SetXObjectImageByName adds the provided XObjectImage to the page resources. The added XObjectImage is identified by the specified name.
func (r *PdfPageResources) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the page resources.
PdfPageResourcesColorspaces contains the colorspace in the PdfPageResources. Needs to have matching name and colorspace map entry. The Names define the order.
type PdfPageResourcesColorspaces struct { Names []string Colorspaces map[string]PdfColorspace // contains filtered or unexported fields }
func NewPdfPageResourcesColorspaces() *PdfPageResourcesColorspaces
NewPdfPageResourcesColorspaces returns a new PdfPageResourcesColorspaces object.
func (rcs *PdfPageResourcesColorspaces) Set(key core.PdfObjectName, val PdfColorspace)
Set sets the colorspace corresponding to key. Add to Names if not set.
func (rcs *PdfPageResourcesColorspaces) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the colorspace.
A PdfPattern can represent a Pattern, either a tiling pattern or a shading pattern. Note that all patterns shall be treated as colours; a Pattern colour space shall be established with the CS or cs operator just like other colour spaces, and a particular pattern shall be installed as the current colour with the SCN or scn operator.
type PdfPattern struct { // Type: Pattern PatternType int64 // contains filtered or unexported fields }
func (p *PdfPattern) GetAsShadingPattern() *PdfShadingPattern
GetAsShadingPattern returns a shading pattern. Check with IsShading() prior to using this.
func (p *PdfPattern) GetAsTilingPattern() *PdfTilingPattern
GetAsTilingPattern returns a tiling pattern. Check with IsTiling() prior to using this.
func (p *PdfPattern) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject returns the container of the pattern object (indirect object).
func (p *PdfPattern) GetContext() PdfModel
GetContext returns a reference to the subpattern entry: either PdfTilingPattern or PdfShadingPattern.
func (p *PdfPattern) IsShading() bool
IsShading specifies if the pattern is a shading pattern.
func (p *PdfPattern) IsTiling() bool
IsTiling specifies if the pattern is a tiling pattern.
func (p *PdfPattern) SetContext(ctx PdfModel)
SetContext sets the sub pattern (context). Either PdfTilingPattern or PdfShadingPattern.
func (p *PdfPattern) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the pattern.
PdfReader represents a PDF file reader. It is a frontend to the lower level parsing mechanism and provides a higher level access to work with PDF structure and information, such as the page structure etc.
type PdfReader struct { PageList []*PdfPage AcroForm *PdfAcroForm DSS *DSS Rotate *int64 // contains filtered or unexported fields }
func NewPdfReader(rs io.ReadSeeker) (*PdfReader, error)
NewPdfReader returns a new PdfReader for an input io.ReadSeeker interface. Can be used to read PDF from memory or file. Immediately loads and traverses the PDF structure including pages and page contents (if not encrypted). Loads entire document structure into memory. Alternatively a lazy-loading reader can be created with NewPdfReaderLazy which loads only references, and references are loaded from disk into memory on an as-needed basis.
func NewPdfReaderFromFile(pdfFile string, opts *ReaderOpts) (*PdfReader, *os.File, error)
NewPdfReaderFromFile creates a new PdfReader from the speficied PDF file. If ReaderOpts is nil it will be set to default value from NewReaderOpts.
func NewPdfReaderLazy(rs io.ReadSeeker) (*PdfReader, error)
NewPdfReaderLazy creates a new PdfReader for `rs` in lazy-loading mode. The difference from NewPdfReader is that in lazy-loading mode, objects are only loaded into memory when needed rather than entire structure being loaded into memory on reader creation. Note that it may make sense to use the lazy-load reader when processing only parts of files, rather than loading entire file into memory. Example: splitting a few pages from a large PDF file.
func NewPdfReaderWithOpts(rs io.ReadSeeker, opts *ReaderOpts) (*PdfReader, error)
NewPdfReaderWithOpts creates a new PdfReader for an input io.ReadSeeker interface with a ReaderOpts. If ReaderOpts is nil it will be set to default value from NewReaderOpts.
func NewReaderForText(txt string) *PdfReader
NewReaderForText makes a new PdfReader for an input PDF content string. For use in testing.
func (r *PdfReader) AcroFormNeedsRepair() (bool, error)
AcroFormNeedsRepair returns true if the document contains widget annotations linked to fields which are not referenced in the AcroForm. The AcroForm can be repaired using the RepairAcroForm method of the reader.
func (r *PdfReader) CheckAccessRights(password []byte) (bool, security.Permissions, error)
CheckAccessRights checks access rights and permissions for a specified password. If either user/owner password is specified, full rights are granted, otherwise the access rights are specified by the Permissions flag.
The bool flag indicates that the user can access and view the file. The AccessPermissions shows what access the user has for editing etc. An error is returned if there was a problem performing the authentication.
func (r *PdfReader) Decrypt(password []byte) (bool, error)
Decrypt decrypts the PDF file with a specified password. Also tries to decrypt with an empty password. Returns true if successful, false otherwise.
func (r *PdfReader) FlattenFields(allannots bool, appgen FieldAppearanceGenerator) error
FlattenFields flattens the form fields and annotations for the PDF loaded in `pdf` and makes non-editable. Looks up all widget annotations corresponding to form fields and flattens them by drawing the content through the content stream rather than annotations. References to flattened annotations will be removed from Page Annots array. For fields the AcroForm entry will be emptied. When `allannots` is true, all annotations will be flattened. Keep false if want to keep non-form related annotations intact. When `appgen` is not nil, it will be used to generate appearance streams for the field annotations.
func (r *PdfReader) FlattenFieldsWithOpts(appgen FieldAppearanceGenerator, opts *FieldFlattenOpts) error
FlattenFieldsWithOpts flattens the AcroForm fields of the reader using the provided field appearance generator and the specified options. If no options are specified, all form fields are flattened. If a filter function is provided using the opts parameter, only the filtered fields are flattened. Otherwise, all form fields are flattened. At the end of the process, the AcroForm contains all the fields which were not flattened. If all fields are flattened, the reader's AcroForm field is set to nil.
func (r *PdfReader) GetCatalogMarkInfo() (core.PdfObject, bool)
GetCatalogMarkInfo gets catalog MarkInfo object.
func (r *PdfReader) GetCatalogMetadata() (core.PdfObject, bool)
GetCatalogMetadata gets the catalog defined XMP Metadata.
func (r *PdfReader) GetCatalogStructTreeRoot() (core.PdfObject, bool)
GetCatalogStructTreeRoot gets the catalog StructTreeRoot object.
func (r *PdfReader) GetEncryptionMethod() string
GetEncryptionMethod returns a descriptive information string about the encryption method used.
func (r *PdfReader) GetIndirectObjectByNumber(number int) (core.PdfObject, error)
GetIndirectObjectByNumber retrieves and returns a specific PdfObject by object number.
func (r *PdfReader) GetNameDictionary() (core.PdfObject, error)
GetNameDictionary returns the Names entry in the PDF catalog. See section 7.7.4 "Name Dictionary" (p. 80 PDF32000_2008).
func (r *PdfReader) GetNamedDestinations() (core.PdfObject, error)
GetNamedDestinations returns the Dests entry in the PDF catalog. See section 12.3.2.3 "Named Destinations" (p. 367 PDF32000_2008).
func (r *PdfReader) GetNumPages() (int, error)
GetNumPages returns the number of pages in the document.
func (r *PdfReader) GetOCProperties() (core.PdfObject, error)
GetOCProperties returns the optional content properties PdfObject.
func (r *PdfReader) GetObjectNums() []int
GetObjectNums returns the object numbers of the PDF objects in the file Numbered objects are either indirect objects or stream objects. e.g. objNums := pdfReader.GetObjectNums() The underlying objects can then be accessed with pdfReader.GetIndirectObjectByNumber(objNums[0]) for the first available object.
func (r *PdfReader) GetOutlineTree() *PdfOutlineTreeNode
GetOutlineTree returns the outline tree.
func (r *PdfReader) GetOutlines() (*Outline, error)
GetOutlines returns a high-level Outline object, based on the outline tree of the reader.
func (r *PdfReader) GetOutlinesFlattened() ([]*PdfOutlineTreeNode, []string, error)
GetOutlinesFlattened returns a flattened list of tree nodes and titles. NOTE: for most use cases, it is recommended to use the high-level GetOutlines method instead, which also provides information regarding the destination of the outline items.
func (r *PdfReader) GetPage(pageNumber int) (*PdfPage, error)
GetPage returns the PdfPage model for the specified page number.
func (r *PdfReader) GetPageLabels() (core.PdfObject, error)
GetPageLabels returns the PageLabels entry in the PDF catalog. See section 12.4.2 "Page Labels" (p. 382 PDF32000_2008).
func (r *PdfReader) GetPdfInfo() (*PdfInfo, error)
GetPdfInfo returns the PDF info dictionary.
func (r *PdfReader) GetPerms() *Permissions
GetPerms returns the Permissions dictionary
func (r *PdfReader) GetPreviousRevision() (*PdfReader, error)
GetPreviousRevision returns the previous revision of PdfReader for the Pdf document
func (r *PdfReader) GetRevision(revisionNumber int) (*PdfReader, error)
GetRevision returns the specific version of the PdfReader for the current Pdf document
func (r *PdfReader) GetRevisionNumber() int
GetRevisionNumber returns the version of the current Pdf document
func (r *PdfReader) GetTrailer() (*core.PdfObjectDictionary, error)
GetTrailer returns the PDF's trailer dictionary.
func (r *PdfReader) Inspect() (map[string]int, error)
Inspect inspects the object types, subtypes and content in the PDF file returning a map of object type to number of instances of each.
func (r *PdfReader) IsEncrypted() (bool, error)
IsEncrypted returns true if the PDF file is encrypted.
func (r *PdfReader) PageFromIndirectObject(ind *core.PdfIndirectObject) (*PdfPage, int, error)
PageFromIndirectObject returns the PdfPage and page number for a given indirect object.
func (r *PdfReader) PdfVersion() core.Version
PdfVersion returns version of the PDF file.
func (r *PdfReader) RepairAcroForm(opts *AcroFormRepairOptions) error
RepairAcroForm attempts to rebuild the AcroForm fields using the widget annotations present in the document pages. Pass nil for the opts parameter in order to use the default options. NOTE: Currently, the opts parameter is declared in order to enable adding future options, but passing nil will always result in the default options being used.
func (r *PdfReader) ToWriter(opts *ReaderToWriterOpts) (*PdfWriter, error)
ToWriter creates a new writer from the current reader, based on the specified options. If no options are provided, all reader properties are copied to the writer.
func (r *PdfReader) ValidateSignatures(handlers []SignatureHandler) ([]SignatureValidationResult, error)
ValidateSignatures validates digital signatures in the document.
PdfRectangle is a definition of a rectangle.
type PdfRectangle struct { Llx float64 // Lower left corner (ll). Lly float64 Urx float64 // Upper right corner (ur). Ury float64 }
func NewPdfRectangle(arr core.PdfObjectArray) (*PdfRectangle, error)
NewPdfRectangle creates a PDF rectangle object based on an input array of 4 integers. Defining the lower left (LL) and upper right (UR) corners with floating point numbers.
func (rect *PdfRectangle) Height() float64
Height returns the height of `rect`.
func (rect *PdfRectangle) Normalize()
Normalize swaps (Llx,Urx) if Urx < Llx, and (Lly,Ury) if Ury < Lly.
func (rect *PdfRectangle) ToPdfObject() core.PdfObject
ToPdfObject converts rectangle to a PDF object.
func (rect *PdfRectangle) Width() float64
Width returns the width of `rect`.
PdfShading represents a shading dictionary. There are 7 types of shading, indicatedby the shading type variable: 1: Function-based shading. 2: Axial shading. 3: Radial shading. 4: Free-form Gouraud-shaded triangle mesh. 5: Lattice-form Gouraud-shaded triangle mesh. 6: Coons patch mesh. 7: Tensor-product patch mesh. types 4-7 are contained in a stream object, where the dictionary is given by the stream dictionary.
type PdfShading struct { ShadingType *core.PdfObjectInteger ColorSpace PdfColorspace Background *core.PdfObjectArray BBox *PdfRectangle AntiAlias *core.PdfObjectBool // contains filtered or unexported fields }
func (s *PdfShading) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject returns the container of the shading object (indirect object).
func (s *PdfShading) GetContext() PdfModel
GetContext returns a reference to the subshading entry as represented by PdfShadingType1-7.
func (s *PdfShading) SetContext(ctx PdfModel)
SetContext set the sub annotation (context).
func (s *PdfShading) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the shading dictionary.
PdfShadingPattern is a Shading patterns that provide a smooth transition between colors across an area to be painted, i.e. color(x,y) = f(x,y) at each point. It is a type 2 pattern (PatternType = 2).
type PdfShadingPattern struct { *PdfPattern Shading *PdfShading Matrix *core.PdfObjectArray ExtGState core.PdfObject }
func (p *PdfShadingPattern) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the shading pattern.
PdfShadingType1 is a Function-based shading.
type PdfShadingType1 struct { *PdfShading Domain *core.PdfObjectArray Matrix *core.PdfObjectArray Function []PdfFunction }
func (s *PdfShadingType1) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the shading dictionary.
PdfShadingType2 is an Axial shading.
type PdfShadingType2 struct { *PdfShading Coords *core.PdfObjectArray Domain *core.PdfObjectArray Function []PdfFunction Extend *core.PdfObjectArray }
func (s *PdfShadingType2) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the shading dictionary.
PdfShadingType3 is a Radial shading.
type PdfShadingType3 struct { *PdfShading Coords *core.PdfObjectArray Domain *core.PdfObjectArray Function []PdfFunction Extend *core.PdfObjectArray }
func (s *PdfShadingType3) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the shading dictionary.
PdfShadingType4 is a Free-form Gouraud-shaded triangle mesh.
type PdfShadingType4 struct { *PdfShading BitsPerCoordinate *core.PdfObjectInteger BitsPerComponent *core.PdfObjectInteger BitsPerFlag *core.PdfObjectInteger Decode *core.PdfObjectArray Function []PdfFunction }
func (s *PdfShadingType4) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the shading dictionary.
PdfShadingType5 is a Lattice-form Gouraud-shaded triangle mesh.
type PdfShadingType5 struct { *PdfShading BitsPerCoordinate *core.PdfObjectInteger BitsPerComponent *core.PdfObjectInteger VerticesPerRow *core.PdfObjectInteger Decode *core.PdfObjectArray Function []PdfFunction }
func (s *PdfShadingType5) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the shading dictionary.
PdfShadingType6 is a Coons patch mesh.
type PdfShadingType6 struct { *PdfShading BitsPerCoordinate *core.PdfObjectInteger BitsPerComponent *core.PdfObjectInteger BitsPerFlag *core.PdfObjectInteger Decode *core.PdfObjectArray Function []PdfFunction }
func (s *PdfShadingType6) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the shading dictionary.
PdfShadingType7 is a Tensor-product patch mesh.
type PdfShadingType7 struct { *PdfShading BitsPerCoordinate *core.PdfObjectInteger BitsPerComponent *core.PdfObjectInteger BitsPerFlag *core.PdfObjectInteger Decode *core.PdfObjectArray Function []PdfFunction }
func (s *PdfShadingType7) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the shading dictionary.
PdfSignature represents a PDF signature dictionary and is used for signing via form signature fields. (Section 12.8, Table 252 - Entries in a signature dictionary p. 475 in PDF32000_2008).
type PdfSignature struct { Handler SignatureHandler // Type: Sig/DocTimeStamp Type *core.PdfObjectName Filter *core.PdfObjectName SubFilter *core.PdfObjectName Contents *core.PdfObjectString Cert core.PdfObject ByteRange *core.PdfObjectArray Reference *core.PdfObjectArray Changes *core.PdfObjectArray Name *core.PdfObjectString M *core.PdfObjectString Location *core.PdfObjectString Reason *core.PdfObjectString ContactInfo *core.PdfObjectString R *core.PdfObjectInteger V *core.PdfObjectInteger PropBuild *core.PdfObjectDictionary PropAuthTime *core.PdfObjectInteger PropAuthType *core.PdfObjectName // contains filtered or unexported fields }
func NewPdfSignature(handler SignatureHandler) *PdfSignature
NewPdfSignature creates a new PdfSignature object.
func (sig *PdfSignature) GetCerts() ([]*x509.Certificate, error)
GetCerts returns the signature certificate chain.
func (sig *PdfSignature) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject implements interface PdfModel.
func (sig *PdfSignature) GetDocMDPPermission() (mdp.DocMDPPermission, bool)
GetDocMDPPermission returns the DocMDP level of the restrictions
func (sig *PdfSignature) Initialize() error
Initialize initializes the PdfSignature.
func (sig *PdfSignature) SetDate(date time.Time, format string)
SetDate sets the `M` field of the signature.
func (sig *PdfSignature) SetLocation(location string)
SetLocation sets the `Location` field of the signature.
func (sig *PdfSignature) SetName(name string)
SetName sets the `Name` field of the signature.
func (sig *PdfSignature) SetReason(reason string)
SetReason sets the `Reason` field of the signature.
func (sig *PdfSignature) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfSignatureReference represents a PDF signature reference dictionary and is used for signing via form signature fields. (Section 12.8.1, Table 253 - Entries in a signature reference dictionary p. 469 in PDF32000_2008).
type PdfSignatureReference struct { Type *core.PdfObjectName TransformMethod *core.PdfObjectName TransformParams core.PdfObject Data core.PdfObject DigestMethod *core.PdfObjectName // contains filtered or unexported fields }
func NewPdfSignatureReferenceDocMDP(transformParams *PdfTransformParamsDocMDP) *PdfSignatureReference
NewPdfSignatureReferenceDocMDP returns PdfSignatureReference for the transformParams.
func (sigref *PdfSignatureReference) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject implements interface PdfModel.
func (sigref *PdfSignatureReference) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
PdfTilingPattern is a Tiling pattern that consists of repetitions of a pattern cell with defined intervals. It is a type 1 pattern. (PatternType = 1). A tiling pattern is represented by a stream object, where the stream content is a content stream that describes the pattern cell.
type PdfTilingPattern struct { *PdfPattern PaintType *core.PdfObjectInteger // Colored or uncolored tiling pattern. TilingType *core.PdfObjectInteger // Constant spacing, no distortion or constant spacing/faster tiling. BBox *PdfRectangle XStep *core.PdfObjectFloat YStep *core.PdfObjectFloat Resources *PdfPageResources Matrix *core.PdfObjectArray // Pattern matrix (6 numbers). }
func (p *PdfTilingPattern) GetContentStream() ([]byte, error)
GetContentStream returns the pattern cell's content stream
func (p *PdfTilingPattern) GetContentStreamWithEncoder() ([]byte, core.StreamEncoder, error)
GetContentStreamWithEncoder returns the pattern cell's content stream and its encoder
func (p *PdfTilingPattern) IsColored() bool
IsColored specifies if the pattern is colored.
func (p *PdfTilingPattern) SetContentStream(content []byte, encoder core.StreamEncoder) error
SetContentStream sets the pattern cell's content stream.
func (p *PdfTilingPattern) ToPdfObject() core.PdfObject
ToPdfObject returns the PDF representation of the tiling pattern.
PdfTransformParamsDocMDP represents a transform parameters dictionary for the DocMDP method and is used to detect modifications relative to a signature field that is signed by the author of a document. (Section 12.8.2.2, Table 254 - Entries in the DocMDP transform parameters dictionary p. 471 in PDF32000_2008).
type PdfTransformParamsDocMDP struct { Type *core.PdfObjectName P *core.PdfObjectInteger V *core.PdfObjectName }
func NewPdfTransformParamsDocMDP(permission mdp.DocMDPPermission) *PdfTransformParamsDocMDP
NewPdfTransformParamsDocMDP create a PdfTransformParamsDocMDP with the specific permissions.
func (sig *PdfTransformParamsDocMDP) String() string
String returns a string representation of PdfTransformParamsDocMDP.
func (sig *PdfTransformParamsDocMDP) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
func (sig *PdfTransformParamsDocMDP) WriteString() string
WriteString outputs the object as it is to be written to file.
PdfWriter handles outputing PDF content.
type PdfWriter struct { ObjNumOffset int // contains filtered or unexported fields }
func NewPdfWriter() PdfWriter
NewPdfWriter initializes a new PdfWriter.
func (w *PdfWriter) AddExtension(extName, baseVersion string, extLevel int)
AddExtension adds the specified extension to the Extensions dictionary. See section 7.1.2 "Extensions Dictionary" (pp. 108-109 PDF32000_2008).
func (w *PdfWriter) AddOutlineTree(outlineTree *PdfOutlineTreeNode)
AddOutlineTree adds outlines to a PDF file.
func (w *PdfWriter) AddPage(page *PdfPage) error
AddPage adds a page to the PDF file. The new page should be an indirect object.
func (w *PdfWriter) ApplyStandard(optimizer StandardApplier)
ApplyStandard is used to apply changes required on the document to match the rules required by the input standard. The writer's content would be changed after all the document parts are already established during the Write method. A good example of the StandardApplier could be a PDF/A Profile (i.e.: pdfa.Profile1A). In such a case PdfWriter would set up all rules required by that Profile.
func (w *PdfWriter) Encrypt(userPass, ownerPass []byte, options *EncryptOptions) error
Encrypt encrypts the output file with a specified user/owner password.
func (w *PdfWriter) GetOptimizer() Optimizer
GetOptimizer returns current PDF optimizer.
func (w *PdfWriter) GetPdfVersion() string
GetPdfVersion gets the version of the PDF used within this document.
func (w *PdfWriter) GetStandardApplier() StandardApplier
GetStandardApplier gets currently used StandardApplier..
func (w *PdfWriter) GetVersion() core.Version
GetVersion gets the document version.
func (w *PdfWriter) SetCatalogMetadata(meta core.PdfObject) error
SetCatalogMetadata sets the catalog metadata (XMP) stream object.
func (w *PdfWriter) SetDocInfo(info *PdfInfo)
SetDocInfo set document info. This will overwrite any globally declared document info.
func (w *PdfWriter) SetForms(form *PdfAcroForm) error
SetForms sets the Acroform for a PDF file.
func (w *PdfWriter) SetNameDictionary(names core.PdfObject) error
SetNameDictionary sets the Names entry in the PDF catalog. See section 7.7.4 "Name Dictionary" (p. 80 PDF32000_2008).
func (w *PdfWriter) SetNamedDestinations(dests core.PdfObject) error
SetNamedDestinations sets the Dests entry in the PDF catalog. See section 12.3.2.3 "Named Destinations" (p. 367 PDF32000_2008).
func (w *PdfWriter) SetOCProperties(ocProperties core.PdfObject) error
SetOCProperties sets the optional content properties.
func (w *PdfWriter) SetOpenAction(dest core.PdfObject) error
SetOpenAction sets the OpenAction in the PDF catalog. The value shall be either an array defining a destination (12.3.2 "Destinations" PDF32000_2008), or an action dictionary representing an action (12.6 "Actions" PDF32000_2008).
func (w *PdfWriter) SetOptimizer(optimizer Optimizer)
SetOptimizer sets the optimizer to optimize PDF before writing.
func (w *PdfWriter) SetPageLabels(pageLabels core.PdfObject) error
SetPageLabels sets the PageLabels entry in the PDF catalog. See section 12.4.2 "Page Labels" (p. 382 PDF32000_2008).
func (w *PdfWriter) SetRotation(rotate int64) error
SetRotation sets the rotation of all pages added to writer. The rotation is specified in degrees and must be a multiple of 90. The Rotate field of individual pages has priority over the global rotation.
func (w *PdfWriter) SetVersion(majorVersion, minorVersion int)
SetVersion sets the PDF version of the output file.
func (w *PdfWriter) Write(writer io.Writer) error
Write writes out the PDF.
func (w *PdfWriter) WriteToFile(outputFilePath string) error
WriteToFile writes the output PDF to file.
Permissions specify a permissions dictionary (PDF 1.5). (Section 12.8.4, Table 258 - Entries in a permissions dictionary p. 477 in PDF32000_2008).
type Permissions struct { DocMDP *PdfSignature // contains filtered or unexported fields }
func NewPermissions(docMdp *PdfSignature) *Permissions
NewPermissions returns a new permissions object.
func (p *Permissions) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject implements interface PdfModel.
func (p *Permissions) ToPdfObject() core.PdfObject
ToPdfObject implements interface PdfModel.
ReaderOpts defines options for creating PdfReader instances.
type ReaderOpts struct { // Password password of the PDF file encryption. // Default: empty (""). Password string // LazyLoad set if the PDF file would be loaded using lazy-loading mode. // Default: true. LazyLoad bool // ComplianceMode set if parsed PDF file should contain meta information for the verifiers of the compliance standards like PDF/A. ComplianceMode bool }
func NewReaderOpts() *ReaderOpts
NewReaderOpts generates a default `ReaderOpts` instance.
ReaderToWriterOpts options used to generate a PdfWriter.
type ReaderToWriterOpts struct { SkipAcroForm bool SkipInfo bool SkipNameDictionary bool SkipNamedDests bool SkipOCProperties bool SkipOutlines bool SkipPageLabels bool SkipRotation bool SkipMetadata bool PageProcessCallback PageProcessCallback // Deprecated: will be removed in v4. Use PageProcessCallback instead. PageCallback PageCallback }
SignatureHandler interface defines the common functionality for PDF signature handlers, which need to be capable of validating digital signatures and signing PDF documents.
type SignatureHandler interface { // IsApplicable checks if a given signature dictionary `sig` is applicable for the signature handler. // For example a signature of type `adbe.pkcs7.detached` might not fit for a rsa.sha1 handler. IsApplicable(sig *PdfSignature) bool // Validate validates a PDF signature against a given digest (hash) such as that determined // for an input file. Returns validation results. Validate(sig *PdfSignature, digest Hasher) (SignatureValidationResult, error) // InitSignature prepares the signature dictionary for signing. This involves setting all // necessary fields, and also allocating sufficient space to the Contents so that the // finalized signature can be inserted once the hash is calculated. InitSignature(sig *PdfSignature) error // NewDigest creates a new digest/hasher based on the signature dictionary and handler. NewDigest(sig *PdfSignature) (Hasher, error) // Sign receives the hash `digest` (for example hash of an input file), and signs based // on the signature dictionary `sig` and applies the signature data to the signature // dictionary Contents field. Sign(sig *PdfSignature, digest Hasher) error }
SignatureHandlerDocMDP extends SignatureHandler with the ValidateWithOpts method for checking the DocMDP policy.
type SignatureHandlerDocMDP interface { SignatureHandler // ValidateWithOpts validates a PDF signature by checking PdfReader or PdfParser // ValidateWithOpts shall contain Validate call ValidateWithOpts(sig *PdfSignature, digest Hasher, params SignatureHandlerDocMDPParams) (SignatureValidationResult, error) }
SignatureHandlerDocMDPParams describe the specific parameters for the SignatureHandlerEx These parameters describe how to check the difference between revisions. Revisions of the document get from the PdfParser.
type SignatureHandlerDocMDPParams struct { Parser *core.PdfParser DiffPolicy mdp.DiffPolicy }
SignatureValidationResult defines the response from the signature validation handler.
type SignatureValidationResult struct { // List of errors when validating the signature. Errors []string IsSigned bool IsVerified bool IsTrusted bool Fields []*PdfField Name string Date PdfDate Reason string Location string ContactInfo string DiffResults *mdp.DiffResults // GeneralizedTime is the time at which the time-stamp token has been created by the TSA (RFC 3161). GeneralizedTime time.Time }
func (v SignatureValidationResult) String() string
StandardApplier is the interface that performs optimization of the whole PDF document. As a result an input document is being changed by the optimizer. The writer than takes back all it's parts and overwrites it. NOTE: This implementation is in experimental development state.
Keep in mind that it might change in the subsequent minor versions.
type StandardApplier interface { ApplyStandard(document *docutil.Document) error }
StandardImplementer is an interface that defines specified PDF standards like PDF/A-1A (pdfa.Profile1A) NOTE: This implementation is in experimental development state.
Keep in mind that it might change in the subsequent minor versions.
type StandardImplementer interface { StandardValidator StandardApplier // StandardName gets the human-readable name of the standard. StandardName() string }
StandardValidator is the interface that is used for the PDF StandardImplementer validation for the PDF document. It is using a CompliancePdfReader which is expected to give more Metadata during reading process. NOTE: This implementation is in experimental development state.
Keep in mind that it might change in the subsequent minor versions.
type StandardValidator interface { // ValidateStandard checks if the input reader ValidateStandard(dr *CompliancePdfReader) error }
StdFontName represents name of a standard font.
type StdFontName = fonts.StdFontName
VRI represents a Validation-Related Information dictionary. The VRI dictionary contains validation data in the form of certificates, OCSP and CRL information, for a single signature. See ETSI TS 102 778-4 V1.1.1 for more information.
type VRI struct { Cert []*core.PdfObjectStream OCSP []*core.PdfObjectStream CRL []*core.PdfObjectStream TU *core.PdfObjectString TS *core.PdfObjectString }
func (v *VRI) ToPdfObject() *core.PdfObjectDictionary
ToPdfObject returns the PDF representation of the VRI dictionary.
VariableText contains the common attributes of a variable text. The VariableText is typically not used directly, but is can encapsulate by PdfField See section 12.7.3.3 "Variable Text" and Table 222 (pp. 434-436 PDF32000_2008).
type VariableText struct { DA *core.PdfObjectString Q *core.PdfObjectInteger DS *core.PdfObjectString RV core.PdfObject }
WatermarkImageOptions contains options for configuring the watermark process.
type WatermarkImageOptions struct { Alpha float64 FitToWidth bool PreserveAspectRatio bool }
XObjectForm (Table 95 in 8.10.2).
type XObjectForm struct { Filter core.StreamEncoder FormType core.PdfObject BBox core.PdfObject Matrix core.PdfObject Resources *PdfPageResources Group core.PdfObject Ref core.PdfObject MetaData core.PdfObject PieceInfo core.PdfObject LastModified core.PdfObject StructParent core.PdfObject StructParents core.PdfObject OPI core.PdfObject OC core.PdfObject Name core.PdfObject // Stream data. Stream []byte // contains filtered or unexported fields }
func NewXObjectForm() *XObjectForm
NewXObjectForm creates a brand new XObject Form. Creates a new underlying PDF object stream primitive.
func NewXObjectFormFromStream(stream *core.PdfObjectStream) (*XObjectForm, error)
NewXObjectFormFromStream builds the Form XObject from a stream object. TODO: Should this be exposed? Consider different access points.
func (xform *XObjectForm) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject returns the XObject Form's containing object (indirect object).
func (xform *XObjectForm) GetContentStream() ([]byte, error)
GetContentStream returns the XObject Form's content stream.
func (xform *XObjectForm) SetContentStream(content []byte, encoder core.StreamEncoder) error
SetContentStream updates the content stream with specified encoding. If encoding is null, will use the xform.Filter object or Raw encoding if not set.
func (xform *XObjectForm) ToPdfObject() core.PdfObject
ToPdfObject returns a stream object.
XObjectImage (Table 89 in 8.9.5.1). Implements PdfModel interface.
type XObjectImage struct { //ColorSpace PdfObject Width *int64 Height *int64 ColorSpace PdfColorspace BitsPerComponent *int64 Filter core.StreamEncoder Intent core.PdfObject ImageMask core.PdfObject Mask core.PdfObject Matte core.PdfObject Decode core.PdfObject Interpolate core.PdfObject Alternatives core.PdfObject SMask core.PdfObject SMaskInData core.PdfObject Name core.PdfObject // Obsolete. Currently read if available and write if available. Not setting on new created files. StructParent core.PdfObject ID core.PdfObject OPI core.PdfObject Metadata core.PdfObject OC core.PdfObject Stream []byte // contains filtered or unexported fields }
func NewXObjectImage() *XObjectImage
NewXObjectImage returns a new XObjectImage.
func NewXObjectImageFromImage(img *Image, cs PdfColorspace, encoder core.StreamEncoder) (*XObjectImage, error)
NewXObjectImageFromImage creates a new XObject Image from an image object with default options. If encoder is nil, uses raw encoding (none).
func NewXObjectImageFromStream(stream *core.PdfObjectStream) (*XObjectImage, error)
NewXObjectImageFromStream builds the image xobject from a stream object. An image dictionary is the dictionary portion of a stream object representing an image XObject.
func UpdateXObjectImageFromImage(xobjIn *XObjectImage, img *Image, cs PdfColorspace, encoder core.StreamEncoder) (*XObjectImage, error)
UpdateXObjectImageFromImage creates a new XObject Image from an Image object `img` and default masks from xobjIn. The default masks are overridden if img.hasAlpha If `encoder` is nil, uses raw encoding (none).
func (ximg *XObjectImage) GetContainingPdfObject() core.PdfObject
GetContainingPdfObject returns the container of the image object (indirect object).
func (ximg *XObjectImage) SetFilter(encoder core.StreamEncoder) error
SetFilter sets compression filter. Decodes with current filter sets and encodes the data with the new filter.
func (ximg *XObjectImage) SetImage(img *Image, cs PdfColorspace) error
SetImage updates XObject Image with new image data.
func (ximg *XObjectImage) ToImage() (*Image, error)
ToImage converts an object to an Image which can be transformed or saved out. The image data is decoded and the Image returned.
func (ximg *XObjectImage) ToPdfObject() core.PdfObject
ToPdfObject returns a stream object.
XObjectType represents the type of an XObject.
type XObjectType int
XObject types.
const ( XObjectTypeUndefined XObjectType = iota XObjectTypeImage XObjectTypeForm XObjectTypePS XObjectTypeUnknown )
Name | Synopsis |
---|---|
.. | |
mdp | |
optimize | |
tests | Package tests provides integration tests for the UniPDF optimizer. |
pdfa | Package pdfa provides abstraction to optimize and verify documents with respect to the PDF/A standards. |
sighandler | Package sighandler implements digital signature handlers for PDF signature validation and signing. |
sigutil | |
xmputil | Package xmputil provides abstraction used by the pdf document XMP Metadata. |
pdfaextension | |
pdfaid |