Documentation ¶
Overview ¶
Package api lets you integrate pdfcpu's operations into your Go backend.
There are two api layers supporting all pdfcpu operations:
- The file based layer (used by pdfcpu's cli)
- The io.ReadSeeker/io.Writer based layer for backend integration.
For any pdfcpu command there are two functions.
The file based function always calls the io.ReadSeeker/io.Writer based function:
func CommandFile(inFile, outFile string, conf *pdf.Configuration) error func Command(rs io.ReadSeeker, w io.Writer, conf *pdf.Configuration) error
eg. for optimization:
func OptimizeFile(inFile, outFile string, conf *pdf.Configuration) error func Optimize(rs io.ReadSeeker, w io.Writer, conf *pdf.Configuration) error
Index ¶
- func AddAnnotations(rs io.ReadSeeker, w io.Writer, selectedPages []string, ...) error
- func AddAnnotationsAsIncrement(rws io.ReadWriteSeeker, selectedPages []string, ar pdfcpu.AnnotationRenderer, ...) error
- func AddAnnotationsFile(inFile, outFile string, selectedPages []string, ar pdfcpu.AnnotationRenderer, ...) (err error)
- func AddAnnotationsMap(rs io.ReadSeeker, w io.Writer, m map[int][]pdfcpu.AnnotationRenderer, ...) error
- func AddAnnotationsMapAsIncrement(rws io.ReadWriteSeeker, m map[int][]pdfcpu.AnnotationRenderer, ...) error
- func AddAnnotationsMapFile(inFile, outFile string, m map[int][]pdfcpu.AnnotationRenderer, ...) (err error)
- func AddAttachments(rs io.ReadSeeker, w io.Writer, files []string, coll bool, ...) error
- func AddAttachmentsFile(inFile, outFile string, files []string, coll bool, conf *pdfcpu.Configuration) (err error)
- func AddBookmarks(rs io.ReadSeeker, w io.Writer, bms []pdf.Bookmark, conf *pdf.Configuration) error
- func AddBookmarksFile(inFile, outFile string, bms []pdf.Bookmark, conf *pdf.Configuration) (err error)
- func AddBoxes(rs io.ReadSeeker, w io.Writer, selectedPages []string, ...) error
- func AddBoxesFile(inFile, outFile string, selectedPages []string, pb *pdfcpu.PageBoundaries, ...) error
- func AddImageWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, ...) error
- func AddImageWatermarksForReaderFile(inFile, outFile string, selectedPages []string, onTop bool, r io.Reader, ...) error
- func AddKeywords(rs io.ReadSeeker, w io.Writer, files []string, conf *pdf.Configuration) error
- func AddKeywordsFile(inFile, outFile string, files []string, conf *pdf.Configuration) (err error)
- func AddPDFWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, ...) error
- func AddProperties(rs io.ReadSeeker, w io.Writer, properties map[string]string, ...) error
- func AddPropertiesFile(inFile, outFile string, properties map[string]string, conf *pdf.Configuration) (err error)
- func AddTextWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, text, desc string, ...) error
- func AddWatermarks(rs io.ReadSeeker, w io.Writer, selectedPages []string, wm *pdfcpu.Watermark, ...) error
- func AddWatermarksFile(inFile, outFile string, selectedPages []string, wm *pdfcpu.Watermark, ...) (err error)
- func AddWatermarksMap(rs io.ReadSeeker, w io.Writer, m map[int]*pdfcpu.Watermark, ...) error
- func AddWatermarksMapFile(inFile, outFile string, m map[int]*pdfcpu.Watermark, ...) (err error)
- func AddWatermarksSliceMap(rs io.ReadSeeker, w io.Writer, m map[int][]*pdfcpu.Watermark, ...) error
- func AddWatermarksSliceMapFile(inFile, outFile string, m map[int][]*pdfcpu.Watermark, ...) (err error)
- func Booklet(rs io.ReadSeeker, w io.Writer, imgFiles, selectedPages []string, ...) error
- func BookletFile(inFiles []string, outFile string, selectedPages []string, nup *pdfcpu.NUp, ...) (err error)
- func BookletFromImages(conf *pdfcpu.Configuration, imageFileNames []string, nup *pdfcpu.NUp) (*pdfcpu.Context, error)
- func Box(s string, u pdfcpu.DisplayUnit) (*pdfcpu.Box, error)
- func ChangeOwnerPassword(rs io.ReadSeeker, w io.Writer, pwOld, pwNew string, conf *pdfcpu.Configuration) error
- func ChangeOwnerPasswordFile(inFile, outFile string, pwOld, pwNew string, conf *pdfcpu.Configuration) (err error)
- func ChangeUserPassword(rs io.ReadSeeker, w io.Writer, pwOld, pwNew string, conf *pdfcpu.Configuration) error
- func ChangeUserPasswordFile(inFile, outFile string, pwOld, pwNew string, conf *pdfcpu.Configuration) (err error)
- func Collect(rs io.ReadSeeker, w io.Writer, selectedPages []string, ...) error
- func CollectFile(inFile, outFile string, selectedPages []string, conf *pdfcpu.Configuration) (err error)
- func CreateCheatSheetsUserFonts(fontNames []string) error
- func CreateFromJSON(rd io.Reader, rs io.ReadSeeker, w io.Writer, conf *pdfcpu.Configuration) error
- func CreateFromJSONFile(jsonFile, inFile, outFile string, conf *pdfcpu.Configuration) (err error)
- func CreatePDFFile(xRefTable *pdfcpu.XRefTable, outFile string, conf *pdfcpu.Configuration) error
- func CreateUserFontDemoFiles(dir, fn string) error
- func Crop(rs io.ReadSeeker, w io.Writer, selectedPages []string, b *pdfcpu.Box, ...) error
- func CropFile(inFile, outFile string, selectedPages []string, b *pdfcpu.Box, ...) error
- func Decrypt(rs io.ReadSeeker, w io.Writer, conf *pdfcpu.Configuration) error
- func DecryptFile(inFile, outFile string, conf *pdfcpu.Configuration) (err error)
- func DisableConfigDir()
- func Encrypt(rs io.ReadSeeker, w io.Writer, conf *pdfcpu.Configuration) error
- func EncryptFile(inFile, outFile string, conf *pdfcpu.Configuration) (err error)
- func EnsureDefaultConfigAt(path string) error
- func ExtractAttachments(rs io.ReadSeeker, outDir string, fileNames []string, ...) error
- func ExtractAttachmentsFile(inFile, outDir string, files []string, conf *pdfcpu.Configuration) error
- func ExtractAttachmentsRaw(rs io.ReadSeeker, outDir string, fileNames []string, ...) ([]pdfcpu.Attachment, error)
- func ExtractContent(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, ...) error
- func ExtractContentFile(inFile, outDir string, selectedPages []string, conf *pdfcpu.Configuration) error
- func ExtractFonts(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, ...) error
- func ExtractFontsFile(inFile, outDir string, selectedPages []string, conf *pdfcpu.Configuration) error
- func ExtractImages(rs io.ReadSeeker, selectedPages []string, ...) error
- func ExtractImagesFile(inFile, outDir string, selectedPages []string, conf *pdfcpu.Configuration) error
- func ExtractImagesRaw(rs io.ReadSeeker, selectedPages []string, conf *pdfcpu.Configuration) ([]pdfcpu.Image, error)
- func ExtractMetadata(rs io.ReadSeeker, outDir, fileName string, conf *pdfcpu.Configuration) error
- func ExtractMetadataFile(inFile, outDir string, conf *pdfcpu.Configuration) error
- func ExtractPages(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, ...) error
- func ExtractPagesFile(inFile, outDir string, selectedPages []string, conf *pdfcpu.Configuration) error
- func GetPermissions(rs io.ReadSeeker, conf *pdfcpu.Configuration) (*int16, error)
- func GetPermissionsFile(inFile string, conf *pdfcpu.Configuration) (*int16, error)
- func HasWatermarks(rs io.ReadSeeker, conf *pdfcpu.Configuration) (bool, error)
- func HasWatermarksFile(inFile string, conf *pdfcpu.Configuration) (bool, error)
- func ImageBookletConfig(val int, desc string) (*pdfcpu.NUp, error)
- func ImageGridConfig(rows, cols int, desc string) (*pdfcpu.NUp, error)
- func ImageNUpConfig(val int, desc string) (*pdfcpu.NUp, error)
- func ImageWatermark(fileName, desc string, onTop, update bool, u pdfcpu.DisplayUnit) (*pdfcpu.Watermark, error)
- func ImageWatermarkForReader(r io.Reader, desc string, onTop, update bool, u pdfcpu.DisplayUnit) (*pdfcpu.Watermark, error)
- func Import(s string, u pdfcpu.DisplayUnit) (*pdfcpu.Import, error)
- func ImportImages(rs io.ReadSeeker, w io.Writer, imgs []io.Reader, imp *pdfcpu.Import, ...) error
- func ImportImagesFile(imgFiles []string, outFile string, imp *pdfcpu.Import, ...) (err error)
- func Info(rs io.ReadSeeker, selectedPages []string, conf *pdfcpu.Configuration) ([]string, error)
- func InfoFile(inFile string, selectedPages []string, conf *pdfcpu.Configuration) ([]string, error)
- func InsertPages(rs io.ReadSeeker, w io.Writer, selectedPages []string, before bool, ...) error
- func InsertPagesFile(inFile, outFile string, selectedPages []string, before bool, ...) (err error)
- func InstallFonts(fileNames []string) error
- func ListAnnotations(rs io.ReadSeeker, selectedPages []string, conf *pdfcpu.Configuration) (int, []string, error)
- func ListAnnotationsFile(inFile string, selectedPages []string, conf *pdfcpu.Configuration) (int, []string, error)
- func ListAttachments(rs io.ReadSeeker, conf *pdfcpu.Configuration) ([]string, error)
- func ListAttachmentsCompact(rs io.ReadSeeker, conf *pdfcpu.Configuration) ([]string, error)
- func ListAttachmentsCompactFile(inFile string, conf *pdfcpu.Configuration) ([]string, error)
- func ListAttachmentsFile(inFile string, conf *pdfcpu.Configuration) ([]string, error)
- func ListBoxes(rs io.ReadSeeker, selectedPages []string, pb *pdfcpu.PageBoundaries, ...) ([]string, error)
- func ListBoxesFile(inFile string, selectedPages []string, pb *pdfcpu.PageBoundaries, ...) ([]string, error)
- func ListFonts() ([]string, error)
- func ListImages(rs io.ReadSeeker, selectedPages []string, conf *pdfcpu.Configuration) ([]string, error)
- func ListImagesFile(inFiles []string, selectedPages []string, conf *pdfcpu.Configuration) ([]string, error)
- func ListKeywords(rs io.ReadSeeker, conf *pdf.Configuration) ([]string, error)
- func ListKeywordsFile(inFile string, conf *pdf.Configuration) ([]string, error)
- func ListPermissions(rs io.ReadSeeker, conf *pdfcpu.Configuration) ([]string, error)
- func ListPermissionsFile(inFile string, conf *pdfcpu.Configuration) ([]string, error)
- func ListProperties(rs io.ReadSeeker, conf *pdf.Configuration) ([]string, error)
- func ListPropertiesFile(inFile string, conf *pdf.Configuration) ([]string, error)
- func LoadConfiguration() *pdfcpu.Configuration
- func Merge(rsc []io.ReadSeeker, w io.Writer, conf *pdfcpu.Configuration) error
- func MergeAppendFile(inFiles []string, outFile string, conf *pdfcpu.Configuration) (err error)
- func MergeCreateFile(inFiles []string, outFile string, conf *pdfcpu.Configuration) error
- func NUp(rs io.ReadSeeker, w io.Writer, imgFiles, selectedPages []string, ...) error
- func NUpFile(inFiles []string, outFile string, selectedPages []string, nup *pdfcpu.NUp, ...) (err error)
- func NUpFromImage(conf *pdfcpu.Configuration, imageFileNames []string, nup *pdfcpu.NUp) (*pdfcpu.Context, error)
- func Optimize(rs io.ReadSeeker, w io.Writer, conf *pdfcpu.Configuration) error
- func OptimizeContext(ctx *pdfcpu.Context) error
- func OptimizeFile(inFile, outFile string, conf *pdfcpu.Configuration) (err error)
- func PDFBookletConfig(val int, desc string) (*pdfcpu.NUp, error)
- func PDFGridConfig(rows, cols int, desc string) (*pdfcpu.NUp, error)
- func PDFNUpConfig(val int, desc string) (*pdfcpu.NUp, error)
- func PDFWatermark(fileName, desc string, onTop, update bool, u pdfcpu.DisplayUnit) (*pdfcpu.Watermark, error)
- func PageBoundaries(s string, unit pdfcpu.DisplayUnit) (*pdfcpu.PageBoundaries, error)
- func PageBoundariesFromBoxList(s string) (*pdfcpu.PageBoundaries, error)
- func PageCount(rs io.ReadSeeker, conf *pdfcpu.Configuration) (int, error)
- func PageCountFile(inFile string) (int, error)
- func PageDims(rs io.ReadSeeker, conf *pdfcpu.Configuration) ([]pdfcpu.Dim, error)
- func PageDimsFile(inFile string) ([]pdfcpu.Dim, error)
- func PagesForPageCollection(pageCount int, pageSelection []string) ([]int, error)
- func PagesForPageRange(from, thru int) []int
- func PagesForPageSelection(pageCount int, pageSelection []string, ensureAllforNone bool) (pdf.IntSet, error)
- func ParsePageSelection(s string) ([]string, error)
- func ReadContext(rs io.ReadSeeker, conf *pdfcpu.Configuration) (*pdfcpu.Context, error)
- func ReadContextFile(inFile string) (*pdfcpu.Context, error)
- func RemoveAnnotations(rs io.ReadSeeker, w io.Writer, selectedPages, ids []string, objNrs []int, ...) error
- func RemoveAnnotationsAsIncrement(rws io.ReadWriteSeeker, selectedPages, ids []string, objNrs []int, ...) error
- func RemoveAnnotationsFile(inFile, outFile string, selectedPages, ids []string, objNrs []int, ...) (err error)
- func RemoveAttachments(rs io.ReadSeeker, w io.Writer, files []string, conf *pdfcpu.Configuration) error
- func RemoveAttachmentsFile(inFile, outFile string, files []string, conf *pdfcpu.Configuration) (err error)
- func RemoveBoxes(rs io.ReadSeeker, w io.Writer, selectedPages []string, ...) error
- func RemoveBoxesFile(inFile, outFile string, selectedPages []string, pb *pdfcpu.PageBoundaries, ...) error
- func RemoveKeywords(rs io.ReadSeeker, w io.Writer, keywords []string, conf *pdf.Configuration) error
- func RemoveKeywordsFile(inFile, outFile string, keywords []string, conf *pdf.Configuration) (err error)
- func RemovePages(rs io.ReadSeeker, w io.Writer, selectedPages []string, ...) error
- func RemovePagesFile(inFile, outFile string, selectedPages []string, conf *pdfcpu.Configuration) (err error)
- func RemoveProperties(rs io.ReadSeeker, w io.Writer, properties []string, conf *pdf.Configuration) error
- func RemovePropertiesFile(inFile, outFile string, properties []string, conf *pdf.Configuration) (err error)
- func RemoveWatermarks(rs io.ReadSeeker, w io.Writer, selectedPages []string, ...) error
- func RemoveWatermarksFile(inFile, outFile string, selectedPages []string, conf *pdfcpu.Configuration) (err error)
- func Rotate(rs io.ReadSeeker, w io.Writer, rotation int, selectedPages []string, ...) error
- func RotateFile(inFile, outFile string, rotation int, selectedPages []string, ...) (err error)
- func SetPermissions(rs io.ReadSeeker, w io.Writer, conf *pdfcpu.Configuration) error
- func SetPermissionsFile(inFile, outFile string, conf *pdfcpu.Configuration) (err error)
- func Split(rs io.ReadSeeker, outDir, fileName string, span int, ...) error
- func SplitFile(inFile, outDir string, span int, conf *pdfcpu.Configuration) error
- func TextWatermark(text, desc string, onTop, update bool, u pdfcpu.DisplayUnit) (*pdfcpu.Watermark, error)
- func Trim(rs io.ReadSeeker, w io.Writer, selectedPages []string, ...) error
- func TrimFile(inFile, outFile string, selectedPages []string, conf *pdfcpu.Configuration) (err error)
- func UpdateImageWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, ...) error
- func UpdatePDFWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, ...) error
- func UpdateTextWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, text, desc string, ...) error
- func Validate(rs io.ReadSeeker, conf *pdfcpu.Configuration) error
- func ValidateContext(ctx *pdfcpu.Context) error
- func ValidateFile(inFile string, conf *pdfcpu.Configuration) error
- func ValidateFiles(inFiles []string, conf *pdfcpu.Configuration) error
- func WatermarkContext(ctx *pdfcpu.Context, selectedPages pdfcpu.IntSet, wm *pdfcpu.Watermark) error
- func WriteContext(ctx *pdfcpu.Context, w io.Writer) error
- func WriteContextFile(ctx *pdfcpu.Context, outFile string) error
- func WriteIncrement(ctx *pdfcpu.Context, w io.Writer) error
- type MergeError
- type PageSpan
- type ReadSeekerCloser
Examples ¶
- AddAttachmentsFile
- AddWatermarksFile
- ChangeOwnerPasswordFile
- ChangeUserPasswordFile
- DecryptFile
- EncryptFile
- ExtractAttachmentsFile
- ExtractContentFile
- ExtractFontsFile
- ExtractImagesFile
- ExtractMetadataFile
- ExtractPagesFile
- ImportImagesFile
- InsertPagesFile
- ListAttachmentsFile
- ListPermissionsFile
- MergeAppendFile
- MergeCreateFile
- NUpFile
- OptimizeFile
- RemoveAttachmentsFile
- RemovePagesFile
- RemoveWatermarksFile
- RotateFile
- SetPermissionsFile
- SplitFile
- TrimFile
- ValidateFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAnnotations ¶
func AddAnnotations(rs io.ReadSeeker, w io.Writer, selectedPages []string, ann pdfcpu.AnnotationRenderer, conf *pdfcpu.Configuration) error
AddAnnotations adds annotations for selected pages in rs and writes the result to w.
func AddAnnotationsAsIncrement ¶
func AddAnnotationsAsIncrement(rws io.ReadWriteSeeker, selectedPages []string, ar pdfcpu.AnnotationRenderer, conf *pdfcpu.Configuration) error
AddAnnotationsAsIncrement adds annotations for selected pages in rws and writes out a PDF increment.
func AddAnnotationsFile ¶
func AddAnnotationsFile(inFile, outFile string, selectedPages []string, ar pdfcpu.AnnotationRenderer, conf *pdfcpu.Configuration, incr bool) (err error)
AddAnnotationsFile adds annotations for selected pages to a PDF context read from inFile and writes the result to outFile.
func AddAnnotationsMap ¶
func AddAnnotationsMap(rs io.ReadSeeker, w io.Writer, m map[int][]pdfcpu.AnnotationRenderer, conf *pdfcpu.Configuration) error
AddAnnotationsMap adds annotations in m to corresponding pages of rs and writes the result to w.
func AddAnnotationsMapAsIncrement ¶
func AddAnnotationsMapAsIncrement(rws io.ReadWriteSeeker, m map[int][]pdfcpu.AnnotationRenderer, conf *pdfcpu.Configuration) error
AddAnnotationsMapAsIncrement adds annotations in m to corresponding pages of rws and writes out a PDF increment.
func AddAnnotationsMapFile ¶
func AddAnnotationsMapFile(inFile, outFile string, m map[int][]pdfcpu.AnnotationRenderer, conf *pdfcpu.Configuration, incr bool) (err error)
AddAnnotationsMapFile adds annotations in m to corresponding pages of inFile and writes the result to outFile.
func AddAttachments ¶
func AddAttachments(rs io.ReadSeeker, w io.Writer, files []string, coll bool, conf *pdfcpu.Configuration) error
AddAttachments embeds files into a PDF context read from rs and writes the result to w. file is either a file name or a file name and a description separated by a comma.
func AddAttachmentsFile ¶
func AddAttachmentsFile(inFile, outFile string, files []string, coll bool, conf *pdfcpu.Configuration) (err error)
AddAttachmentsFile embeds files into a PDF context read from inFile and writes the result to outFile.
Example ¶
// Attach 3 files to in.pdf. AddAttachmentsFile("in.pdf", "", []string{"img.jpg", "attach.pdf", "test.zip"}, false, nil)
Output:
func AddBookmarks ¶
func AddBookmarks(rs io.ReadSeeker, w io.Writer, bms []pdf.Bookmark, conf *pdf.Configuration) error
AddBookmarks adds a single bookmark outline layer to the PDF context read from rs and writes the result to w.
func AddBookmarksFile ¶
func AddBookmarksFile(inFile, outFile string, bms []pdf.Bookmark, conf *pdf.Configuration) (err error)
AddBookmarksFile adds a single bookmark outline layer to the PDF context read from inFile and writes the result to outFile.
func AddBoxes ¶
func AddBoxes(rs io.ReadSeeker, w io.Writer, selectedPages []string, pb *pdfcpu.PageBoundaries, conf *pdfcpu.Configuration) error
AddBoxes adds page boundaries for selected pages of rs and writes result to w.
func AddBoxesFile ¶
func AddBoxesFile(inFile, outFile string, selectedPages []string, pb *pdfcpu.PageBoundaries, conf *pdfcpu.Configuration) error
AddBoxesFile adds page boundaries for selected pages of inFile and writes result to outFile.
func AddImageWatermarksFile ¶
func AddImageWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, fileName, desc string, conf *pdfcpu.Configuration) error
AddImageWatermarksFile adds image stamps/watermarks to all selected pages of inFile and writes the result to outFile.
func AddImageWatermarksForReaderFile ¶
func AddImageWatermarksForReaderFile(inFile, outFile string, selectedPages []string, onTop bool, r io.Reader, desc string, conf *pdfcpu.Configuration) error
AddImageWatermarksForReaderFile adds image stamps/watermarks to all selected pages of inFile for r and writes the result to outFile.
func AddKeywords ¶
func AddKeywords(rs io.ReadSeeker, w io.Writer, files []string, conf *pdf.Configuration) error
AddKeywords embeds files into a PDF context read from rs and writes the result to w.
func AddKeywordsFile ¶
func AddKeywordsFile(inFile, outFile string, files []string, conf *pdf.Configuration) (err error)
AddKeywordsFile embeds files into a PDF context read from inFile and writes the result to outFile.
func AddPDFWatermarksFile ¶
func AddPDFWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, fileName, desc string, conf *pdfcpu.Configuration) error
AddPDFWatermarksFile adds PDF stamps/watermarks to all selected pages of inFile and writes the result to outFile.
func AddProperties ¶
func AddProperties(rs io.ReadSeeker, w io.Writer, properties map[string]string, conf *pdf.Configuration) error
AddProperties embeds files into a PDF context read from rs and writes the result to w.
func AddPropertiesFile ¶
func AddPropertiesFile(inFile, outFile string, properties map[string]string, conf *pdf.Configuration) (err error)
AddPropertiesFile embeds files into a PDF context read from inFile and writes the result to outFile.
func AddTextWatermarksFile ¶
func AddTextWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, text, desc string, conf *pdfcpu.Configuration) error
AddTextWatermarksFile adds text stamps/watermarks to all selected pages of inFile and writes the result to outFile.
func AddWatermarks ¶
func AddWatermarks(rs io.ReadSeeker, w io.Writer, selectedPages []string, wm *pdfcpu.Watermark, conf *pdfcpu.Configuration) error
AddWatermarks adds watermarks to all pages selected in rs and writes the result to w.
func AddWatermarksFile ¶
func AddWatermarksFile(inFile, outFile string, selectedPages []string, wm *pdfcpu.Watermark, conf *pdfcpu.Configuration) (err error)
AddWatermarksFile adds watermarks to all selected pages of inFile and writes the result to outFile.
Example ¶
// Unique abbreviations are accepted for all watermark descriptor parameters. // eg. sc = scalefactor or rot = rotation // Add a "Demo" watermark to all pages of in.pdf along the diagonal running from lower left to upper right. onTop := false update := false wm, _ := TextWatermark("Demo", "", onTop, update, pdfcpu.POINTS) AddWatermarksFile("in.pdf", "", nil, wm, nil) // Stamp all odd pages of in.pdf in red "Confidential" in 48 point Courier // using a rotation angle of 45 degrees and an absolute scalefactor of 1.0. onTop = true wm, _ = TextWatermark("Confidential", "font:Courier, points:48, col: 1 0 0, rot:45, sc:1 abs, ", onTop, update, pdfcpu.POINTS) AddWatermarksFile("in.pdf", "", []string{"odd"}, wm, nil) // Add image stamps to in.pdf using absolute scaling and a negative rotation of 90 degrees. wm, _ = ImageWatermark("image.png", "scalefactor:.5 a, rot:-90", onTop, update, pdfcpu.POINTS) AddWatermarksFile("in.pdf", "", nil, wm, nil) // Add a PDF stamp to all pages of in.pdf using the 2nd page of stamp.pdf, use absolute scaling of 0.5 // and rotate along the 2nd diagonal running from upper left to lower right corner. wm, _ = PDFWatermark("stamp.pdf:2", "sc:.5 abs, diagonal:2", onTop, update, pdfcpu.POINTS) AddWatermarksFile("in.pdf", "", nil, wm, nil)
Output:
func AddWatermarksMap ¶
func AddWatermarksMap(rs io.ReadSeeker, w io.Writer, m map[int]*pdfcpu.Watermark, conf *pdfcpu.Configuration) error
AddWatermarksMap adds watermarks in m to corresponding pages in rs and writes the result to w.
func AddWatermarksMapFile ¶
func AddWatermarksMapFile(inFile, outFile string, m map[int]*pdfcpu.Watermark, conf *pdfcpu.Configuration) (err error)
AddWatermarksMapFile adds watermarks to corresponding pages in m of inFile and writes the result to outFile.
func AddWatermarksSliceMap ¶
func AddWatermarksSliceMap(rs io.ReadSeeker, w io.Writer, m map[int][]*pdfcpu.Watermark, conf *pdfcpu.Configuration) error
AddWatermarksSliceMap adds watermarks in m to corresponding pages in rs and writes the result to w.
func AddWatermarksSliceMapFile ¶
func AddWatermarksSliceMapFile(inFile, outFile string, m map[int][]*pdfcpu.Watermark, conf *pdfcpu.Configuration) (err error)
AddWatermarksSliceMapFile adds watermarks to corresponding pages in m of inFile and writes the result to outFile.
func Booklet ¶
func Booklet(rs io.ReadSeeker, w io.Writer, imgFiles, selectedPages []string, nup *pdfcpu.NUp, conf *pdfcpu.Configuration) error
Booklet arranges PDF pages on larger sheets of paper and writes the result to w.
func BookletFile ¶
func BookletFile(inFiles []string, outFile string, selectedPages []string, nup *pdfcpu.NUp, conf *pdfcpu.Configuration) (err error)
BookletFile rearranges PDF pages or images into a booklet layout and writes the result to outFile.
func BookletFromImages ¶
func BookletFromImages(conf *pdfcpu.Configuration, imageFileNames []string, nup *pdfcpu.NUp) (*pdfcpu.Context, error)
BookletFromImages creates a booklet from images.
func ChangeOwnerPassword ¶
func ChangeOwnerPassword(rs io.ReadSeeker, w io.Writer, pwOld, pwNew string, conf *pdfcpu.Configuration) error
ChangeOwnerPassword reads a PDF stream from rs, changes the owner password and writes the encrypted PDF stream to w. A configuration containing the current passwords is required.
func ChangeOwnerPasswordFile ¶
func ChangeOwnerPasswordFile(inFile, outFile string, pwOld, pwNew string, conf *pdfcpu.Configuration) (err error)
ChangeOwnerPasswordFile reads inFile, changes the owner password and writes the result to outFile. A configuration containing the current passwords is required.
Example ¶
// Changing the owner password for an AES-256 encrypted file. conf := pdfcpu.NewAESConfiguration("upw", "opw", 256) ChangeOwnerPasswordFile("in.pdf", "", "opw", "opwNew", conf)
Output:
func ChangeUserPassword ¶
func ChangeUserPassword(rs io.ReadSeeker, w io.Writer, pwOld, pwNew string, conf *pdfcpu.Configuration) error
ChangeUserPassword reads a PDF stream from rs, changes the user password and writes the encrypted PDF stream to w. A configuration containing the current passwords is required.
func ChangeUserPasswordFile ¶
func ChangeUserPasswordFile(inFile, outFile string, pwOld, pwNew string, conf *pdfcpu.Configuration) (err error)
ChangeUserPasswordFile reads inFile, changes the user password and writes the result to outFile. A configuration containing the current passwords is required.
Example ¶
// Changing the user password for an AES-256 encrypted file. conf := pdfcpu.NewAESConfiguration("upw", "opw", 256) ChangeUserPasswordFile("in.pdf", "", "upw", "upwNew", conf)
Output:
func Collect ¶
func Collect(rs io.ReadSeeker, w io.Writer, selectedPages []string, conf *pdfcpu.Configuration) error
Collect creates a custom PDF page sequence for selected pages of rs and writes the result to w.
func CollectFile ¶
func CollectFile(inFile, outFile string, selectedPages []string, conf *pdfcpu.Configuration) (err error)
CollectFile creates a custom PDF page sequence for inFile and writes the result to outFile.
func CreateCheatSheetsUserFonts ¶
CreateCheatSheetsUserFonts creates single page PDF cheat sheets for installed user fonts.
func CreateFromJSON ¶
func CreateFromJSON(rd io.Reader, rs io.ReadSeeker, w io.Writer, conf *pdfcpu.Configuration) error
CreateFromJSONFile renders the PDF structure corresponding to rd to w. If rs == nil a new PDF file will be written to w. If infile exists it appends page content for existing pages and appends new pages including any empty pages needed in between.
func CreateFromJSONFile ¶
func CreateFromJSONFile(jsonFile, inFile, outFile string, conf *pdfcpu.Configuration) (err error)
CreateFromJSONFile renders the PDF structure corresponding to jsonFile to outFile. If inFile does not exist it creates a new PDF Context. If infile exists it appends page content for existing pages and appends new pages including any empty pages needed.
func CreatePDFFile ¶
CreatePDFFile creates a PDF file for an xRefTable and writes it to outFile.
func CreateUserFontDemoFiles ¶
CreateUserFontDemoFiles creates single page PDF for each Unicode plane covered.
func Crop ¶
func Crop(rs io.ReadSeeker, w io.Writer, selectedPages []string, b *pdfcpu.Box, conf *pdfcpu.Configuration) error
Crop adds crop boxes for selected pages of rs and writes result to w.
func CropFile ¶
func CropFile(inFile, outFile string, selectedPages []string, b *pdfcpu.Box, conf *pdfcpu.Configuration) error
CropFile adds crop boxes for selected pages of inFile and writes result to outFile.
func Decrypt ¶
func Decrypt(rs io.ReadSeeker, w io.Writer, conf *pdfcpu.Configuration) error
Decrypt reads a PDF stream from rs and writes the encrypted PDF stream to w. A configuration containing at least the current passwords is required.
func DecryptFile ¶
func DecryptFile(inFile, outFile string, conf *pdfcpu.Configuration) (err error)
DecryptFile decrypts inFile and writes the result to outFile. A configuration containing at least the current passwords is required.
Example ¶
// Decrypting an AES-256 encrypted file. conf := pdfcpu.NewAESConfiguration("upw", "opw", 256) DecryptFile("in.pdf", "", conf)
Output:
func DisableConfigDir ¶
func DisableConfigDir()
DisableConfigDir disables the configuration directory. Any needed default configuration will be loaded from configuration.go Since the config dir also contains the user font dir, this also limits font usage to the default core font set No user fonts will be available.
func Encrypt ¶
func Encrypt(rs io.ReadSeeker, w io.Writer, conf *pdfcpu.Configuration) error
Encrypt reads a PDF stream from rs and writes the encrypted PDF stream to w. A configuration containing at least the current passwords is required.
func EncryptFile ¶
func EncryptFile(inFile, outFile string, conf *pdfcpu.Configuration) (err error)
EncryptFile encrypts inFile and writes the result to outFile. A configuration containing at least the current passwords is required.
Example ¶
// Encrypting a file using AES-256. conf := pdfcpu.NewAESConfiguration("upw", "opw", 256) EncryptFile("in.pdf", "", conf)
Output:
func EnsureDefaultConfigAt ¶
EnsureDefaultConfigAt switches to the pdfcpu config dir located at path. If path/pdfcpu is not existent, it will be created including config.yml
func ExtractAttachments ¶
func ExtractAttachments(rs io.ReadSeeker, outDir string, fileNames []string, conf *pdfcpu.Configuration) error
ExtractAttachments extracts embedded files from a PDF context read from rs into outDir.
func ExtractAttachmentsFile ¶
func ExtractAttachmentsFile(inFile, outDir string, files []string, conf *pdfcpu.Configuration) error
ExtractAttachmentsFile extracts embedded files from a PDF context read from inFile into outDir.
Example ¶
// Extract 1 attachment from in.pdf into outDir. ExtractAttachmentsFile("in.pdf", "outDir", []string{"img.jpg"}, nil) // Extract all attachments from in.pdf into outDir ExtractAttachmentsFile("in.pdf", "outDir", nil, nil)
Output:
func ExtractAttachmentsRaw ¶
func ExtractAttachmentsRaw(rs io.ReadSeeker, outDir string, fileNames []string, conf *pdfcpu.Configuration) ([]pdfcpu.Attachment, error)
ExtractAttachmentsRaw extracts embedded files from a PDF context read from rs.
func ExtractContent ¶
func ExtractContent(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, conf *pdfcpu.Configuration) error
ExtractContent dumps "PDF source" files from rs into outDir for selected pages.
func ExtractContentFile ¶
func ExtractContentFile(inFile, outDir string, selectedPages []string, conf *pdfcpu.Configuration) error
ExtractContentFile dumps "PDF source" files from inFile into outDir for selected pages.
Example ¶
// Extract content for all pages in PDF syntax from in.pdf into outDir. ExtractContentFile("in.pdf", "outDir", nil, nil)
Output:
func ExtractFonts ¶
func ExtractFonts(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, conf *pdfcpu.Configuration) error
ExtractFonts dumps embedded fontfiles from rs into outDir for selected pages.
func ExtractFontsFile ¶
func ExtractFontsFile(inFile, outDir string, selectedPages []string, conf *pdfcpu.Configuration) error
ExtractFontsFile dumps embedded fontfiles from inFile into outDir for selected pages.
Example ¶
// Extract embedded fonts for pages 1-3 from in.pdf into outDir. ExtractFontsFile("in.pdf", "outDir", []string{"1-3"}, nil)
Output:
func ExtractImages ¶
func ExtractImages(rs io.ReadSeeker, selectedPages []string, digestImage func(pdfcpu.Image, bool, int) error, conf *pdfcpu.Configuration) error
ExtractImages extracts and digests embedded image resources from rs for selected pages.
func ExtractImagesFile ¶
func ExtractImagesFile(inFile, outDir string, selectedPages []string, conf *pdfcpu.Configuration) error
ExtractImagesFile dumps embedded image resources from inFile into outDir for selected pages.
Example ¶
// Extract embedded images from in.pdf into outDir. ExtractImagesFile("in.pdf", "outDir", nil, nil)
Output:
func ExtractImagesRaw ¶
func ExtractImagesRaw(rs io.ReadSeeker, selectedPages []string, conf *pdfcpu.Configuration) ([]pdfcpu.Image, error)
ExtractImagesRaw returns []pdfcpu.Image containing io.Readers for images contained in selectedPages. Beware of memory intensive returned slice.
func ExtractMetadata ¶
func ExtractMetadata(rs io.ReadSeeker, outDir, fileName string, conf *pdfcpu.Configuration) error
ExtractMetadata dumps all metadata dict entries for rs into outDir.
func ExtractMetadataFile ¶
func ExtractMetadataFile(inFile, outDir string, conf *pdfcpu.Configuration) error
ExtractMetadataFile dumps all metadata dict entries for inFile into outDir.
Example ¶
// Extract all metadata from in.pdf into outDir. ExtractMetadataFile("in.pdf", "outDir", nil)
Output:
func ExtractPages ¶
func ExtractPages(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, conf *pdfcpu.Configuration) error
ExtractPages generates single page PDF files from rs in outDir for selected pages.
func ExtractPagesFile ¶
func ExtractPagesFile(inFile, outDir string, selectedPages []string, conf *pdfcpu.Configuration) error
ExtractPagesFile generates single page PDF files from inFile in outDir for selected pages.
Example ¶
// Extract all even numbered pages from in.pdf into outDir. ExtractPagesFile("in.pdf", "outDir", []string{"even"}, nil)
Output:
func GetPermissions ¶
func GetPermissions(rs io.ReadSeeker, conf *pdfcpu.Configuration) (*int16, error)
GetPermissions returns the permissions for rs.
func GetPermissionsFile ¶
func GetPermissionsFile(inFile string, conf *pdfcpu.Configuration) (*int16, error)
GetPermissionsFile returns the permissions for inFile.
func HasWatermarks ¶
func HasWatermarks(rs io.ReadSeeker, conf *pdfcpu.Configuration) (bool, error)
HasWatermarks checks rs for watermarks.
func HasWatermarksFile ¶
func HasWatermarksFile(inFile string, conf *pdfcpu.Configuration) (bool, error)
HasWatermarksFile checks inFile for watermarks.
func ImageBookletConfig ¶
ImageBookletConfig returns an NUp configuration for Booklet-ing image files.
func ImageGridConfig ¶
ImageGridConfig returns a grid configuration for Grid-ing image files.
func ImageNUpConfig ¶
ImageNUpConfig returns an NUp configuration for Nup-ing image files.
func ImageWatermark ¶
func ImageWatermark(fileName, desc string, onTop, update bool, u pdfcpu.DisplayUnit) (*pdfcpu.Watermark, error)
ImageWatermark returns an image watermark configuration.
func ImageWatermarkForReader ¶
func ImageWatermarkForReader(r io.Reader, desc string, onTop, update bool, u pdfcpu.DisplayUnit) (*pdfcpu.Watermark, error)
ImageWatermarkForReader returns an image watermark configuration for r.
func ImportImages ¶
func ImportImages(rs io.ReadSeeker, w io.Writer, imgs []io.Reader, imp *pdfcpu.Import, conf *pdfcpu.Configuration) error
ImportImages appends PDF pages containing images to rs and writes the result to w. If rs == nil a new PDF file will be written to w.
func ImportImagesFile ¶
func ImportImagesFile(imgFiles []string, outFile string, imp *pdfcpu.Import, conf *pdfcpu.Configuration) (err error)
ImportImagesFile appends PDF pages containing images to outFile which will be created if necessary.
Example ¶
// Convert an image into a single page of out.pdf which will be created if necessary. // The page dimensions will match the image dimensions. // If out.pdf already exists, append a new page. // Use the default import configuration. ImportImagesFile([]string{"image.png"}, "out.pdf", nil, nil) // Import images by creating an A3 page for each image. // Images are page centered with 1.0 relative scaling. // Import an image as a new page of the existing out.pdf. imp, _ := Import("form:A3, pos:c, s:1.0", pdfcpu.POINTS) ImportImagesFile([]string{"a1.png", "a2.jpg", "a3.tiff"}, "out.pdf", imp, nil)
Output:
func Info ¶
func Info(rs io.ReadSeeker, selectedPages []string, conf *pdfcpu.Configuration) ([]string, error)
Info returns information about rs.
func InsertPages ¶
func InsertPages(rs io.ReadSeeker, w io.Writer, selectedPages []string, before bool, conf *pdfcpu.Configuration) error
InsertPages inserts a blank page before or after every page selected of rs and writes the result to w.
func InsertPagesFile ¶
func InsertPagesFile(inFile, outFile string, selectedPages []string, before bool, conf *pdfcpu.Configuration) (err error)
InsertPagesFile inserts a blank page before or after every inFile page selected and writes the result to w.
Example ¶
// Insert a blank page into in.pdf before page #3. InsertPagesFile("in.pdf", "", []string{"3"}, true, nil) // Insert a blank page into in.pdf after every page. InsertPagesFile("in.pdf", "", nil, false, nil)
Output:
func InstallFonts ¶
InstallFonts installs true type fonts for embedding.
func ListAnnotations ¶
func ListAnnotations(rs io.ReadSeeker, selectedPages []string, conf *pdfcpu.Configuration) (int, []string, error)
ListAnnotations returns a list of page annotations of rs.
func ListAnnotationsFile ¶
func ListAnnotationsFile(inFile string, selectedPages []string, conf *pdfcpu.Configuration) (int, []string, error)
ListAnnotationsFile returns a list of page annotations of inFile.
func ListAttachments ¶
func ListAttachments(rs io.ReadSeeker, conf *pdfcpu.Configuration) ([]string, error)
ListAttachments returns a list of embedded file attachments of rs with optional description.
func ListAttachmentsCompact ¶
func ListAttachmentsCompact(rs io.ReadSeeker, conf *pdfcpu.Configuration) ([]string, error)
ListAttachmentsCompact returns a list of embedded file attachments of rs w/o optional description.
func ListAttachmentsCompactFile ¶
func ListAttachmentsCompactFile(inFile string, conf *pdfcpu.Configuration) ([]string, error)
ListAttachmentsCompactFile returns a list of embedded file attachments of inFile w/o optional description.
func ListAttachmentsFile ¶
func ListAttachmentsFile(inFile string, conf *pdfcpu.Configuration) ([]string, error)
ListAttachmentsFile returns a list of embedded file attachments of inFile with optional description.
Example ¶
// Output a list of attachments of in.pdf. list, _ := ListAttachmentsFile("in.pdf", nil) for _, s := range list { fmt.Println(s) }
Output:
func ListBoxes ¶
func ListBoxes(rs io.ReadSeeker, selectedPages []string, pb *pdfcpu.PageBoundaries, conf *pdfcpu.Configuration) ([]string, error)
ListBoxes returns a list of page boundaries for selected pages of rs.
func ListBoxesFile ¶
func ListBoxesFile(inFile string, selectedPages []string, pb *pdfcpu.PageBoundaries, conf *pdfcpu.Configuration) ([]string, error)
ListBoxesFile returns a list of page boundaries for selected pages of inFile.
func ListImages ¶
func ListImages(rs io.ReadSeeker, selectedPages []string, conf *pdfcpu.Configuration) ([]string, error)
ListImages returns a list of embedded images of rs.
func ListImagesFile ¶
func ListImagesFile(inFiles []string, selectedPages []string, conf *pdfcpu.Configuration) ([]string, error)
ListImagesFile returns a list of embedded images of inFile.
func ListKeywords ¶
func ListKeywords(rs io.ReadSeeker, conf *pdf.Configuration) ([]string, error)
ListKeywords returns the keyword list of rs.
func ListKeywordsFile ¶
func ListKeywordsFile(inFile string, conf *pdf.Configuration) ([]string, error)
ListKeywordsFile returns the keyword list of inFile.
func ListPermissions ¶
func ListPermissions(rs io.ReadSeeker, conf *pdfcpu.Configuration) ([]string, error)
ListPermissions returns a list of user access permissions.
func ListPermissionsFile ¶
func ListPermissionsFile(inFile string, conf *pdfcpu.Configuration) ([]string, error)
ListPermissionsFile returns a list of user access permissions for inFile.
Example ¶
// Output the current permissions of in.pdf. list, _ := ListPermissionsFile("in.pdf", nil) for _, s := range list { fmt.Println(s) }
Output:
func ListProperties ¶
func ListProperties(rs io.ReadSeeker, conf *pdf.Configuration) ([]string, error)
ListProperties returns the property list of rs.
func ListPropertiesFile ¶
func ListPropertiesFile(inFile string, conf *pdf.Configuration) ([]string, error)
ListPropertiesFile returns the property list of inFile.
func LoadConfiguration ¶
func LoadConfiguration() *pdfcpu.Configuration
LoadConfiguration locates and loads the default configuration and also loads installed user fonts.
func Merge ¶
func Merge(rsc []io.ReadSeeker, w io.Writer, conf *pdfcpu.Configuration) error
Merge merges a sequence of PDF streams and writes the result to w.
func MergeAppendFile ¶
func MergeAppendFile(inFiles []string, outFile string, conf *pdfcpu.Configuration) (err error)
MergeAppendFile merges a sequence of inFiles and writes the result to outFile. This operation corresponds to file concatenation in the order specified by inFiles. If outFile already exists, inFiles will be appended.
Example ¶
// Merge inFiles by concatenation in the order specified and write the result to out.pdf. // If out.pdf already exists it will be preserved and serves as the beginning of the merge result. inFiles := []string{"in1.pdf", "in2.pdf"} MergeAppendFile(inFiles, "out.pdf", nil)
Output:
func MergeCreateFile ¶
func MergeCreateFile(inFiles []string, outFile string, conf *pdfcpu.Configuration) error
MergeCreateFile merges a sequence of inFiles and writes the result to outFile. This operation corresponds to file concatenation in the order specified by inFiles. The first entry of inFiles serves as the destination context where all remaining files get merged into.
Example ¶
// Merge inFiles by concatenation in the order specified and write the result to out.pdf. // out.pdf will be overwritten. inFiles := []string{"in1.pdf", "in2.pdf"} MergeCreateFile(inFiles, "out.pdf", nil)
Output:
func NUp ¶
func NUp(rs io.ReadSeeker, w io.Writer, imgFiles, selectedPages []string, nup *pdfcpu.NUp, conf *pdfcpu.Configuration) error
NUp rearranges PDF pages or images into page grids and writes the result to w. Either rs or imgFiles will be used.
func NUpFile ¶
func NUpFile(inFiles []string, outFile string, selectedPages []string, nup *pdfcpu.NUp, conf *pdfcpu.Configuration) (err error)
NUpFile rearranges PDF pages or images into page grids and writes the result to outFile.
Example ¶
// 4-Up in.pdf and write result to out.pdf. nup, _ := PDFNUpConfig(4, "") inFiles := []string{"in.pdf"} NUpFile(inFiles, "out.pdf", nil, nup, nil) // 9-Up a sequence of images using format Tabloid w/o borders and no margins. nup, _ = ImageNUpConfig(9, "f:Tabloid, b:off, m:0") inFiles = []string{"in1.png", "in2.jpg", "in3.tiff"} NUpFile(inFiles, "out.pdf", nil, nup, nil) // TestGridFromPDF nup, _ = PDFGridConfig(1, 3, "f:LegalL") inFiles = []string{"in.pdf"} NUpFile(inFiles, "out.pdf", nil, nup, nil) // TestGridFromImages nup, _ = ImageGridConfig(4, 2, "d:500 500, m:20, b:off") inFiles = []string{"in1.png", "in2.jpg", "in3.tiff"} NUpFile(inFiles, "out.pdf", nil, nup, nil)
Output:
func NUpFromImage ¶
func NUpFromImage(conf *pdfcpu.Configuration, imageFileNames []string, nup *pdfcpu.NUp) (*pdfcpu.Context, error)
NUpFromImage creates a single page n-up PDF for one image or a sequence of n-up pages for more than one image.
func Optimize ¶
func Optimize(rs io.ReadSeeker, w io.Writer, conf *pdfcpu.Configuration) error
Optimize reads a PDF stream from rs and writes the optimized PDF stream to w.
func OptimizeContext ¶
OptimizeContext optimizes ctx.
func OptimizeFile ¶
func OptimizeFile(inFile, outFile string, conf *pdfcpu.Configuration) (err error)
OptimizeFile reads inFile and writes the optimized PDF to outFile. If outFile is not provided then inFile gets overwritten which leads to the same result as when inFile equals outFile.
Example ¶
conf := pdfcpu.NewDefaultConfiguration() // Set passwords for encrypted files. conf.UserPW = "upw" conf.OwnerPW = "opw" // Configure end of line sequence for writing. conf.Eol = pdfcpu.EolLF // Create an optimized version of in.pdf and write it to out.pdf. OptimizeFile("in.pdf", "out.pdf", conf) // Create an optimized version of inFile. // If you want to modify the original file, pass an empty string for outFile. // Use nil for a default configuration. OptimizeFile("in.pdf", "", nil)
Output:
func PDFBookletConfig ¶
PDFBookletConfig returns an NUp configuration for Booklet-ing PDF files.
func PDFGridConfig ¶
PDFGridConfig returns a grid configuration for Grid-ing PDF files.
func PDFNUpConfig ¶
PDFNUpConfig returns an NUp configuration for Nup-ing PDF files.
func PDFWatermark ¶
func PDFWatermark(fileName, desc string, onTop, update bool, u pdfcpu.DisplayUnit) (*pdfcpu.Watermark, error)
PDFWatermark returns a PDF watermark configuration.
func PageBoundaries ¶
func PageBoundaries(s string, unit pdfcpu.DisplayUnit) (*pdfcpu.PageBoundaries, error)
PageBoundaries parses a list of box definitions and assignments.
func PageBoundariesFromBoxList ¶
func PageBoundariesFromBoxList(s string) (*pdfcpu.PageBoundaries, error)
PageBoundariesFromBoxList parses a list of box types.
func PageCount ¶
func PageCount(rs io.ReadSeeker, conf *pdfcpu.Configuration) (int, error)
PageCount returns rs's page count.
func PageCountFile ¶
PageCountFile returns inFile's page count.
func PageDims ¶
func PageDims(rs io.ReadSeeker, conf *pdfcpu.Configuration) ([]pdfcpu.Dim, error)
PageDims returns a sorted slice of mediaBox dimensions for rs.
func PageDimsFile ¶
PageDimsFile returns a sorted slice of mediaBox dimensions for inFile.
func PagesForPageCollection ¶
PagesForPageCollection returns a slice of page numbers for a page collection. Any page number in any order any number of times allowed.
func PagesForPageRange ¶
PagesForPageRange returns a slice of page numbers for a page range.
func PagesForPageSelection ¶
func PagesForPageSelection(pageCount int, pageSelection []string, ensureAllforNone bool) (pdf.IntSet, error)
PagesForPageSelection ensures a set of page numbers for an ascending page sequence where each page number may appear only once.
func ParsePageSelection ¶
ParsePageSelection ensures a correct page selection expression.
func ReadContext ¶
func ReadContext(rs io.ReadSeeker, conf *pdfcpu.Configuration) (*pdfcpu.Context, error)
ReadContext uses an io.ReadSeeker to build an internal structure holding its cross reference table aka the Context.
func ReadContextFile ¶
ReadContextFile returns inFile's validated context.
func RemoveAnnotations ¶
func RemoveAnnotations(rs io.ReadSeeker, w io.Writer, selectedPages, ids []string, objNrs []int, conf *pdfcpu.Configuration) error
RemoveAnnotations removes annotations for selected pages by id and object number from a PDF context read from rs and writes the result to w.
func RemoveAnnotationsAsIncrement ¶
func RemoveAnnotationsAsIncrement(rws io.ReadWriteSeeker, selectedPages, ids []string, objNrs []int, conf *pdfcpu.Configuration) error
RemoveAnnotationsAsIncrement removes annotations for selected pages by ids and object number from a PDF context read from rs and writes out a PDF increment.
func RemoveAnnotationsFile ¶
func RemoveAnnotationsFile(inFile, outFile string, selectedPages, ids []string, objNrs []int, conf *pdfcpu.Configuration, incr bool) (err error)
RemoveAnnotationsFile removes annotations for selected pages by id and object number from a PDF context read from inFile and writes the result to outFile.
func RemoveAttachments ¶
func RemoveAttachments(rs io.ReadSeeker, w io.Writer, files []string, conf *pdfcpu.Configuration) error
RemoveAttachments deletes embedded files from a PDF context read from rs and writes the result to w.
func RemoveAttachmentsFile ¶
func RemoveAttachmentsFile(inFile, outFile string, files []string, conf *pdfcpu.Configuration) (err error)
RemoveAttachmentsFile deletes embedded files from a PDF context read from inFile and writes the result to outFile.
Example ¶
// Remove 1 attachment from in.pdf. RemoveAttachmentsFile("in.pdf", "", []string{"img.jpg"}, nil) // Remove all attachments from in.pdf RemoveAttachmentsFile("in.pdf", "", nil, nil)
Output:
func RemoveBoxes ¶
func RemoveBoxes(rs io.ReadSeeker, w io.Writer, selectedPages []string, pb *pdfcpu.PageBoundaries, conf *pdfcpu.Configuration) error
RemoveBoxes removes page boundaries as specified in pb for selected pages of rs and writes result to w.
func RemoveBoxesFile ¶
func RemoveBoxesFile(inFile, outFile string, selectedPages []string, pb *pdfcpu.PageBoundaries, conf *pdfcpu.Configuration) error
RemoveBoxesFile removes page boundaries as specified in pb for selected pages of inFile and writes result to outFile.
func RemoveKeywords ¶
func RemoveKeywords(rs io.ReadSeeker, w io.Writer, keywords []string, conf *pdf.Configuration) error
RemoveKeywords deletes embedded files from a PDF context read from rs and writes the result to w.
func RemoveKeywordsFile ¶
func RemoveKeywordsFile(inFile, outFile string, keywords []string, conf *pdf.Configuration) (err error)
RemoveKeywordsFile deletes embedded files from a PDF context read from inFile and writes the result to outFile.
func RemovePages ¶
func RemovePages(rs io.ReadSeeker, w io.Writer, selectedPages []string, conf *pdfcpu.Configuration) error
RemovePages removes selected pages from rs and writes the result to w.
func RemovePagesFile ¶
func RemovePagesFile(inFile, outFile string, selectedPages []string, conf *pdfcpu.Configuration) (err error)
RemovePagesFile removes selected inFile pages and writes the result to outFile..
Example ¶
// Remove pages 2 and 8 of in.pdf. RemovePagesFile("in.pdf", "", []string{"2", "8"}, nil) // Remove first 2 pages of in.pdf. RemovePagesFile("in.pdf", "", []string{"-2"}, nil) // Remove all pages >= 10 of in.pdf. RemovePagesFile("in.pdf", "", []string{"10-"}, nil)
Output:
func RemoveProperties ¶
func RemoveProperties(rs io.ReadSeeker, w io.Writer, properties []string, conf *pdf.Configuration) error
RemoveProperties deletes embedded files from a PDF context read from rs and writes the result to w.
func RemovePropertiesFile ¶
func RemovePropertiesFile(inFile, outFile string, properties []string, conf *pdf.Configuration) (err error)
RemovePropertiesFile deletes embedded files from a PDF context read from inFile and writes the result to outFile.
func RemoveWatermarks ¶
func RemoveWatermarks(rs io.ReadSeeker, w io.Writer, selectedPages []string, conf *pdfcpu.Configuration) error
RemoveWatermarks removes watermarks from all pages selected in rs and writes the result to w.
func RemoveWatermarksFile ¶
func RemoveWatermarksFile(inFile, outFile string, selectedPages []string, conf *pdfcpu.Configuration) (err error)
RemoveWatermarksFile removes watermarks from all selected pages of inFile and writes the result to outFile.
Example ¶
// Add a "Demo" stamp to all pages of in.pdf along the diagonal running from lower left to upper right. onTop := true update := false wm, _ := TextWatermark("Demo", "", onTop, update, pdfcpu.POINTS) AddWatermarksFile("in.pdf", "", nil, wm, nil) // Update stamp for correction: update = true wm, _ = TextWatermark("Confidential", "", onTop, update, pdfcpu.POINTS) AddWatermarksFile("in.pdf", "", nil, wm, nil) // Add another watermark on top of page 1 wm, _ = TextWatermark("Footer stamp", "c:.5 1 1, pos:bc", onTop, update, pdfcpu.POINTS) AddWatermarksFile("in.pdf", "", nil, wm, nil) // Remove watermark on page 1 RemoveWatermarksFile("in.pdf", "", []string{"1"}, nil) // Remove all watermarks RemoveWatermarksFile("in.pdf", "", nil, nil)
Output:
func Rotate ¶
func Rotate(rs io.ReadSeeker, w io.Writer, rotation int, selectedPages []string, conf *pdfcpu.Configuration) error
Rotate rotates selected pages of rs clockwise by rotation degrees and writes the result to w.
func RotateFile ¶
func RotateFile(inFile, outFile string, rotation int, selectedPages []string, conf *pdfcpu.Configuration) (err error)
RotateFile rotates selected pages of inFile clockwise by rotation degrees and writes the result to outFile.
Example ¶
// Rotate all pages of in.pdf, clockwise by 90 degrees and write the result to out.pdf. RotateFile("in.pdf", "out.pdf", 90, nil, nil) // Rotate the first page of in.pdf by 180 degrees. // If you want to modify the original file, pass an empty string as outFile. RotateFile("in.pdf", "", 180, []string{"1"}, nil)
Output:
func SetPermissions ¶
func SetPermissions(rs io.ReadSeeker, w io.Writer, conf *pdfcpu.Configuration) error
SetPermissions sets user access permissions. inFile has to be encrypted. A configuration containing the current passwords is required.
func SetPermissionsFile ¶
func SetPermissionsFile(inFile, outFile string, conf *pdfcpu.Configuration) (err error)
SetPermissionsFile sets inFile's user access permissions. inFile has to be encrypted. A configuration containing the current passwords is required.
Example ¶
// Setting all permissions for the AES-256 encrypted in.pdf. conf := pdfcpu.NewAESConfiguration("upw", "opw", 256) conf.Permissions = pdfcpu.PermissionsAll SetPermissionsFile("in.pdf", "", conf) // Restricting permissions for the AES-256 encrypted in.pdf. conf = pdfcpu.NewAESConfiguration("upw", "opw", 256) conf.Permissions = pdfcpu.PermissionsNone SetPermissionsFile("in.pdf", "", conf)
Output:
func Split ¶
func Split(rs io.ReadSeeker, outDir, fileName string, span int, conf *pdfcpu.Configuration) error
Split generates a sequence of PDF files in outDir for the PDF stream read from rs obeying given split span. If span == 1 splitting results in single page PDFs. If span == 0 we split along given bookmarks (level 1 only). Default span: 1
func SplitFile ¶
func SplitFile(inFile, outDir string, span int, conf *pdfcpu.Configuration) error
SplitFile generates a sequence of PDF files in outDir for inFile obeying given split span. If span == 1 splitting results in single page PDFs. If span == 0 we split along given bookmarks (level 1 only). Default span: 1
Example ¶
// Create single page PDFs for in.pdf in outDir using the default configuration. SplitFile("in.pdf", "outDir", 1, nil) // Create dual page PDFs for in.pdf in outDir using the default configuration. SplitFile("in.pdf", "outDir", 2, nil) // Create a sequence of PDFs representing bookmark secions. SplitFile("in.pdf", "outDir", 0, nil)
Output:
func TextWatermark ¶
func TextWatermark(text, desc string, onTop, update bool, u pdfcpu.DisplayUnit) (*pdfcpu.Watermark, error)
TextWatermark returns a text watermark configuration.
func Trim ¶
func Trim(rs io.ReadSeeker, w io.Writer, selectedPages []string, conf *pdfcpu.Configuration) error
Trim generates a trimmed version of rs containing all selected pages and writes the result to w.
func TrimFile ¶
func TrimFile(inFile, outFile string, selectedPages []string, conf *pdfcpu.Configuration) (err error)
TrimFile generates a trimmed version of inFile containing all selected pages and writes the result to outFile.
Example ¶
// Create a trimmed version of in.pdf containing odd page numbers only. TrimFile("in.pdf", "outFile", []string{"odd"}, nil) // Create a trimmed version of in.pdf containing the first two pages only. // If you want to modify the original file, pass an empty string for outFile. TrimFile("in.pdf", "", []string{"1-2"}, nil)
Output:
func UpdateImageWatermarksFile ¶
func UpdateImageWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, fileName, desc string, conf *pdfcpu.Configuration) error
UpdateImageWatermarksFile adds image stamps/watermarks to all selected pages of inFile and writes the result to outFile.
func UpdatePDFWatermarksFile ¶
func UpdatePDFWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, fileName, desc string, conf *pdfcpu.Configuration) error
UpdatePDFWatermarksFile adds PDF stamps/watermarks to all selected pages of inFile and writes the result to outFile.
func UpdateTextWatermarksFile ¶
func UpdateTextWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, text, desc string, conf *pdfcpu.Configuration) error
UpdateTextWatermarksFile adds text stamps/watermarks to all selected pages of inFile and writes the result to outFile.
func Validate ¶
func Validate(rs io.ReadSeeker, conf *pdfcpu.Configuration) error
Validate validates a PDF stream read from rs.
func ValidateContext ¶
ValidateContext validates ctx.
func ValidateFile ¶
func ValidateFile(inFile string, conf *pdfcpu.Configuration) error
ValidateFile validates inFile.
Example ¶
// Use the default configuration to validate in.pdf. ValidateFile("in.pdf", nil)
Output:
func ValidateFiles ¶
func ValidateFiles(inFiles []string, conf *pdfcpu.Configuration) error
ValidateFiles validates inFiles.
func WatermarkContext ¶
WatermarkContext applies wm for selected pages to ctx.
func WriteContext ¶
WriteContext writes ctx to w.
func WriteContextFile ¶
WriteContextFile writes ctx to outFile.
Types ¶
type MergeError ¶
func (*MergeError) Error ¶
func (e *MergeError) Error() string
type PageSpan ¶
func SplitRaw ¶
func SplitRaw(rs io.ReadSeeker, span int, conf *pdfcpu.Configuration) ([]*PageSpan, error)
SplitRaw returns page spans for the PDF stream read from rs obeying given split span. If span == 1 splitting results in single page PDFs. If span == 0 we split along given bookmarks (level 1 only). Default span: 1
type ReadSeekerCloser ¶
type ReadSeekerCloser interface { io.ReadSeeker io.Closer }
ReadSeekerCloser combines io.ReadSeeker and io.Closer