Versions in this module Expand all Collapse all v0 v0.1.14 Jun 9, 2018 Changes in this version + const CalGrayCS + const CalRGBCS + const DeviceCMYKCS + const DeviceGrayCS + const DeviceNCS + const DeviceRGBCS + const ICCBasedCS + const IndexedCS + const LabCS + const PatternCS + const SeparationCS + var ErrUnsupportedBPC = errors.New("unsupported bitsPerComponent") + var ErrUnsupportedColorSpace = errors.New("unsupported color space") + func WritePNGFile(ctx *PDFContext, fileName string, objNr int, io *ImageObject) error v0.1.13 May 26, 2018 v0.1.12 May 22, 2018 Changes in this version + const EolCR + const EolCRLF + const EolLF + const ExcludePatternCS + const FreeHeadGeneration + const IncludePatternCS + const OPTIONAL + const ObjectStreamMaxObjects + const PDFCPULongVersion + const PDFCPUVersion + const PageAA + const PageAnnots + const PageArtBox + const PageB + const PageBleedBox + const PageBoxColorInfo + const PageContents + const PageCropBox + const PageDur + const PageGroup + const PageID + const PageLastModified + const PageMediaBox + const PageMetadata + const PagePZ + const PagePieceInfo + const PagePresSteps + const PageResources + const PageRotate + const PageSeparationInfo + const PageStructParents + const PageTabs + const PageTemplateInstantiated + const PageThumb + const PageTrans + const PageTrimBox + const PageUserUnit + const PageVP + const PermissionsAll + const PermissionsNone + const REQUIRED + const RootAA + const RootAcroForm + const RootCollection + const RootDests + const RootExtensions + const RootLang + const RootLegal + const RootMarkInfo + const RootMetadata + const RootNames + const RootNeedsRendering + const RootOCProperties + const RootOpenAction + const RootOutlines + const RootOutputIntents + const RootPageLabels + const RootPageLayout + const RootPageMode + const RootPerms + const RootPieceInfo + const RootRequirements + const RootSpiderInfo + const RootStructTreeRoot + const RootThreads + const RootURI + const RootVersion + const RootViewerPrefs + const StatsFileNameDefault + const ValidationRelaxed + const ValidationStrict + func AppendStatsFile(ctx *PDFContext) error + func AttachAdd(xRefTable *XRefTable, files StringSet) (ok bool, err error) + func AttachExtract(ctx *PDFContext, files StringSet) (err error) + func AttachList(xRefTable *XRefTable) (list []string, err error) + func AttachRemove(xRefTable *XRefTable, files StringSet) (ok bool, err error) + func CreateDemoPDF(xRefTable *XRefTable, dirName, fileName string) error + func Date(s string) bool + func DecodeUTF16String(s string) (string, error) + func Escape(s string) (*string, error) + func ExtractContentData(ctx *PDFContext, objNr int) (data []byte, err error) + func HexLiteralToString(hexString string) (string, error) + func IsStringUTF16BE(s string) bool + func IsUTF16BE(b []byte) (ok bool, err error) + func MergeXRefTables(ctxSource, ctxDest *PDFContext) (err error) + func OptimizeXRefTable(ctx *PDFContext) error + func Permissions(ctx *PDFContext) (list []string) + func StringLiteralToString(s string) (string, error) + func Unescape(s string) ([]byte, error) + func ValidateXRefTable(xRefTable *XRefTable) error + func VersionString(version PDFVersion) string + func WritePDFFile(ctx *PDFContext) error + type ByteSize float64 + const GB + const KB + const MB + func (b ByteSize) String() string + type CommandMode int + const ADDATTACHMENTS + const ADDPERMISSIONS + const CHANGEOPW + const CHANGEUPW + const DECRYPT + const ENCRYPT + const EXTRACTATTACHMENTS + const EXTRACTCONTENT + const EXTRACTFONTS + const EXTRACTIMAGES + const EXTRACTPAGES + const LISTATTACHMENTS + const LISTPERMISSIONS + const MERGE + const OPTIMIZE + const REMOVEATTACHMENTS + const SPLIT + const TRIM + const VALIDATE + type Configuration struct + CollectStats bool + DecodeAllStreams bool + EncryptUsing128BitKey bool + EncryptUsingAES bool + Eol string + Mode CommandMode + OwnerPW string + OwnerPWNew *string + Reader15 bool + StatsFileName string + UserAccessPermissions int16 + UserPW string + UserPWNew *string + ValidationMode int + WriteObjectStream bool + WriteXRefStream bool + func NewDefaultConfiguration() *Configuration + func (c *Configuration) ValidationModeString() string + type Enc struct + Emd bool + ID []byte + L int + O []byte + P int + R int + U []byte + V int + type FontObject struct + Data []byte + Extension string + FontDict *PDFDict + FontName string + Prefix string + ResourceNames []string + func ExtractFontData(ctx *PDFContext, objNr int) (*FontObject, error) + func (fo *FontObject) AddResourceName(resourceName string) + func (fo FontObject) Embedded() (embedded bool) + func (fo FontObject) Encoding() string + func (fo FontObject) ResourceNamesString() string + func (fo FontObject) String() string + func (fo FontObject) SubType() string + type ImageObject struct + Extension string + ImageDict *PDFStreamDict + ResourceNames []string + func ExtractImageData(ctx *PDFContext, objNr int) (*ImageObject, error) + func (io *ImageObject) AddResourceName(resourceName string) + func (io ImageObject) Data() []byte + func (io ImageObject) ResourceNamesString() string + type IntSet map[int]bool + type Node struct + IndRef *PDFIndirectRef + Kids []*Node + Kmax string + Kmin string + Names []entry + func (n *Node) Add(xRefTable *XRefTable, k string, v PDFObject) error + func (n *Node) AddToLeaf(k string, v PDFObject) + func (n *Node) Remove(xRefTable *XRefTable, k string) (empty, ok bool, err error) + func (n Node) KeyList() ([]string, error) + func (n Node) Process(xRefTable *XRefTable, handler func(*XRefTable, string, PDFObject) error) error + func (n Node) String() string + func (n Node) Value(k string) (PDFObject, bool) + type OptimizationContext struct + DuplicateFontObjs IntSet + DuplicateFonts map[int]*PDFDict + DuplicateImageObjs IntSet + DuplicateImages map[int]*PDFStreamDict + DuplicateInfoObjects IntSet + FontObjects map[int]*FontObject + Fonts map[string][]int + ImageObjects map[int]*ImageObject + NonReferencedObjs []int + PageFonts []IntSet + PageImages []IntSet + func (oc *OptimizationContext) DuplicateFontObjectsString() (int, string) + func (oc *OptimizationContext) DuplicateImageObjectsString() (int, string) + func (oc *OptimizationContext) DuplicateInfoObjectsString() (int, string) + func (oc *OptimizationContext) IsDuplicateFontObject(i int) bool + func (oc *OptimizationContext) IsDuplicateImageObject(i int) bool + func (oc *OptimizationContext) IsDuplicateInfoObject(i int) bool + func (oc *OptimizationContext) NonReferencedObjsString() (int, string) + type PDFArray []PDFObject + func NewIntegerArray(fVars ...int) PDFArray + func NewNameArray(sVars ...string) PDFArray + func NewNumberArray(fVars ...float64) PDFArray + func NewRectangle(llx, lly, urx, ury float64) PDFArray + func NewStringArray(sVars ...string) PDFArray + func (array PDFArray) PDFString() string + func (array PDFArray) String() string + type PDFBoolean bool + func (boolean PDFBoolean) PDFString() string + func (boolean PDFBoolean) String() string + func (boolean PDFBoolean) Value() bool + type PDFContext struct + Optimize *OptimizationContext + Read *ReadContext + Write *WriteContext + func NewPDFContext(fileName string, file *os.File, config *Configuration) (*PDFContext, error) + func ReadPDFFile(fileName string, config *Configuration) (*PDFContext, error) + func (ctx *PDFContext) ResetWriteContext() + func (ctx *PDFContext) String() string + type PDFDict struct + Dict map[string]PDFObject + func NewPDFDict() PDFDict + func (d *PDFDict) Delete(key string) (value PDFObject) + func (d *PDFDict) Entry(dictName, key string, required bool) (PDFObject, error) + func (d *PDFDict) Insert(key string, value PDFObject) (ok bool) + func (d *PDFDict) InsertFloat(key string, value float32) + func (d *PDFDict) InsertInt(key string, value int) + func (d *PDFDict) InsertName(key, value string) + func (d *PDFDict) InsertString(key, value string) + func (d *PDFDict) Len() int + func (d *PDFDict) Update(key string, value PDFObject) + func (d PDFDict) BooleanEntry(key string) *bool + func (d PDFDict) Find(key string) (value PDFObject, found bool) + func (d PDFDict) First() *int + func (d PDFDict) Index() *PDFArray + func (d PDFDict) IndirectRefEntry(key string) *PDFIndirectRef + func (d PDFDict) Int64Entry(key string) *int64 + func (d PDFDict) IntEntry(key string) *int + func (d PDFDict) IsLinearizationParmDict() bool + func (d PDFDict) IsObjStm() bool + func (d PDFDict) Length() (*int64, *int) + func (d PDFDict) N() *int + func (d PDFDict) NameEntry(key string) *string + func (d PDFDict) PDFArrayEntry(key string) *PDFArray + func (d PDFDict) PDFDictEntry(key string) *PDFDict + func (d PDFDict) PDFHexLiteralEntry(key string) *PDFHexLiteral + func (d PDFDict) PDFNameEntry(key string) *PDFName + func (d PDFDict) PDFStreamDictEntry(key string) *PDFStreamDict + func (d PDFDict) PDFString() string + func (d PDFDict) PDFStringLiteralEntry(key string) *PDFStringLiteral + func (d PDFDict) Prev() *int64 + func (d PDFDict) Size() *int + func (d PDFDict) String() string + func (d PDFDict) StringEntry(key string) *string + func (d PDFDict) StringEntryBytes(key string) ([]byte, error) + func (d PDFDict) Subtype() *string + func (d PDFDict) Type() *string + func (d PDFDict) W() *PDFArray + type PDFFilter struct + DecodeParms *PDFDict + Name string + type PDFFloat float64 + func (f PDFFloat) PDFString() string + func (f PDFFloat) String() string + func (f PDFFloat) Value() float64 + type PDFHexLiteral string + func (hexliteral PDFHexLiteral) Bytes() ([]byte, error) + func (hexliteral PDFHexLiteral) PDFString() string + func (hexliteral PDFHexLiteral) String() string + func (hexliteral PDFHexLiteral) Value() string + type PDFIndirectRef struct + GenerationNumber PDFInteger + ObjectNumber PDFInteger + func NewPDFIndirectRef(objectNumber, generationNumber int) *PDFIndirectRef + func (ir PDFIndirectRef) Equals(indRef PDFIndirectRef) bool + func (ir PDFIndirectRef) PDFString() string + func (ir PDFIndirectRef) String() string + type PDFInteger int + func (i PDFInteger) PDFString() string + func (i PDFInteger) String() string + func (i PDFInteger) Value() int + type PDFName string + func (nameObject PDFName) PDFString() string + func (nameObject PDFName) String() string + func (nameObject PDFName) Value() string + type PDFObject interface + PDFString func() string + type PDFObjectStreamDict struct + FirstObjOffset int + ObjArray PDFArray + ObjCount int + Prolog []byte + func NewPDFObjectStreamDict() *PDFObjectStreamDict + func (oStreamDict *PDFObjectStreamDict) AddObject(objNumber int, entry *XRefTableEntry) error + func (oStreamDict *PDFObjectStreamDict) Finalize() + func (oStreamDict *PDFObjectStreamDict) IndexedObject(index int) (PDFObject, error) + type PDFStats struct + func NewPDFStats() PDFStats + func (stats PDFStats) AddPageAttr(name int) + func (stats PDFStats) AddRootAttr(name int) + func (stats PDFStats) UsesPageAttr(name int) bool + func (stats PDFStats) UsesRootAttr(name int) bool + type PDFStreamDict struct + Content []byte + FilterPipeline []PDFFilter + IsPageContent bool + Raw []byte + StreamLength *int64 + StreamLengthObjNr *int + StreamOffset int64 + func NewPDFStreamDict(pdfDict PDFDict, streamOffset int64, streamLength *int64, ...) PDFStreamDict + func (streamDict PDFStreamDict) HasSoleFilterNamed(filterName string) bool + type PDFStringLiteral string + func DateStringLiteral(t time.Time) PDFStringLiteral + func (stringliteral PDFStringLiteral) PDFString() string + func (stringliteral PDFStringLiteral) String() string + func (stringliteral PDFStringLiteral) Value() string + type PDFVersion int + const V10 + const V11 + const V12 + const V13 + const V14 + const V15 + const V16 + const V17 + func Version(versionStr string) (PDFVersion, error) + type PDFXRefStreamDict struct + Objects []int + PreviousOffset *int64 + Size int + W [3]int + func NewPDFXRefStreamDict(ctx *PDFContext) *PDFXRefStreamDict + type ReadContext struct + BinaryFontDuplSize int64 + BinaryFontSize int64 + BinaryImageDuplSize int64 + BinaryImageSize int64 + BinaryTotalSize int64 + File *os.File + FileName string + FileSize int64 + Hybrid bool + Linearized bool + ObjectStreams IntSet + UsingObjectStreams bool + UsingXRefStreams bool + XRefStreams IntSet + func (rc *ReadContext) IsObjectStreamObject(i int) bool + func (rc *ReadContext) IsXRefStreamObject(i int) bool + func (rc *ReadContext) LogStats(optimized bool) + func (rc *ReadContext) ObjectStreamsString() (int, string) + func (rc *ReadContext) XRefStreamsString() (int, string) + type StringSet map[string]bool + type WriteContext struct + BinaryFontSize int64 + BinaryImageSize int64 + BinaryTotalSize int64 + Command string + CurrentObjStream *int + DirName string + Eol string + ExtractPageNr int + ExtractPages IntSet + FileName string + FileSize int64 + Offset int64 + Table map[int]int64 + WriteToObjectStream bool + func NewWriteContext(eol string) *WriteContext + func (wc *WriteContext) ExtractPage(i int) bool + func (wc *WriteContext) HasWriteOffset(objNumber int) bool + func (wc *WriteContext) LogStats() + func (wc *WriteContext) ReducedFeatureSet() bool + func (wc *WriteContext) SetWriteOffset(objNumber int) + func (wc *WriteContext) WriteEol() error + type XRefTable struct + AES4EmbeddedStreams bool + AES4Streams bool + AES4Strings bool + AdditionalStreams *PDFArray + Author string + Creator string + E *Enc + EncKey []byte + Encrypt *PDFIndirectRef + HeaderVersion *PDFVersion + ID *PDFArray + Info *PDFIndirectRef + LinearizationObjs IntSet + Names map[string]*Node + OffsetOverflowHintTable *int64 + OffsetPrimaryHintTable *int64 + Optimized bool + PageCount int + Producer string + Root *PDFIndirectRef + RootDict *PDFDict + RootVersion *PDFVersion + Size *int + Stats PDFStats + Table map[int]*XRefTableEntry + Tagged bool + Valid bool + ValidationMode int + func CreateAcroFormDemoXRef() (*XRefTable, error) + func CreateAnnotationDemoXRef() (*XRefTable, error) + func (xRefTable *XRefTable) BindNameTrees() error + func (xRefTable *XRefTable) Catalog() (*PDFDict, error) + func (xRefTable *XRefTable) CatalogHasPieceInfo() (bool, error) + func (xRefTable *XRefTable) DeleteObject(objectNumber int) error + func (xRefTable *XRefTable) DeleteObjectGraph(obj PDFObject) error + func (xRefTable *XRefTable) Dereference(obj PDFObject) (PDFObject, error) + func (xRefTable *XRefTable) DereferenceArray(obj PDFObject) (*PDFArray, error) + func (xRefTable *XRefTable) DereferenceDict(obj PDFObject) (*PDFDict, error) + func (xRefTable *XRefTable) DereferenceInteger(obj PDFObject) (*PDFInteger, error) + func (xRefTable *XRefTable) DereferenceName(obj PDFObject, sinceVersion PDFVersion, validate func(string) bool) (n PDFName, err error) + func (xRefTable *XRefTable) DereferenceStreamDict(obj PDFObject) (*PDFStreamDict, error) + func (xRefTable *XRefTable) DereferenceStringLiteral(obj PDFObject, sinceVersion PDFVersion, validate func(string) bool) (s PDFStringLiteral, err error) + func (xRefTable *XRefTable) DereferenceStringOrHexLiteral(obj PDFObject, sinceVersion PDFVersion, validate func(string) bool) (o PDFObject, err error) + func (xRefTable *XRefTable) EncryptDict() (*PDFDict, error) + func (xRefTable *XRefTable) EnsureCollection() error + func (xRefTable *XRefTable) EnsureValidFreeList() error + func (xRefTable *XRefTable) Exists(objNumber int) bool + func (xRefTable *XRefTable) Find(objNumber int) (*XRefTableEntry, bool) + func (xRefTable *XRefTable) FindObject(objNumber int) (PDFObject, error) + func (xRefTable *XRefTable) FindTableEntry(objNumber int, generationNumber int) (*XRefTableEntry, bool) + func (xRefTable *XRefTable) FindTableEntryForIndRef(indRef *PDFIndirectRef) (*XRefTableEntry, bool) + func (xRefTable *XRefTable) FindTableEntryLight(objNumber int) (*XRefTableEntry, bool) + func (xRefTable *XRefTable) Free(objNumber int) (*XRefTableEntry, error) + func (xRefTable *XRefTable) IDFirstElement() (id []byte, err error) + func (xRefTable *XRefTable) IndRefForNewObject(obj PDFObject) (*PDFIndirectRef, error) + func (xRefTable *XRefTable) InsertAndUseRecycled(xRefTableEntry XRefTableEntry) (objNumber int, err error) + func (xRefTable *XRefTable) InsertNew(xRefTableEntry XRefTableEntry) (objNumber int) + func (xRefTable *XRefTable) InsertObject(obj PDFObject) (objNumber int, err error) + func (xRefTable *XRefTable) IsLinearizationObject(i int) bool + func (xRefTable *XRefTable) LinearizationObjsString() (int, string) + func (xRefTable *XRefTable) LocateNameTree(nameTreeName string, ensure bool) error + func (xRefTable *XRefTable) MissingObjects() (int, *string) + func (xRefTable *XRefTable) NamesDict() (*PDFDict, error) + func (xRefTable *XRefTable) NewEmbeddedFileStreamDict(filename string) (*PDFStreamDict, error) + func (xRefTable *XRefTable) NewFileSpecDict(filename string, indRefStreamDict PDFIndirectRef) (*PDFDict, error) + func (xRefTable *XRefTable) NewPDFStreamDict(filename string) (*PDFStreamDict, error) + func (xRefTable *XRefTable) NewSoundStreamDict(filename string, samplingRate int, fileSpecDict *PDFDict) (*PDFStreamDict, error) + func (xRefTable *XRefTable) NextForFree(objNumber int) (int, error) + func (xRefTable *XRefTable) PageDict(page int) (*PDFDict, error) + func (xRefTable *XRefTable) Pages() (*PDFIndirectRef, error) + func (xRefTable *XRefTable) ParseRootVersion() (v *string, err error) + func (xRefTable *XRefTable) RemoveCollection() error + func (xRefTable *XRefTable) RemoveEmbeddedFilesNameTree() error + func (xRefTable *XRefTable) RemoveNameTree(nameTreeName string) error + func (xRefTable *XRefTable) UndeleteObject(objectNumber int) error + func (xRefTable *XRefTable) ValidateVersion(element string, sinceVersion PDFVersion) error + func (xRefTable *XRefTable) Version() PDFVersion + func (xRefTable *XRefTable) VersionString() string + type XRefTableEntry struct + Compressed bool + Free bool + Generation *int + Object PDFObject + ObjectStream *int + ObjectStreamInd *int + Offset *int64 + func NewFreeHeadXRefTableEntry() *XRefTableEntry + func NewXRefTableEntryGen0(obj PDFObject) *XRefTableEntry