Documentation
¶
Overview ¶
Package pdfcpu is a PDF processing library written in Go supporting encryption. It provides an API and a command line interface. Supported are all versions up to PDF 1.7 (ISO-32000).
The commands are:
annotations list, remove page annotations attachments list, add, remove, extract embedded file attachments booklet arrange pages onto larger sheets of paper to make a booklet or zine bookmarks list, import, export, remove bookmarks boxes list, add, remove page boundaries for selected pages changeopw change owner password changeupw change user password collect create custom sequence of selected pages config list, reset configuration create create PDF content including forms via JSON crop set cropbox for selected pages cut custom cut pages horizontally or vertically decrypt remove password protection encrypt set password protection extract extract images, fonts, content, pages or metadata fonts install, list supported fonts, create cheat sheets form list, remove fields, lock, unlock, reset, export, fill form via JSON or CSV grid rearrange pages or images for enhanced browsing experience images list, extract, update images import import/convert images to PDF info print file info keywords list, add, remove keywords merge concatenate PDFs ndown cut selected pages into n pages symmetrically nup rearrange pages or images for reduced number of pages optimize optimize PDF by getting rid of redundant page resources pagelayout list, set, reset page layout for opened document pagemode list, set, reset page mode for opened document pages insert, remove selected pages paper print list of supported paper sizes permissions list, set user access permissions portfolio list, add, remove, extract portfolio entries with optional description poster cut selected pages into poster by paper size or dimensions properties list, add, remove document properties resize scale selected pages rotate rotate selected pages selectedpages print definition of the -pages flag split split up a PDF by span or bookmark stamp add, remove, update Unicode text, image or PDF stamps for selected pages trim create trimmed version of selected pages validate validate PDF against PDF 32000-1:2008 (PDF 1.7) + basic PDF 2.0 validation version print version viewerpref list, set, reset viewer preferences for opened document watermark add, remove, update Unicode text, image or PDF watermarks for selected pages zoom zoom in/out of selected pages by magnification factor or corresponding margin
Index ¶
- Constants
- Variables
- func AddAnnotation(ctx *model.Context, pageDictIndRef *types.IndirectRef, pageDict types.Dict, ...) (*types.IndirectRef, types.Dict, error)
- func AddAnnotationToPage(ctx *model.Context, pageNr int, ar model.AnnotationRenderer, incr bool) (*types.IndirectRef, types.Dict, error)
- func AddAnnotations(ctx *model.Context, selectedPages types.IntSet, ar model.AnnotationRenderer, ...) (bool, error)
- func AddAnnotationsMap(ctx *model.Context, m map[int][]model.AnnotationRenderer, incr bool) (bool, error)
- func AddBookmarks(ctx *model.Context, bms []Bookmark, replace bool) error
- func AddPageTreeWithSamplePage(xRefTable *model.XRefTable, rootDict types.Dict, p model.Page) error
- func AddPages(ctxSrc, ctxDest *model.Context, pageNrs []int, usePgCache bool) error
- func AddWatermarks(ctx *model.Context, selectedPages types.IntSet, wm *model.Watermark) error
- func AddWatermarksMap(ctx *model.Context, m map[int]*model.Watermark) error
- func AddWatermarksSliceMap(ctx *model.Context, m map[int][]*model.Watermark) error
- func Annotation(xRefTable *model.XRefTable, d types.Dict) (model.AnnotationRenderer, error)
- func AnnotationsForSelectedPages(ctx *model.Context, selectedPages types.IntSet) map[int]model.PgAnnots
- func AppendStatsFile(ctx *model.Context) error
- func BookletFromImages(ctx *model.Context, fileNames []string, nup *model.NUp, pagesDict types.Dict, ...) error
- func BookletFromPDF(ctx *model.Context, selectedPages types.IntSet, nup *model.NUp) error
- func BookmarkList(ctx *model.Context) ([]string, error)
- func CacheFormFonts(ctx *model.Context) error
- func CachedAnnotationObjNrs(ctx *model.Context) ([]int, error)
- func ColorSpaceComponents(xRefTable *model.XRefTable, sd *types.StreamDict) (int, error)
- func ColorSpaceString(ctx *model.Context, sd *types.StreamDict) (string, error)
- func CreateAnnotationDemoXRef() (*model.XRefTable, error)
- func CreateContext(xRefTable *model.XRefTable, conf *model.Configuration) *model.Context
- func CreateContextWithXRefTable(conf *model.Configuration, pageDim *types.Dim) (*model.Context, error)
- func CreateDemoXRef() (*model.XRefTable, error)
- func CreateFormDemoXRef() (*model.XRefTable, error)
- func CreateResourceDictInheritanceDemoXRef() (*model.XRefTable, error)
- func CreateTestPageContent(p model.Page)
- func CreateXRefTableWithRootDict() (*model.XRefTable, error)
- func CutPage(ctxSrc *model.Context, i int, cut *model.Cut) (*model.Context, error)
- func DefaultBookletConfig() *model.NUp
- func DetectPageTreeWatermarks(ctx *model.Context) error
- func DetectWatermarks(ctx *model.Context) error
- func EnsureOutlines(ctx *model.Context, fName string, append bool) error
- func ExportBookmarksJSON(ctx *model.Context, source string, w io.Writer) (bool, error)
- func ExtractImage(ctx *model.Context, sd *types.StreamDict, thumb bool, resourceID string, ...) (*model.Image, error)
- func ExtractPageContent(ctx *model.Context, pageNr int) (io.Reader, error)
- func ExtractPageImages(ctx *model.Context, pageNr int, stub bool) (map[int]model.Image, error)
- func ExtractPages(ctx *model.Context, pageNrs []int, usePgCache bool) (*model.Context, error)
- func FontObjNrs(ctx *model.Context, pageNr int) []int
- func GetBookletOrdering(pages types.IntSet, nup *model.NUp) []model.BookletPage
- func ImageBookletConfig(val int, desc string, conf *model.Configuration) (*model.NUp, error)
- func ImageGridConfig(rows, cols int, desc string, conf *model.Configuration) (*model.NUp, error)
- func ImageNUpConfig(val int, desc string, conf *model.Configuration) (*model.NUp, error)
- func ImageObjNrs(ctx *model.Context, pageNr int) []int
- func ImportBookmarks(ctx *model.Context, rd io.Reader, replace bool) (bool, error)
- func KeywordsAdd(ctx *model.Context, keywords []string) error
- func KeywordsList(ctx *model.Context) ([]string, error)
- func KeywordsRemove(ctx *model.Context, keywords []string) (bool, error)
- func ListAnnotations(annots map[int]model.PgAnnots) (int, []string, error)
- func ListImages(ctx *model.Context, selectedPages types.IntSet) ([]string, error)
- func ListInfo(info *PDFInfo, selectedPages types.IntSet) ([]string, error)
- func MergeXRefTables(fName string, ctxSrc, ctxDest *model.Context, zip, dividerPage bool) (err error)
- func NDownPage(ctxSrc *model.Context, i, n int, cut *model.Cut) (*model.Context, error)
- func NUpFromMultipleImages(ctx *model.Context, fileNames []string, nup *model.NUp, pagesDict types.Dict, ...) error
- func NUpFromOneImage(ctx *model.Context, fileName string, nup *model.NUp, pagesDict types.Dict, ...) error
- func NUpFromPDF(ctx *model.Context, selectedPages types.IntSet, nup *model.NUp) error
- func NewNUpPageForImage(xRefTable *model.XRefTable, fileName string, parentIndRef *types.IndirectRef, ...) (*types.IndirectRef, error)
- func NewPageForImage(xRefTable *model.XRefTable, r io.Reader, parentIndRef *types.IndirectRef, ...) (*types.IndirectRef, error)
- func OptimizeXRefTable(ctx *model.Context) error
- func PDFBookletConfig(val int, desc string, conf *model.Configuration) (*model.NUp, error)
- func PDFGridConfig(rows, cols int, desc string, conf *model.Configuration) (*model.NUp, error)
- func PDFNUpConfig(val int, desc string, conf *model.Configuration) (*model.NUp, error)
- func PageObjFromDestination(ctx *model.Context, dest types.Object) (*types.IndirectRef, error)
- func ParseCutConfig(s string, u types.DisplayUnit) (*model.Cut, error)
- func ParseCutConfigForN(n int, s string, u types.DisplayUnit) (*model.Cut, error)
- func ParseCutConfigForPoster(s string, u types.DisplayUnit) (*model.Cut, error)
- func ParseImageWatermarkDetails(fileName, desc string, onTop bool, u types.DisplayUnit) (*model.Watermark, error)
- func ParseNUpDetails(s string, nup *model.NUp) error
- func ParseNUpGridDefinition(rows, cols int, nUp *model.NUp) error
- func ParseNUpValue(n int, nUp *model.NUp) error
- func ParseObject(ctx *model.Context, offset int64, objNr, genNr int) (types.Object, error)
- func ParseObjectWithContext(c context.Context, ctx *model.Context, offset int64, objNr, genNr int) (types.Object, error)
- func ParsePDFWatermarkDetails(fileName, desc string, onTop bool, u types.DisplayUnit) (*model.Watermark, error)
- func ParsePageDim(v string, u types.DisplayUnit) (*types.Dim, string, error)
- func ParseResizeConfig(s string, u types.DisplayUnit) (*model.Resize, error)
- func ParseTextWatermarkDetails(text, desc string, onTop bool, u types.DisplayUnit) (*model.Watermark, error)
- func ParseZoomConfig(s string, u types.DisplayUnit) (*model.Zoom, error)
- func Permissions(ctx *model.Context) (list []string)
- func PermissionsList(p int) (list []string)
- func PosterPage(ctxSrc *model.Context, i int, cut *model.Cut) (*model.Context, error)
- func PropertiesAdd(ctx *model.Context, properties map[string]string) error
- func PropertiesList(ctx *model.Context) ([]string, error)
- func PropertiesRemove(ctx *model.Context, properties []string) (bool, error)
- func Read(rs io.ReadSeeker, conf *model.Configuration) (*model.Context, error)
- func ReadFile(inFile string, conf *model.Configuration) (*model.Context, error)
- func ReadFileWithContext(c context.Context, inFile string, conf *model.Configuration) (*model.Context, error)
- func ReadWithContext(c context.Context, rs io.ReadSeeker, conf *model.Configuration) (*model.Context, error)
- func RemoveAnnotations(ctx *model.Context, selectedPages types.IntSet, idsAndTypes []string, ...) (bool, error)
- func RemoveAnnotationsFromPageDict(ctx *model.Context, annotTypes []model.AnnotationType, ids []string, ...) (bool, error)
- func RemoveBookmarks(ctx *model.Context) (bool, error)
- func RemoveWatermarks(ctx *model.Context, selectedPages types.IntSet) error
- func RenderImage(xRefTable *model.XRefTable, sd *types.StreamDict, thumb bool, ...) (io.Reader, string, error)
- func Resize(ctx *model.Context, selectedPages types.IntSet, res *model.Resize) error
- func RotatePages(ctx *model.Context, selectedPages types.IntSet, rotation int) error
- func StreamLength(ctx *model.Context, sd *types.StreamDict) (int64, error)
- func UpdateImagesByObjNr(ctx *model.Context, rd io.Reader, objNr int) error
- func UpdateImagesByPageNrAndId(ctx *model.Context, rd io.Reader, pageNr int, id string) error
- func Write(ctx *model.Context) (err error)
- func WriteImage(xRefTable *model.XRefTable, fileName string, sd *types.StreamDict, thumb bool, ...) (string, error)
- func WriteImageToDisk(outDir, fileName string) func(model.Image, bool, int) error
- func WriteIncrement(ctx *model.Context) error
- func WriteReader(path string, r io.Reader) error
- func Zoom(ctx *model.Context, selectedPages types.IntSet, zoom *model.Zoom) error
- type AnnotListMaxLengths
- type Bookmark
- type BookmarkTree
- type Font
- type Header
- type ImageListMaxLengths
- type Import
- type Metadata
- type PDFImage
- type PDFInfo
- type PageConfiguration
Constants ¶
const (
// ObjectStreamMaxObjects limits the number of objects within an object stream written.
ObjectStreamMaxObjects = 100
)
Variables ¶
var ( ErrWrongPassword = errors.New("pdfcpu: please provide the correct password") ErrCorruptHeader = errors.New("pdfcpu: no header version available") ErrReferenceDoesNotExist = errors.New("pdfcpu: referenced object does not exist") )
var (
ErrUnknownEncryption = errors.New("pdfcpu: unknown encryption")
)
var (
ErrUnsupported16BPC = errors.New("unsupported 16 bits per component")
)
Errors to be identified.
var (
ErrUnsupportedVersion = errors.New("pdfcpu: PDF 2.0 unsupported for this operation")
)
var (
NUpValues = []int{2, 3, 4, 6, 8, 9, 12, 16}
)
var NUpValuesForBooklets = []int{2, 4, 6, 8}
Functions ¶
func AddAnnotation ¶ added in v0.5.2
func AddAnnotation( ctx *model.Context, pageDictIndRef *types.IndirectRef, pageDict types.Dict, pageNr int, ar model.AnnotationRenderer, incr bool) (*types.IndirectRef, types.Dict, error)
AddAnnotation adds ar to pageDict.
func AddAnnotationToPage ¶ added in v0.9.2
func AddAnnotations ¶ added in v0.5.2
func AddAnnotations(ctx *model.Context, selectedPages types.IntSet, ar model.AnnotationRenderer, incr bool) (bool, error)
AddAnnotations adds ar to selected pages.
func AddAnnotationsMap ¶ added in v0.5.2
func AddAnnotationsMap(ctx *model.Context, m map[int][]model.AnnotationRenderer, incr bool) (bool, error)
AddAnnotationsMap adds annotations in m to corresponding pages.
func AddBookmarks ¶ added in v0.5.2
AddBookmarks adds bms to ctx.
func AddPageTreeWithSamplePage ¶ added in v0.5.2
func AddPages ¶ added in v0.3.12
AddPages adds pages and corresponding resources from ctxSrc to ctxDest.
func AddWatermarks ¶ added in v0.1.16
AddWatermarks adds watermarks to all pages selected.
func AddWatermarksMap ¶ added in v0.5.2
AddWatermarksMap adds watermarks in m to corresponding pages.
func AddWatermarksSliceMap ¶ added in v0.5.2
AddWatermarksSliceMap adds watermarks in m to corresponding pages.
func Annotation ¶ added in v0.5.2
Annotation returns an annotation renderer. Validation sets up a cache of annotation renderers.
func AnnotationsForSelectedPages ¶ added in v0.5.2
func AppendStatsFile ¶
AppendStatsFile appends a stats line for this xRefTable to the configured csv file name.
func BookletFromImages ¶ added in v0.3.12
func BookletFromImages(ctx *model.Context, fileNames []string, nup *model.NUp, pagesDict types.Dict, pagesIndRef *types.IndirectRef) error
BookletFromImages creates a booklet version of the image sequence represented by fileNames.
func BookletFromPDF ¶ added in v0.5.2
BookletFromPDF creates a booklet version of the PDF represented by xRefTable.
func CacheFormFonts ¶ added in v0.9.2
func CachedAnnotationObjNrs ¶ added in v0.5.2
CachedAnnotationObjNrs returns a list of object numbers representing known annotation dict indirect references.
func ColorSpaceComponents ¶ added in v0.5.2
ColorSpaceComponents returns the corresponding number of used color components for sd's colorspace.
func ColorSpaceString ¶ added in v0.5.2
ColorSpaceString returns a string representation for sd's colorspace.
func CreateAnnotationDemoXRef ¶
CreateAnnotationDemoXRef creates a PDF file with examples of annotations and actions.
func CreateContext ¶ added in v0.1.20
CreateContext creates a Context for given cross reference table and configuration.
func CreateContextWithXRefTable ¶ added in v0.1.20
func CreateContextWithXRefTable(conf *model.Configuration, pageDim *types.Dim) (*model.Context, error)
CreateContextWithXRefTable creates a Context with an xRefTable without pages for given configuration.
func CreateDemoXRef ¶ added in v0.1.16
CreateDemoXRef creates a minimal single page PDF file for demo purposes.
func CreateFormDemoXRef ¶ added in v0.5.2
CreateFormDemoXRef creates an xRefTable with an AcroForm example.
func CreateResourceDictInheritanceDemoXRef ¶ added in v0.3.12
CreateResourceDictInheritanceDemoXRef creates a page tree for testing resource dict inheritance.
func CreateTestPageContent ¶ added in v0.3.12
CreateTestPageContent draws a test grid.
func CreateXRefTableWithRootDict ¶ added in v0.5.2
func DefaultBookletConfig ¶ added in v0.3.12
DefaultBookletConfig returns the default configuration for a booklet
func DetectPageTreeWatermarks ¶ added in v0.5.2
DetectPageTreeWatermarks checks xRefTable's page tree for watermarks and records the result to xRefTable.Watermarked.
func DetectWatermarks ¶ added in v0.5.2
DetectWatermarks checks ctx for watermarks and records the result to xRefTable.Watermarked.
func EnsureOutlines ¶ added in v0.5.2
func ExportBookmarksJSON ¶ added in v0.5.2
func ExtractImage ¶ added in v0.5.2
func ExtractImage(ctx *model.Context, sd *types.StreamDict, thumb bool, resourceID string, objNr int, stub bool) (*model.Image, error)
ExtractImage extracts an image from sd.
func ExtractPageContent ¶ added in v0.5.2
ExtractPageContent extracts the consolidated page content stream for pageNr.
func ExtractPageImages ¶ added in v0.5.2
ExtractPageImages extracts all images used by pageNr. Optionally return stubs only.
func ExtractPages ¶ added in v0.5.2
ExtractPages extracts pageNrs into a new single page context.
func FontObjNrs ¶ added in v0.5.2
FontObjNrs returns all font dict objNrs for pageNr. Requires an optimized context.
func GetBookletOrdering ¶ added in v0.9.2
func ImageBookletConfig ¶ added in v0.3.12
ImageBookletConfig returns an NUp configuration for booklet-ing image files.
func ImageGridConfig ¶ added in v0.3.12
ImageGridConfig returns a grid configuration for Nup-ing image files.
func ImageNUpConfig ¶ added in v0.3.12
ImageNUpConfig returns an NUp configuration for Nup-ing image files.
func ImageObjNrs ¶ added in v0.5.2
ImageObjNrs returns all image dict objNrs for pageNr. Requires an optimized context.
func ImportBookmarks ¶ added in v0.5.2
ImportBookmarks creates/replaces outlines in ctx as provided by rd.
func KeywordsAdd ¶ added in v0.3.12
KeywordsAdd adds keywords to the document info dict. Returns true if at least one keyword was added.
func KeywordsList ¶ added in v0.3.12
KeywordsList returns a list of keywords as recorded in the document info dict.
func KeywordsRemove ¶ added in v0.3.12
KeywordsRemove deletes keywords from the document info dict. Returns true if at least one keyword was removed.
func ListAnnotations ¶ added in v0.5.2
ListAnnotations returns a formatted list of annotations.
func ListImages ¶ added in v0.5.2
ListImages returns a formatted list of embedded images.
func MergeXRefTables ¶
func MergeXRefTables(fName string, ctxSrc, ctxDest *model.Context, zip, dividerPage bool) (err error)
MergeXRefTables merges Context ctxSrc into ctxDest by appending its page tree. zip ... zip 2 files together (eg. 1A,1B,2A,2B,3A,3B...) dividerPage ... insert blank page between merged files (not applicable for zipping)
func NUpFromMultipleImages ¶ added in v0.3.12
func NUpFromMultipleImages(ctx *model.Context, fileNames []string, nup *model.NUp, pagesDict types.Dict, pagesIndRef *types.IndirectRef) error
NUpFromMultipleImages creates pages in NUp-style rendering each image once.
func NUpFromOneImage ¶ added in v0.3.12
func NUpFromOneImage(ctx *model.Context, fileName string, nup *model.NUp, pagesDict types.Dict, pagesIndRef *types.IndirectRef) error
NUpFromOneImage creates one page with instances of one image.
func NUpFromPDF ¶ added in v0.1.21
NUpFromPDF creates an n-up version of the PDF represented by xRefTable.
func NewNUpPageForImage ¶ added in v0.1.21
func NewNUpPageForImage(xRefTable *model.XRefTable, fileName string, parentIndRef *types.IndirectRef, nup *model.NUp) (*types.IndirectRef, error)
NewNUpPageForImage creates a new page dict in xRefTable for given image filename and n-up conf.
func NewPageForImage ¶ added in v0.1.20
func NewPageForImage(xRefTable *model.XRefTable, r io.Reader, parentIndRef *types.IndirectRef, imp *Import) (*types.IndirectRef, error)
NewPageForImage creates a new page dict in xRefTable for given image reader r.
func OptimizeXRefTable ¶
OptimizeXRefTable optimizes an xRefTable by locating and getting rid of redundant embedded fonts and images.
func PDFBookletConfig ¶ added in v0.3.12
PDFBookletConfig returns an NUp configuration for booklet-ing PDF files.
func PDFGridConfig ¶ added in v0.3.12
PDFGridConfig returns a grid configuration for Nup-ing PDF files.
func PDFNUpConfig ¶ added in v0.3.12
PDFNUpConfig returns an NUp configuration for Nup-ing PDF files.
func PageObjFromDestination ¶ added in v0.5.2
PageObjFromDestinationArray returns an IndirectRef of the destinations page.
func ParseCutConfig ¶ added in v0.5.2
ParseCutConfig parses a Cut command string into an internal structure. optionally: horizontalCut, verticalCut, bgcolor, border, margin, origin
func ParseCutConfigForN ¶ added in v0.5.2
ParseCutConfigForN parses a NDown command string into an internal structure. n, Optionally: border, margin, bgcolor
func ParseCutConfigForPoster ¶ added in v0.5.2
ParseCutConfigForPoster parses a Cut command string into an internal structure. formsize(=papersize) or dimensions, optionally: scalefactor, border, margin, bgcolor
func ParseImageWatermarkDetails ¶ added in v0.3.12
func ParseImageWatermarkDetails(fileName, desc string, onTop bool, u types.DisplayUnit) (*model.Watermark, error)
ParseImageWatermarkDetails parses an image Watermark/Stamp command string into an internal structure.
func ParseNUpDetails ¶ added in v0.1.21
ParseNUpDetails parses a NUp command string into an internal structure.
func ParseNUpGridDefinition ¶ added in v0.1.21
ParseNUpGridDefinition parses NUp grid dimensions into an internal structure.
func ParseNUpValue ¶ added in v0.1.21
ParseNUpValue parses the NUp value into an internal structure.
func ParseObject ¶ added in v0.1.16
ParseObject parses an object from file at given offset.
func ParseObjectWithContext ¶ added in v0.9.2
func ParsePDFWatermarkDetails ¶ added in v0.3.12
func ParsePDFWatermarkDetails(fileName, desc string, onTop bool, u types.DisplayUnit) (*model.Watermark, error)
ParsePDFWatermarkDetails parses a PDF Watermark/Stamp command string into an internal structure.
func ParsePageDim ¶ added in v0.9.2
func ParseResizeConfig ¶ added in v0.5.2
ParseResizeConfig parses a Resize command string into an internal structure. "scale:.5, form:A4, dim:400 200 bgcol:#D00000"
func ParseTextWatermarkDetails ¶ added in v0.3.12
func ParseTextWatermarkDetails(text, desc string, onTop bool, u types.DisplayUnit) (*model.Watermark, error)
ParseTextWatermarkDetails parses a text Watermark/Stamp command string into an internal structure.
func ParseZoomConfig ¶ added in v0.9.2
ParseZoomConfig parses a Zoom command string into an internal structure.
func Permissions ¶
Permissions returns a list of set permissions.
func PermissionsList ¶ added in v0.5.2
PermissionsList returns a list of set permissions.
func PosterPage ¶ added in v0.5.2
func PropertiesAdd ¶ added in v0.3.12
PropertiesAdd adds properties into the document info dict. Returns true if at least one property was added.
func PropertiesList ¶ added in v0.3.12
PropertiesList returns a list of document properties as recorded in the document info dict.
func PropertiesRemove ¶ added in v0.3.12
PropertiesRemove deletes specified properties. Returns true if at least one property was removed.
func Read ¶ added in v0.1.18
func Read(rs io.ReadSeeker, conf *model.Configuration) (*model.Context, error)
Read takes a readSeeker and generates a PDF model context, an in-memory representation containing a cross reference table.
func ReadFile ¶ added in v0.1.18
ReadFile reads in a PDF file and builds an internal structure holding its cross reference table aka the PDF model context.
func ReadFileWithContext ¶ added in v0.9.2
func ReadFileWithContext(c context.Context, inFile string, conf *model.Configuration) (*model.Context, error)
ReadFileContext reads in a PDF file and builds an internal structure holding its cross reference table aka the PDF model context. If the passed Go context is cancelled, reading will be interrupted.
func ReadWithContext ¶ added in v0.9.2
func ReadWithContext(c context.Context, rs io.ReadSeeker, conf *model.Configuration) (*model.Context, error)
Read takes a readSeeker and generates a PDF model context, an in-memory representation containing a cross reference table. If the passed Go context is cancelled, reading will be interrupted.
func RemoveAnnotations ¶ added in v0.5.2
func RemoveAnnotations(ctx *model.Context, selectedPages types.IntSet, idsAndTypes []string, objNrs []int, incr bool) (bool, error)
RemoveAnnotations removes annotations for selected pages by id, type or object number. All annotations for selected pages are removed if neither idsAndTypes nor objNrs are provided.
func RemoveAnnotationsFromPageDict ¶ added in v0.5.2
func RemoveAnnotationsFromPageDict( ctx *model.Context, annotTypes []model.AnnotationType, ids []string, objNrSet types.IntSet, pageDict types.Dict, pageDictObjNr, pageNr int, incr bool) (bool, error)
RemoveAnnotationsFromPageDict removes an annotation by annotType, id and obj# from pageDict.
func RemoveBookmarks ¶ added in v0.5.2
RemoveBookmarks erases all outlines from ctx.
func RemoveWatermarks ¶ added in v0.5.2
RemoveWatermarks removes watermarks for all pages selected.
func RenderImage ¶ added in v0.3.12
func RenderImage(xRefTable *model.XRefTable, sd *types.StreamDict, thumb bool, resourceName string, objNr int) (io.Reader, string, error)
RenderImage returns a reader for a decoded image stream.
func RotatePages ¶ added in v0.1.20
RotatePages rotates all selected pages by a multiple of 90 degrees.
func StreamLength ¶ added in v0.5.2
StreamLength returns sd's stream length.
func UpdateImagesByObjNr ¶ added in v0.9.2
UpdateImagesByObjNr replaces an XObject.
func UpdateImagesByPageNrAndId ¶ added in v0.9.2
UpdateImagesByPageNrAndId replaces the XObject referenced by pageNr and id.
func Write ¶ added in v0.1.18
Write generates a PDF file for the cross reference table contained in Context.
func WriteImage ¶ added in v0.1.16
func WriteImage(xRefTable *model.XRefTable, fileName string, sd *types.StreamDict, thumb bool, objNr int) (string, error)
WriteImage writes a PDF image object to disk.
func WriteImageToDisk ¶ added in v0.5.2
WriteImageToDisk returns a closure for writing img to disk.
func WriteIncrement ¶ added in v0.5.2
WriteIncrement writes a PDF increment..
func WriteReader ¶ added in v0.3.12
WriteReader consumes r's content by writing it to a file at path.
Types ¶
type AnnotListMaxLengths ¶ added in v0.9.2
type AnnotListMaxLengths struct {
ObjNr, ID, Rect, Content int
}
type Bookmark ¶ added in v0.3.12
type Bookmark struct { Title string `json:"title"` PageFrom int `json:"page"` PageThru int `json:"-"` // for extraction only; >= pageFrom and reaches until before pageFrom of the next bookmark. Bold bool `json:"bold,omitempty"` Italic bool `json:"italic,omitempty"` Color *color.SimpleColor `json:"color,omitempty"` Kids []Bookmark `json:"kids,omitempty"` Parent *Bookmark `json:"-"` }
Bookmark represents an outline item tree.
func BookmarksForOutlineItem ¶ added in v0.5.2
func BookmarksForOutlineItem(ctx *model.Context, item *types.IndirectRef, parent *Bookmark) ([]Bookmark, error)
BookmarksForOutlineItem returns the bookmarks tree for an outline item.
type BookmarkTree ¶ added in v0.5.2
func ExportBookmarks ¶ added in v0.5.2
func ExportBookmarks(ctx *model.Context, source string) (*BookmarkTree, error)
type Font ¶ added in v0.3.12
Font is a Reader representing an embedded font.
func ExtractFont ¶ added in v0.5.2
ExtractFont extracts a font from fontObject.
func ExtractFormFonts ¶ added in v0.5.2
ExtractPageFonts extracts all form fonts.
type Header ¶ added in v0.5.2
type Header struct { Source string `json:"source,omitempty"` Version string `json:"version"` Creation string `json:"creation"` ID []string `json:"id,omitempty"` Title string `json:"title,omitempty"` Author string `json:"author,omitempty"` Creator string `json:"creator,omitempty"` Producer string `json:"producer,omitempty"` Subject string `json:"subject,omitempty"` Keywords string `json:"keywords,omitempty"` }
type ImageListMaxLengths ¶ added in v0.5.2
type ImageListMaxLengths struct {
PageNr, ObjNr, ID, Size, Filters int
}
type Import ¶ added in v0.1.20
type Import struct { PageDim *types.Dim // page dimensions in display unit. PageSize string // one of A0,A1,A2,A3,A4(=default),A5,A6,A7,A8,Letter,Legal,Ledger,Tabloid,Executive,ANSIC,ANSID,ANSIE. UserDim bool // true if one of dimensions or paperSize provided overriding the default. DPI int // destination resolution to apply in dots per inch. Pos types.Anchor // position anchor, one of tl,tc,tr,l,c,r,bl,bc,br,full. Dx, Dy float64 // anchor offset. Scale float64 // relative scale factor. 0 <= x <= 1 ScaleAbs bool // true for absolute scaling. InpUnit types.DisplayUnit // input display unit. Gray bool // true for rendering in Gray. Sepia bool BgColor *color.SimpleColor // background color }
Import represents the command details for the command "ImportImage".
func DefaultImportConfig ¶ added in v0.1.20
func DefaultImportConfig() *Import
DefaultImportConfig returns the default configuration.
func ParseImportDetails ¶ added in v0.1.20
func ParseImportDetails(s string, u types.DisplayUnit) (*Import, error)
ParseImportDetails parses an Import command string into an internal structure.
type Metadata ¶ added in v0.3.12
type Metadata struct { io.Reader // metadata ObjNr int // metadata dict objNr ParentObjNr int // container object number ParentType string // container dict type }
Metadata is a Reader representing a metadata dict.
type PDFImage ¶ added in v0.1.16
type PDFImage struct {
// contains filtered or unexported fields
}
PDFImage represents a XObject of subtype image.
type PDFInfo ¶ added in v0.5.2
type PDFInfo struct { FileName string `json:"source,omitempty"` Version string `json:"version"` PageCount int `json:"pageCount"` PageBoundaries []model.PageBoundaries `json:"-"` Boundaries map[string]model.PageBoundaries `json:"pageBoundaries,omitempty"` PageDimensions map[types.Dim]bool `json:"-"` Dimensions []types.Dim `json:"pageSizes,omitempty"` Title string `json:"title"` Author string `json:"author"` Subject string `json:"subject"` Producer string `json:"producer"` Creator string `json:"creator"` CreationDate string `json:"creationDate"` ModificationDate string `json:"modificationDate"` PageMode string `json:"pageMode,omitempty"` PageLayout string `json:"pageLayout,omitempty"` ViewerPref *model.ViewerPreferences `json:"viewerPreferences,omitempty"` Keywords []string `json:"keywords"` Properties map[string]string `json:"properties"` Tagged bool `json:"tagged"` Hybrid bool `json:"hybrid"` Linearized bool `json:"linearized"` UsingXRefStreams bool `json:"usingXRefStreams"` UsingObjectStreams bool `json:"usingObjectStreams"` Watermarked bool `json:"watermarked"` Thumbnails bool `json:"thumbnails"` Form bool `json:"form"` Signatures bool `json:"signatures"` AppendOnly bool `json:"appendOnly"` Outlines bool `json:"bookmarks"` Names bool `json:"names"` Encrypted bool `json:"encrypted"` Permissions int `json:"permissions"` Attachments []model.Attachment `json:"attachments,omitempty"` Unit types.DisplayUnit `json:"-"` UnitString string `json:"unit"` }
type PageConfiguration ¶ added in v0.9.2
type PageConfiguration struct { PageDim *types.Dim // page dimensions in display unit. PageSize string // one of A0,A1,A2,A3,A4(=default),A5,A6,A7,A8,Letter,Legal,Ledger,Tabloid,Executive,ANSIC,ANSID,ANSIE. UserDim bool // true if one of dimensions or paperSize provided overriding the default. InpUnit types.DisplayUnit // input display unit. }
PageConfiguration represents the page config for the "pages insert" command.
func DefaultPageConfiguration ¶ added in v0.9.2
func DefaultPageConfiguration() *PageConfiguration
DefaultPageConfiguration returns the default configuration.
func ParsePageConfiguration ¶ added in v0.9.2
func ParsePageConfiguration(s string, u types.DisplayUnit) (*PageConfiguration, error)
ParsePageConfiguration parses a page configuration string into an internal structure.
func (PageConfiguration) String ¶ added in v0.9.2
func (p PageConfiguration) String() string
Source Files
¶
- annotation.go
- booklet.go
- bookmark.go
- createAnnotations.go
- createRenditions.go
- createTestPDF.go
- crypto.go
- cut.go
- doc.go
- extract.go
- iccProfile.go
- image.go
- importImage.go
- info.go
- keyword.go
- merge.go
- migrate.go
- nup.go
- optimize.go
- page.go
- property.go
- read.go
- resize.go
- rotate.go
- stamp.go
- write.go
- writeImage.go
- writeObjects.go
- writePages.go
- writeStats.go
- zoom.go