podofo

package
v0.0.0-...-6d64815 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2023 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BufferSize is used for internal buffers.
	BufferSize = 4096

	// DefaultPDFVersion is the default PDF version
	// used by new PDF documents.
	DefaultPDFVersion = pdf.Version14
)

Variables

View Source
var (
	ErrUnknown                   = errors.New("unknown error")
	ErrInvalidHandle             = errors.New("invalid handle")
	ErrFileNotFound              = fs.ErrNotExist
	ErrInvalidDeviceOperation    = errors.New("invalid device operation")
	ErrUnexpectedEOF             = io.ErrUnexpectedEOF
	ErrValueOutOfRange           = pdf.ErrValueOutOfRange
	ErrInternalLogic             = errors.New("internal logic")
	ErrInvalidEnumValue          = errors.New("invalid enum value")
	ErrBrokenFile                = errors.New("file is broken")
	ErrPageNotFound              = errors.New("page not found")
	ErrNoPDFFile                 = errors.New("not a PDF file")
	ErrNoXRef                    = errors.New("no valid XRef")
	ErrNoTrailer                 = errors.New("no trailer")
	ErrNoNumber                  = errors.New("not a number")
	ErrNoObject                  = errors.New("not an object")
	ErrNoEOFToken                = errors.New("EOF token not found")
	ErrInvalidTrailerSize        = errors.New("invalid trailer size")
	ErrInvalidDataType           = errors.New("invalid data type")
	ErrInvalidXRef               = errors.New("invalid XRef")
	ErrInvalidXRefStream         = errors.New("invalid XRef stream")
	ErrInvalidXRefType           = errors.New("invalid XRef type")
	ErrInvalidPredictor          = errors.New("invalid predictor")
	ErrInvalidStrokeStyle        = errors.New("invalid stroke style")
	ErrInvalidHexString          = errors.New("invalid hex string")
	ErrInvalidStream             = errors.New("invalid stream")
	ErrInvalidStreamLength       = errors.New("invalid stream len")
	ErrInvalidKey                = errors.New("invalid key")
	ErrInvalidName               = errors.New("invalid name")
	ErrInvalidEncryptionDict     = errors.New("invalid encryption dict")
	ErrInvalidPassword           = errors.New("invalid password")
	ErrInvalidFontData           = errors.New("invalid font data")
	ErrInvalidContentStream      = errors.New("invalid content stream")
	ErrUnsupportedVersion        = pdf.ErrUnsupportedVersion
	ErrUnsupportedFilter         = errors.New("unsupported filter")
	ErrUnsupportedFontFormat     = errors.New("unsupported font format")
	ErrUnsupportedImageFormat    = errors.New("unsupported image format")
	ErrActionAlreadyPresent      = errors.New("action already present")
	ErrWrongDestinationType      = errors.New("wrong destination type")
	ErrMissingEndStream          = errors.New("missing steram end")
	ErrDate                      = errors.New("bad date")
	ErrFlate                     = errors.New("flate")
	ErrFreeType                  = errors.New("free type")
	ErrSignature                 = errors.New("signature")
	ErrCannotConvertColor        = pdf.ErrCannotConvertColor
	ErrNotImplemented            = pdf.ErrNotImplemented
	ErrDestinationAlreadyPresent = errors.New("destination already present")
	ErrChangeOnImmutable         = errors.New("change on immutable")
	ErrNotCompiled               = errors.New("not compiled")
	ErrOutlineItemAlreadyPresent = errors.New("outline already present")
	ErrNotLoadedForUpdate        = errors.New("not loaded for update")
	ErrCannotEncrypUpdate        = errors.New("cannot encrypt update")
	ErrXMPMetadata               = errors.New("xmp metadata")
)

Functions

func PainterFlagNoSaveRestore

func PainterFlagNoSaveRestore(p *painterFlag)

PainterFlagNoSaveRestore disables Save/Restore of added content in this painting session.

func PainterFlagNoSaveRestorePrior

func PainterFlagNoSaveRestorePrior(p *painterFlag)

PainterFlagNoSaveRestorePrior disables Save/Restore or previous content. Implies PainterFlagRawCoordinates.

func PainterFlagPrepend

func PainterFlagPrepend(p *painterFlag)

PainterFlagPrepend does nothing for now.

func PainterFlagRawCoordinates

func PainterFlagRawCoordinates(p *painterFlag)

PainterFlagRawCoordinates does nothing for now.

Types

type AnnotationFlag

type AnnotationFlag uint32
const (
	AnnotationFlagNone      AnnotationFlag = 0x0000
	AnnotationFlagInvisible AnnotationFlag = 1 << (iota - 1)
	AnnotationFlagHidden
	AnnotationFlagPrint
	AnnotationFlagNoZoom
	AnnotationFlagNoRotate
	AnnotationFlagNoView
	AnnotationFlagReadOnly
	AnnotationFlagLocked
	AnnotationFlagToggleNoView
	AnnotationFlagLockedContents
)

type AnnotationType

type AnnotationType uint8
const (
	AnnotationTypeUnknown AnnotationType = iota
	AnnotationTypeText
	AnnotationTypeLink
	AnnotationTypeFreeText
	AnnotationTypeLine
	AnnotationTypeSquare
	AnnotationTypeCircle
	AnnotationTypePolygon
	AnnotationTypePolyLine
	AnnotationTypeHighlight
	AnnotationTypeUnderline
	AnnotationTypeSquiggly
	AnnotationTypeStrikeOut
	AnnotationTypeStamp
	AnnotationTypeCaret
	AnnotationTypeInk
	AnnotationTypePopup
	AnnotationTypeFileAttachement
	AnnotationTypeSound
	AnnotationTypeMovie
	AnnotationTypeWidget
	AnnotationTypeScreen
	AnnotationTypePrinterMark
	AnnotationTypeTrapNet
	AnnotationTypeWatermark
	AnnotationTypeModel3D
	AnnotationTypeRichMedia
	AnnotationTypeWebMedia
	AnnotationTypeRedact
	AnnotationTypeProjection
)

type AppearanceType

type AppearanceType uint8
const (
	AppearenceTypeNormal AppearanceType = iota
	AppearenceTypeRollover
	AppearenceTypeDown
)

type Array

type Array struct {
	pdf.BaseObject
	// contains filtered or unexported fields
}

func (*Array) Append

func (array *Array) Append(objects ...Object) error

func (*Array) AppendIndirect

func (array *Array) AppendIndirect(objects ...Object) error

func (*Array) AppendIndirectSafe

func (array *Array) AppendIndirectSafe(objects ...Object) error

func (*Array) At

func (array *Array) At(index int) Object

func (*Array) Clear

func (array *Array) Clear()

func (*Array) Copy

func (array *Array) Copy() (obj Object, err error)

func (*Array) Kind

func (array *Array) Kind() ObjectKind

func (*Array) MarshalPDF

func (array *Array) MarshalPDF(w *pdf.Writer) (err error)

func (*Array) NumObjects

func (array *Array) NumObjects() int

func (*Array) Remove

func (array *Array) Remove(index int) error

func (*Array) Set

func (array *Array) Set(index int, obj Object)

func (*Array) SetIndirect

func (array *Array) SetIndirect(index int, obj Object) (Object, error)

func (*Array) SetIndirectSafe

func (array *Array) SetIndirectSafe(index int, obj Object) (Object, error)

type BlendMode

type BlendMode uint8
const (
	BlendModeNormal BlendMode = iota
	BlendModeMultiply
	BlendModeScreen
	BlendModeOverlay
	BlendModeDarken
	BlendModeLighten
	BlendModeColorDodge
	BlendModeColorBurn
	BlendModeHardLight
	BlendModeSoftLight
	BlendModeDifference
	BlendModeExclusion
	BlendModeHue
	BlendModeSaturation
	BlendModeColor
	BlendModeLuminosity
)

type Bool

type Bool bool

func (Bool) Kind

func (b Bool) Kind() ObjectKind

func (Bool) WriteTo

func (b Bool) WriteTo(w io.Writer) (n int64, err error)

type CIDToGIDMap

type CIDToGIDMap []struct {
	CID, GID uint
}

CIDToGIDMap is a backing storage for a CID to GID map.

It must preserve ordering.

type CanvasObject

type CanvasObject interface {
}

type Contents

type Contents struct {
	// contains filtered or unexported fields
}

func NewContents

func NewContents(parent *Page, obj Object) (*Contents, error)

func (*Contents) MarshalPDF

func (c *Contents) MarshalPDF(w *pdf.Writer) (err error)

func (*Contents) Object

func (c *Contents) Object() Object

type DataContainer

type DataContainer interface {
	Owner() Object
	SetOwner(owner Object)

	ObjectDocument() *Document
	GetIndirectObject(*Reference) Object

	SetDirty()
	ResetDirty()

	IsIndirectReferenceAllowed(obj Object) bool
}

type Dictionary

type Dictionary struct {
	pdf.BaseObject
	// contains filtered or unexported fields
}

Dictionary is the PDF Dictionary data type.

func (*Dictionary) AddKey

func (d *Dictionary) AddKey(name pdf.Name, obj Object)

AddKey adds key to the dictionary.

func (*Dictionary) AddKeyIndirect

func (d *Dictionary) AddKeyIndirect(name pdf.Name, obj Object) error

AddKeyIndirect adds key to the dictionary.

func (*Dictionary) Copy

func (d *Dictionary) Copy() (Object, error)

func (*Dictionary) Int

func (d *Dictionary) Int(name pdf.Name, defval int64) int64

Int finds an object and converts it to int64.

func (*Dictionary) Key

func (d *Dictionary) Key(name pdf.Name) Object

Key finds an object in the dictionry. Nil is returned if the key does not exist.

func (*Dictionary) Kind

func (d *Dictionary) Kind() ObjectKind

Kind returns the kind of the PDFObject.

func (*Dictionary) MarshalPDF

func (d *Dictionary) MarshalPDF(w *pdf.Writer) error

type Document

type Document = pdf.Document

type DocumentOptionFunc

type DocumentOptionFunc func(doc *MemDocument)

func WithAuthor

func WithAuthor(name string) DocumentOptionFunc

func WithCreator

func WithCreator(name string) DocumentOptionFunc

func WithKeyword

func WithKeyword(keywords ...string) DocumentOptionFunc

func WithSubjects

func WithSubjects(subj string) DocumentOptionFunc

func WithTitle

func WithTitle(title string) DocumentOptionFunc

type EncodingMapType

type EncodingMapType uint8
const (
	// PDFEncodingMapTypeIndeterminate is for
	// indeterminate map type, such as identity
	// encodings.
	EncodingMapTypeIndeterminate EncodingMapType = iota
	// PDFEncodingMapTypeSimple is for a legacy
	// encoding, such as built-in or difference.
	EncodingMapTypeSimple
	// PDFEncodingMapTypeCMap is for proper
	// CMap encoding or pre-defined CMap names.
	EncodingMapTypeCMap
)

type Encrypt

type Encrypt struct{}

func EncryptFromObject

func EncryptFromObject(obj Object) (*Encrypt, error)

func (*Encrypt) Authenticate

func (enc *Encrypt) Authenticate(password string, objectID *String) bool

type ExportFormat

type ExportFormat uint8
const (
	ExportFormatPNG  ExportFormat = 1
	ExportFormatJPEG ExportFormat = 2
)

type FieldFlag

type FieldFlag uint8
const (
	FieldFlagReadOnly FieldFlag = 1
	FieldFlagRequired FieldFlag = 2
	FieldFlagNoExport FieldFlag = 4
)

type FieldType

type FieldType uint32
const (
	FieldTypeUnknown FieldType = iota
	FieldTypePushButton
	FieldTypeCheckBox
	FieldTypeRadioButton
	FieldTypeTextBox
	FieldTypeComboBox
	FieldTypeListBox
	FieldTypeSignature
)

type FilterType

type FilterType uint8
const (
	FilterTypeNone FilterType = iota
	FilterTypeASCIIHexDecode
	FilterTypeASCII85Decode
	FilterTypeLZWDecode
	FilterTypeFlateDecode
	FilterTypeRunLengthDecode
	FilterTypeCCITTFaxDecode
	FilterTypeJBIG2Decode
	FilterTypeDCTDecode
	FilterTypeJPXDecode
	FilterTypeCrypt
)

type Font

type Font struct{}

func (*Font) Metrics

func (f *Font) Metrics() *Metrics

type FontAutoSelectBehavior

type FontAutoSelectBehavior uint8
const (
	FontAutoSelectBehaviorNone FontAutoSelectBehavior = iota
	FontAutoSelectBehaviorStandard14
	FontAutoSelectBehaviorStandard14Alt
)

type FontCreateFlag

type FontCreateFlag uint8
const (
	FontCreateFlagNone      FontCreateFlag = 0
	FontCreateFlagDontEmbed FontCreateFlag = 1 << (iota - 1)
	FontCreateFlagDontSubset
	FontCreateFlagPreferNonCID
)

type FontDescriptorFlag

type FontDescriptorFlag uint32
const (
	FontDescriptorFlagNone       FontDescriptorFlag = 0
	FontDescriptorFlagFixedPitch FontDescriptorFlag = 1 << (iota - 1)
	FontDescriptorFlagSerif
	FontDescriptorFlagSymbolic
	FontDescriptorFlagScript
	FontDescriptorFlagNonSymbolic FontDescriptorFlag = 1 << iota
	FontDescriptorFlagItalic
	FontDescriptorFlagAllCap FontDescriptorFlag = 1 << (iota + 9)
	FontDescriptorFlagSmallCap
	FontDescriptorFlagForceBold
)

type FontFileType

type FontFileType uint8
const (
	FontFileTypeUnknown FontFileType = iota
	FontFileTypeType1
	FontFileTypeType1CCF
	FontFileTypeCIDType1
	FontFileTypeType3
	FontFileTypeTrueType
	FontFileTypeOpenType
)

type FontMatchBehaviorFlag

type FontMatchBehaviorFlag uint8
const (
	FontMatchBehaviorFlagNone                FontMatchBehaviorFlag = 0
	FontMatchBehaviorFlagNormalizePattern    FontMatchBehaviorFlag = 1
	FontMatchBehaviorFlagMatchPostScriptName FontMatchBehaviorFlag = 2
)

type FontStretch

type FontStretch uint8
const (
	FontStretchUnknown FontStretch = iota
	FontStretchUltraCondensed
	FontStretchExtraCondensed
	FontStretchCondensed
	FontStretchSemiCondensed
	FontStretchNormal
	FontStretchSemiExpanded
	FontStretchExpanded
	FontStretchExtraExpanded
	FontStretchUltraExpanded
)

type FontStyle

type FontStyle uint8
const (
	FontStyleRegular FontStyle = iota
	FontStyleItalic
	FontStyleBold
)

type FontType

type FontType uint8
const (
	FontTypeUnknown FontType = iota
	FontTypeType1
	FontTypeType3
	FontTypeTrueType
	FontTypeCIDType1
	FontTypeCIDTrueType
)

type Generation

type Generation = pdf.Generation

type GlyphAccess

type GlyphAccess uint8
const (
	GlyphAccessWidth       GlyphAccess = 1
	GlyphAccessFontProgram GlyphAccess = 2
)

type HighlightingMode

type HighlightingMode uint8
const (
	HighlightingModeUnknown HighlightingMode = iota
	HighlightingModeNone
	HighlightingModeInvert
	HighlightingModeInvertOutline
	HighlightingModePush
)

type HorizontalAlignment

type HorizontalAlignment uint8
const (
	HorizontalAlignmentLeft HorizontalAlignment = iota
	HorizontalAlignmentCenter
	HorizontalAlignmentRight
)

type IndirectObjectList

type IndirectObjectList struct{}

func (*IndirectObjectList) AddFreeObject

func (list *IndirectObjectList) AddFreeObject(obj Object)

func (*IndirectObjectList) AddObjectStream

func (list *IndirectObjectList) AddObjectStream(objNum int)

func (*IndirectObjectList) Document

func (list *IndirectObjectList) Document() *Document

func (*IndirectObjectList) PushObject

func (list *IndirectObjectList) PushObject(obj Object)

func (*IndirectObjectList) SafeAddFreeObject

func (list *IndirectObjectList) SafeAddFreeObject(obj Object)

type InfoInitial

type InfoInitial uint8
const (
	InfoInitialNone InfoInitial = iota
	InfoInitialWriteCreationTime
	InfoInitialWriteModificationTime
	InfoInitialWriteProducer
)

type LineCapStyle

type LineCapStyle uint8
const (
	LineCapStyleButt LineCapStyle = iota
	LineCapStyleRound
	LineCapStyleSquare
)

type LineJoinStyle

type LineJoinStyle uint8
const (
	LineJoinStyleMiter LineJoinStyle = iota
	LineJoinStyleRound
	LineJoinStyleBevel
)

type Matrix2D

type Matrix2D [6]float64

Matrix2D.

NOTE: This may change if the future.

type MemDocument

type MemDocument struct {
	Metadata Metadata
	// contains filtered or unexported fields
}

func NewMemDocument

func NewMemDocument(options ...DocumentOptionFunc) *MemDocument

func (*MemDocument) AddPage

func (doc *MemDocument) AddPage(size PageSize) *Page

func (*MemDocument) FindFont

func (doc *MemDocument) FindFont(name string) *Font

func (*MemDocument) SaveToFile

func (doc *MemDocument) SaveToFile(filename string) error

type Metadata

type Metadata struct {
	Author   string
	Creator  string
	Title    string
	Subject  string
	Keywords []string
}

type Metrics

type Metrics struct{}

func (*Metrics) FaceIndex

func (m *Metrics) FaceIndex() string

func (*Metrics) FilePath

func (m *Metrics) FilePath() string

func (*Metrics) FontFamilyName

func (m *Metrics) FontFamilyName() string

func (*Metrics) FontName

func (m *Metrics) FontName() string

type Null

type Null struct{}

func (Null) Kind

func (null Null) Kind() ObjectKind

func (Null) WriteTo

func (null Null) WriteTo(w io.Writer) (n int64, err error)

type Number

type Number string

func (Number) Kind

func (num Number) Kind() ObjectKind

func (Number) WriteTo

func (num Number) WriteTo(w io.Writer) (n int64, err error)

type Object

type Object = pdf.Object

type ObjectKind

type ObjectKind = pdf.ObjectKind

type Operator

type Operator uint8
const (
	OperatorUnknown Operator = iota
	// ISO 32008-1:2008 Table 51 – Operator Categories
	// General graphics state
	Operatorw
	OperatorJ
	Operatorj
	OperatorM
	Operatord
	Operatorri
	Operatori
	Operatorgs
	// Special graphics state
	Operatorq
	OperatorQ
	Operatorcm
	// Path construction
	Operatorm
	Operatorl
	Operatorc
	Operatorv
	Operatory
	Operatorh
	Operatorre
	// Path painting
	OperatorS
	Operators
	Operatorf
	OperatorF
	OperatorfStar
	OperatorB
	OperatorBStar
	Operatorb
	OperatorbStar
	Operatorn
	// Clipping paths
	OperatorW
	OperatorWStar
	// Text objects
	OperatorBT
	OperatorET
	// Text state
	OperatorTc
	OperatorTw
	OperatorTz
	OperatorTL
	OperatorTf
	OperatorTr
	OperatorTs
	// Text positioning
	OperatorTd
	OperatorTD
	OperatorTm
	OperatorTStar
	// Text showing
	OperatorTj
	OperatorTJ
	OperatorQuote
	OperatorDoubleQuote
	// Type 3 fonts
	Operatord0
	Operatord1
	// Color
	OperatorCS
	Operatorcs
	OperatorSC
	OperatorSCN
	Operatorsc
	Operatorscn
	OperatorG
	Operatorg
	OperatorRG
	Operatorrg
	OperatorK
	Operatork
	// Shading patterns
	Operatorsh
	// Inline images
	OperatorBI
	OperatorID
	OperatorEI
	// XObjects
	OperatorDo
	// Marked content
	OperatorMP
	OperatorDP
	OperatorBMC
	OperatorBDC
	OperatorEMC
	// Compatibility
	OperatorBX
	OperatorEX
)

type PDFALevel

type PDFALevel uint8
const (
	PDFALevelUnknown PDFALevel = iota
	PDFALevel1B
	PDFALevel1A
	PDFALevel2B
	PDFALevel2A
	PDFALevel2U
	PDFALevel3B
	PDFALevel3A
	PDFALevel3U
	PDFALevel4E
	PDFALevel4F
)

type PDFVersion

type PDFVersion = pdf.Version

type Page

type Page struct {
	// contains filtered or unexported fields
}

func (*Page) Document

func (page *Page) Document() *Document

func (*Page) Object

func (page *Page) Object() Object

func (*Page) Rect

func (page *Page) Rect() Rect

type PageSize

type PageSize = pdf.PageSize

func PageSizeA0

func PageSizeA0() PageSize

func PageSizeA1

func PageSizeA1() PageSize

func PageSizeA2

func PageSizeA2() PageSize

func PageSizeA3

func PageSizeA3() PageSize

func PageSizeA4

func PageSizeA4() PageSize

func PageSizeA5

func PageSizeA5() PageSize

func PageSizeA6

func PageSizeA6() PageSize

func PageSizeLegal

func PageSizeLegal() PageSize

func PageSizeLetter

func PageSizeLetter() PageSize

func PageSizeTabloid

func PageSizeTabloid() PageSize

type Pages

type Pages struct{}

func (*Pages) Add

func (pg *Pages) Add(size PageSize) *Page

func (*Pages) Count

func (pg *Pages) Count() int

func (*Pages) Index

func (pg *Pages) Index(index int) *Page

type Painter

type Painter struct {
	// contains filtered or unexported fields
}

func NewPainter

func NewPainter(flags ...PainterFlag) *Painter

func (*Painter) Close

func (p *Painter) Close() error

func (*Painter) DrawText

func (p *Painter) DrawText(text string, x float64, y float64, style ...TextStyle) error

func (*Painter) FinishDrawing

func (p *Painter) FinishDrawing() error

func (*Painter) SetCanvas

func (p *Painter) SetCanvas(canvas CanvasObject)

type PainterFlag

type PainterFlag func(*painterFlag)

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser reads a PDF file into memory. The file can be modifierd and written back using Writer. Most PDF features are supported.

func Parse

func Parse(
	r Reader, options ...ParserOption,
) (*Parser, error)

Parse opens a PDF file and parses it.

If loadOnDemand is true all objects will be read from the file at the time they are accessed first. If false all the objects will be read immidiately. This is faster if you do not need the complete PDF file in memory.

func (*Parser) FileSize

func (p *Parser) FileSize() int64

FileSize returns the length of the file in bytes.

func (*Parser) GetEncrypt

func (p *Parser) GetEncrypt() *Encrypt

GetEncrypt gives the encryption object from the parser.

func (*Parser) HasXRefStream

func (p *Parser) HasXRefStream() bool

HasXRefStream returns true if the file has XRef stream.

func (*Parser) IsEncrypted

func (p *Parser) IsEncrypted() bool

IsEncrypted returns true if the PDF file is encrypted.

func (*Parser) IsStrictParsing

func (p *Parser) IsStrictParsing() bool

IsStrictParsing returns true if strict parsing mode is enabled.

func (*Parser) LoadOnDemand

func (p *Parser) LoadOnDemand() bool

LoadOnDemand returns true if the LoadOnDemand option was applied for Parser.

func (*Parser) NumIncrementalUpdates

func (p *Parser) NumIncrementalUpdates() int

NumIncrementalUpdates returns the number of incremental updates that have been applied to the last parsed PDF file.

The function returs 0 if there is no updade has been applied.

func (*Parser) Objects

func (p *Parser) Objects() *IndirectObjectList

Objects returns a reference to the sorted internal objects list.

func (*Parser) PDFVersion

func (p *Parser) PDFVersion() PDFVersion

PDFVersion returns the file format version of the PDF.

func (*Parser) Password

func (p *Parser) Password() string

Password retuns the PDF file password.

func (*Parser) TakeEncrypt

func (p *Parser) TakeEncrypt() *Encrypt

TakeEncrypt gives the encryption object from the parser. The internal handle will be set to nil and the ownership of the object is given to the caller.

Only call this if yout need access to the encryption object.

func (*Parser) Trailer

func (p *Parser) Trailer() Object

Trailer returns the trailer object of the PDF file.

func (*Parser) XRefOffset

func (p *Parser) XRefOffset() int64

XRefOffset returns the offset to the XRef stream.

type ParserObject

type ParserObject struct {
	*Dictionary
	Encrypt Encrypt
}

func NewParserObject

func NewParserObject(r Reader, offset int64, options ...ParserObjectOption) (*ParserObject, error)

func (*ParserObject) Parse

func (obj *ParserObject) Parse() error

type ParserObjectOption

type ParserObjectOption func(*ParserObject)

func DelayedLoad

func DelayedLoad(delayed bool) ParserObjectOption

func WithDocument

func WithDocument(doc *Document) ParserObjectOption

func WithReference

func WithReference(ref *Reference) ParserObjectOption

type ParserOption

type ParserOption func(*Parser)

ParserOption is used for PDF file Parser.

func DontIgnoreBrokenObjects

func DontIgnoreBrokenObjects() ParserOption

DontIgnoreBrokenObjects tells the parser to not ignore broken object, i.e. XRef entries that do not point to valid objects.

func LoadOnDemand

func LoadOnDemand() ParserOption

LoadOnDemand tells Parser to read object at the time they are accessed first.

This is faster if you do not need the complete PDF file in memory.

func Password

func Password(password string) ParserOption

Password sets the PDF file password.

func StrictMode

func StrictMode() ParserOption

StrictMode enables strict parsing mode.

If you enable strict parsing, Parse will fail on a few more common PDF failuers. Please note that Parser is by default very strict already and does not recover from e.g. wrong XREF tables.

type PixelFormat

type PixelFormat uint8
const (
	PixelFormatUnknown PixelFormat = 0
	PixelFormatGrayscale
	PixelFormatRGB24
	PixelFormatBGR24
	PixelFormatRGBA
	PixelFormatBGRA
	PixelFormatARGB
	PixelFormatABGR
)

type RawData

type RawData struct{}

func (*RawData) Kind

func (data *RawData) Kind() ObjectKind

func (*RawData) WriteTo

func (data *RawData) WriteTo(w io.Writer) (n int64, err error)

type Reader

type Reader interface {
	io.ReadSeeker
}

type Rect

type Rect = pdf.Rect

type Reference

type Reference = pdf.Reference

type RenderingIntent

type RenderingIntent uint8
const (
	RenderingIntentAbsoluteColorimetric RenderingIntent = iota
	RenderingIntentRelativeColorimetric
	RenderingIntentPerceptual
	RenderingIntentSaturation
)

type SaveOption

type SaveOption uint8
const (
	SaveOptionNone      SaveOption = 0
	SaveOptionReserved1 SaveOption = 1 << (iota - 1)
	SaveOptionReserved2
	SaveOptionNoFlateCompress
	SaveOptionNoCollectGarbage
	SaveOptionNoModifyDateUpdate
	SaveOptionClean
)

type Standard14FontType

type Standard14FontType uint8
const (
	Standart14FontTypeUnknown Standard14FontType = iota
	Standart14FontTypeTimesRoman
	Standart14FontTypeTimesItalic
	Standart14FontTypeTimesBold
	Standart14FontTypeTimesBoldItalic
	Standart14FontTypeHelvetica
	Standart14FontTypeHelveticaOblique
	Standart14FontTypeHelveticaBold
	Standart14FontTypeHelveticaBoldOblique
	Standart14FontTypeCourier
	Standart14FontTypeCourierOblique
	Standart14FontTypeCourierBold
	Standart14FontTypeCourierBoldOblique
	Standart14FontTypeSymbol
	Standart14FontTypeZapfDingbats
)

type String

type String struct {
	pdf.BaseObject
	// contains filtered or unexported fields
}

func (*String) Copy

func (s *String) Copy() (Object, error)

func (*String) IsHex

func (s *String) IsHex() bool

func (*String) IsZero

func (s *String) IsZero() bool

func (*String) Kind

func (s *String) Kind() ObjectKind

func (*String) MarshalPDF

func (s *String) MarshalPDF(w *pdf.Writer) error

func (*String) RawData

func (s *String) RawData() []byte

func (*String) State

func (s *String) State() StringState

func (*String) String

func (s *String) String() string

func (*String) UnmarshalBinary

func (s *String) UnmarshalBinary(data []byte) error

type StringEncoding

type StringEncoding uint8
const (
	StringEncodingUTF8 StringEncoding = iota
	StringEncodingUTF16BE
	StringEncodingUTF16LE
	StringEncodingPDFDoc
)

type StringState

type StringState uint8
const (
	// StringStateRawBuffer is for an unvaluated
	// raw buffer string.
	StringStateRawBuffer StringState = iota
	// StringStateASCII is for both an ASCII
	// and PDFDocEncoding charsets.
	StringStateASCII
	// StringStateDocEncoding is for strings
	// that use the whole PDFDocEncoding charset.
	StringStateDocEncoding
	// StringStateUnicode is for strings that
	// use the whole Unicode charset.
	StringStateUnicode
)

type StrokeStyle

type StrokeStyle uint8
const (
	StrokeStyleSolid StrokeStyle = iota
	StrokeStyleDash
	StrokeStyleDot
	StrokeStyleDashDot
	StrokeStyleDashDotDot
)

type TextExtractFlags

type TextExtractFlags uint8
const (
	TextExtractFlagNone       TextExtractFlags = 0
	TextExtractFlagIgnoreCase TextExtractFlags = 1 << (iota - 1)
	TextExtractFlagKeepWhiteTokens
	TextExtractFlagTokenizeWords
	TextExtractFlagMatchWholeWord
	TextExtractFlagRegexPattern
	TextExtractFlagComputeBoundingBox
	TextExtractFlagRawCoordinates
	TextExtractFlagExtractSubstring
)

type TextRenderingMode

type TextRenderingMode uint8
const (
	TextRenderingModeFill TextRenderingMode = 0
	TextRenderingModeStroke
	TextRenderingModeFillStroke
	TextRenderingModeInvisible
	TextRenderingModeFillAddToClipPath
	TextRenderingModeStrokeAddToClipPath
	TextRenderingModeFillStrokeAddToClipPath
	TextRenderingModeAddToClipPath
)

type TextStyle

type TextStyle struct{}

type Tokenizer

type Tokenizer struct {
	// contains filtered or unexported fields
}

func NewTokenizer

func NewTokenizer() *Tokenizer

func (*Tokenizer) ReadNextNumber

func (tok *Tokenizer) ReadNextNumber(r Reader) (number int64, err error)

func (*Tokenizer) TryReadNextToken

func (tok *Tokenizer) TryReadNextToken(r Reader) (token []byte, err error)

type VerticalAlignment

type VerticalAlignment uint8
const (
	VerticalAligmentTop VerticalAlignment = iota
	VerticalAligmentCenter
	VerticalAligmentBottom
)

type Writer

type Writer struct{}

type XObjectType

type XObjectType uint8
const (
	XObjectTypeUnknown XObjectType = iota
	XObjectTypeForm
	XObjectTypeImage
	XObjectTypePostScript
)

type XRefEntry

type XRefEntry struct {
	Entry  xrefEntry
	Parsed bool
}

type XRefEntryCompressed

type XRefEntryCompressed struct {
	ObjectNumber int
	Index        int64
}

type XRefEntryFree

type XRefEntryFree struct {
	ObjectNumber int
	Generation   Generation
}

type XRefEntryInUse

type XRefEntryInUse struct {
	Offset     int64
	Generation Generation
}

type XRefStreamParser

type XRefStreamParser struct {
	Object
}

func NewXRefStreamParser

func NewXRefStreamParser(doc *Document, r Reader, entries *[]XRefEntry) (*XRefStreamParser, error)

func (*XRefStreamParser) ParseStream

func (parser *XRefStreamParser) ParseStream() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL