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 ¶
- Variables
- func AddAnnotations(rs io.ReadSeeker, w io.Writer, selectedPages []string, ...) error
- func AddAnnotationsAsIncrement(rws io.ReadWriteSeeker, selectedPages []string, ar model.AnnotationRenderer, ...) error
- func AddAnnotationsFile(inFile, outFile string, selectedPages []string, ar model.AnnotationRenderer, ...) (err error)
- func AddAnnotationsMap(rs io.ReadSeeker, w io.Writer, m map[int][]model.AnnotationRenderer, ...) error
- func AddAnnotationsMapAsIncrement(rws io.ReadWriteSeeker, m map[int][]model.AnnotationRenderer, ...) error
- func AddAnnotationsMapFile(inFile, outFile string, m map[int][]model.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 *model.Configuration) (err error)
- func AddBookmarks(rs io.ReadSeeker, w io.Writer, bms []pdfcpu.Bookmark, replace bool, ...) error
- func AddBookmarksFile(inFile, outFile string, bms []pdfcpu.Bookmark, replace bool, ...) (err error)
- func AddBoxes(rs io.ReadSeeker, w io.Writer, selectedPages []string, ...) error
- func AddBoxesFile(inFile, outFile string, selectedPages []string, pb *model.PageBoundaries, ...) (err 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 *model.Configuration) error
- func AddKeywordsFile(inFile, outFile string, files []string, conf *model.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, ...) (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 *model.Watermark, ...) error
- func AddWatermarksFile(inFile, outFile string, selectedPages []string, wm *model.Watermark, ...) (err error)
- func AddWatermarksMap(rs io.ReadSeeker, w io.Writer, m map[int]*model.Watermark, ...) error
- func AddWatermarksMapFile(inFile, outFile string, m map[int]*model.Watermark, conf *model.Configuration) (err error)
- func AddWatermarksSliceMap(rs io.ReadSeeker, w io.Writer, m map[int][]*model.Watermark, ...) error
- func AddWatermarksSliceMapFile(inFile, outFile string, m map[int][]*model.Watermark, ...) (err error)
- func Annotations(rs io.ReadSeeker, selectedPages []string, conf *model.Configuration) (map[int]model.PgAnnots, error)
- func Attachments(rs io.ReadSeeker, conf *model.Configuration) ([]model.Attachment, error)
- func Booklet(rs io.ReadSeeker, w io.Writer, imgFiles, selectedPages []string, ...) error
- func BookletFile(inFiles []string, outFile string, selectedPages []string, nup *model.NUp, ...) (err error)
- func BookletFromImages(conf *model.Configuration, imageFileNames []string, nup *model.NUp) (*model.Context, error)
- func Bookmarks(rs io.ReadSeeker, conf *model.Configuration) ([]pdfcpu.Bookmark, error)
- func Box(s string, u types.DisplayUnit) (*model.Box, error)
- func Boxes(rs io.ReadSeeker, selectedPages []string, conf *model.Configuration) ([]model.PageBoundaries, error)
- func ChangeOwnerPassword(rs io.ReadSeeker, w io.Writer, pwOld, pwNew string, conf *model.Configuration) error
- func ChangeOwnerPasswordFile(inFile, outFile string, pwOld, pwNew string, conf *model.Configuration) (err error)
- func ChangeUserPassword(rs io.ReadSeeker, w io.Writer, pwOld, pwNew string, conf *model.Configuration) error
- func ChangeUserPasswordFile(inFile, outFile string, pwOld, pwNew string, conf *model.Configuration) (err error)
- func Collect(rs io.ReadSeeker, w io.Writer, selectedPages []string, ...) error
- func CollectFile(inFile, outFile string, selectedPages []string, conf *model.Configuration) (err error)
- func Create(rs io.ReadSeeker, rd io.Reader, w io.Writer, conf *model.Configuration) error
- func CreateCheatSheetsUserFonts(fontNames []string) error
- func CreateFile(inFilePDF, inFileJSON, outFilePDF string, conf *model.Configuration) (err error)
- func CreatePDFFile(xRefTable *model.XRefTable, outFile string, conf *model.Configuration) error
- func CreateUserFontDemoFiles(dir, fn string) error
- func Crop(rs io.ReadSeeker, w io.Writer, selectedPages []string, b *model.Box, ...) error
- func CropFile(inFile, outFile string, selectedPages []string, b *model.Box, ...) (err error)
- func Cut(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, ...) error
- func CutFile(inFile, outDir, outFile string, selectedPages []string, cut *model.Cut, ...) error
- func Decrypt(rs io.ReadSeeker, w io.Writer, conf *model.Configuration) error
- func DecryptFile(inFile, outFile string, conf *model.Configuration) (err error)
- func DisableConfigDir()
- func DumpObject(rs io.ReadSeeker, mode, objNr int, conf *model.Configuration) error
- func DumpObjectFile(inFile string, mode, objNr int, conf *model.Configuration) error
- func Encrypt(rs io.ReadSeeker, w io.Writer, conf *model.Configuration) error
- func EncryptFile(inFile, outFile string, conf *model.Configuration) (err error)
- func EnsureDefaultConfigAt(path string) error
- func ExportBookmarksFile(inFilePDF, outFileJSON string, conf *model.Configuration) (err error)
- func ExportBookmarksJSON(rs io.ReadSeeker, w io.Writer, source string, conf *model.Configuration) error
- func ExportForm(rs io.ReadSeeker, source string, conf *model.Configuration) (*form.FormGroup, error)
- func ExportFormFile(inFilePDF, outFileJSON string, conf *model.Configuration) (err error)
- func ExportFormJSON(rs io.ReadSeeker, w io.Writer, source string, conf *model.Configuration) error
- func ExtractAttachments(rs io.ReadSeeker, outDir string, fileNames []string, conf *model.Configuration) error
- func ExtractAttachmentsFile(inFile, outDir string, files []string, conf *model.Configuration) error
- func ExtractAttachmentsRaw(rs io.ReadSeeker, outDir string, fileNames []string, conf *model.Configuration) ([]model.Attachment, error)
- func ExtractContent(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, ...) error
- func ExtractContentFile(inFile, outDir string, selectedPages []string, conf *model.Configuration) error
- func ExtractFonts(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, ...) error
- func ExtractFontsFile(inFile, outDir string, selectedPages []string, conf *model.Configuration) error
- func ExtractImages(rs io.ReadSeeker, selectedPages []string, ...) error
- func ExtractImagesFile(inFile, outDir string, selectedPages []string, conf *model.Configuration) error
- func ExtractImagesRaw(rs io.ReadSeeker, selectedPages []string, conf *model.Configuration) ([]map[int]model.Image, error)
- func ExtractMetadata(rs io.ReadSeeker, outDir, fileName string, conf *model.Configuration) error
- func ExtractMetadataFile(inFile, outDir string, conf *model.Configuration) error
- func ExtractPage(ctx *model.Context, pageNr int) (io.Reader, error)
- func ExtractPages(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, ...) error
- func ExtractPagesFile(inFile, outDir string, selectedPages []string, conf *model.Configuration) error
- func FillForm(rs io.ReadSeeker, rd io.Reader, w io.Writer, conf *model.Configuration) error
- func FillFormFile(inFilePDF, inFileJSON, outFilePDF string, conf *model.Configuration) (err error)
- func FormFields(rs io.ReadSeeker, conf *model.Configuration) ([]form.Field, error)
- func GetPermissions(rs io.ReadSeeker, conf *model.Configuration) (*int16, error)
- func GetPermissionsFile(inFile string, conf *model.Configuration) (*int16, error)
- func HasWatermarks(rs io.ReadSeeker, conf *model.Configuration) (bool, error)
- func HasWatermarksFile(inFile string, conf *model.Configuration) (bool, error)
- 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 ImageWatermark(fileName, desc string, onTop, update bool, u types.DisplayUnit) (*model.Watermark, error)
- func ImageWatermarkForReader(r io.Reader, desc string, onTop, update bool, u types.DisplayUnit) (*model.Watermark, error)
- func Images(rs io.ReadSeeker, selectedPages []string, conf *model.Configuration) ([]map[int]model.Image, error)
- func Import(s string, u types.DisplayUnit) (*pdfcpu.Import, error)
- func ImportBookmarks(rs io.ReadSeeker, rd io.Reader, w io.Writer, replace bool, ...) error
- func ImportBookmarksFile(inFilePDF, inFileJSON, outFilePDF string, replace bool, ...) (err 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 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 Keywords(rs io.ReadSeeker, conf *model.Configuration) ([]string, error)
- func ListFonts() ([]string, error)
- func ListPageLayout(rs io.ReadSeeker, conf *model.Configuration) ([]string, error)
- func ListPageLayoutFile(inFile string, conf *model.Configuration) ([]string, error)
- func ListPageMode(rs io.ReadSeeker, conf *model.Configuration) ([]string, error)
- func ListPageModeFile(inFile string, conf *model.Configuration) ([]string, error)
- func ListViewerPreferences(rs io.ReadSeeker, all bool, conf *model.Configuration) ([]string, error)
- func ListViewerPreferencesFile(inFile string, all, json bool, conf *model.Configuration) ([]string, error)
- func ListViewerPreferencesFileJSON(inFile string, all bool, conf *model.Configuration) ([]string, error)
- func LoadConfiguration() *model.Configuration
- func LockFormFields(rs io.ReadSeeker, w io.Writer, fieldIDsOrNames []string, ...) error
- func LockFormFieldsFile(inFile, outFile string, fieldIDsOrNames []string, conf *model.Configuration) (err error)
- func Merge(destFile string, inFiles []string, w io.Writer, conf *model.Configuration, ...) error
- func MergeAppendFile(inFiles []string, outFile string, dividerPage bool, conf *model.Configuration) (err error)
- func MergeCreateFile(inFiles []string, outFile string, dividerPage bool, conf *model.Configuration) (err error)
- func MergeCreateZip(rs1, rs2 io.ReadSeeker, w io.Writer, conf *model.Configuration) error
- func MergeCreateZipFile(inFile1, inFile2, outFile string, conf *model.Configuration) (err error)
- func MergeRaw(rsc []io.ReadSeeker, w io.Writer, dividerPage bool, conf *model.Configuration) error
- func MultiFillForm(inFilePDF string, rd io.Reader, outDir, fileName string, ...) error
- func MultiFillFormFile(inFilePDF, inFileData, outDir, outFilePDF string, merge bool, ...) (err error)
- func NDown(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, n int, ...) error
- func NDownFile(inFile, outDir, outFile string, selectedPages []string, n int, cut *model.Cut, ...) error
- func NUp(rs io.ReadSeeker, w io.Writer, imgFiles, selectedPages []string, ...) error
- func NUpFile(inFiles []string, outFile string, selectedPages []string, nup *model.NUp, ...) (err error)
- func NUpFromImage(conf *model.Configuration, imageFileNames []string, nup *model.NUp) (*model.Context, error)
- func Optimize(rs io.ReadSeeker, w io.Writer, conf *model.Configuration) error
- func OptimizeContext(ctx *model.Context) error
- func OptimizeFile(inFile, outFile string, conf *model.Configuration) (err 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 PDFInfo(rs io.ReadSeeker, fileName string, selectedPages []string, ...) (*pdfcpu.PDFInfo, error)
- func PDFMultiWatermarkForReadSeeker(rs io.ReadSeeker, startPageNrSrc, startPageNrDest int, desc string, ...) (*model.Watermark, error)
- func PDFNUpConfig(val int, desc string, conf *model.Configuration) (*model.NUp, error)
- func PDFWatermark(fileName, desc string, onTop, update bool, u types.DisplayUnit) (*model.Watermark, error)
- func PDFWatermarkForReadSeeker(rs io.ReadSeeker, pageNrSrc int, desc string, onTop, update bool, ...) (*model.Watermark, error)
- func PageBoundaries(s string, unit types.DisplayUnit) (*model.PageBoundaries, error)
- func PageBoundariesFromBoxList(s string) (*model.PageBoundaries, error)
- func PageCount(rs io.ReadSeeker, conf *model.Configuration) (int, error)
- func PageCountFile(inFile string) (int, error)
- func PageDims(rs io.ReadSeeker, conf *model.Configuration) ([]types.Dim, error)
- func PageDimsFile(inFile string) ([]types.Dim, error)
- func PageLayout(rs io.ReadSeeker, conf *model.Configuration) (*model.PageLayout, error)
- func PageLayoutFile(inFile string, conf *model.Configuration) (*model.PageLayout, error)
- func PageMode(rs io.ReadSeeker, conf *model.Configuration) (*model.PageMode, error)
- func PageModeFile(inFile string, conf *model.Configuration) (*model.PageMode, error)
- func PagesForPageCollection(pageCount int, pageSelection []string) ([]int, error)
- func PagesForPageRange(from, thru int) []int
- func PagesForPageSelection(pageCount int, pageSelection []string, ensureAllforNone bool, log bool) (types.IntSet, error)
- func ParsePageSelection(s string) ([]string, error)
- func Permissions(rs io.ReadSeeker, conf *model.Configuration) (int, error)
- func Poster(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, ...) error
- func PosterFile(inFile, outDir, outFile string, selectedPages []string, cut *model.Cut, ...) error
- func Properties(rs io.ReadSeeker, conf *model.Configuration) (map[string]string, error)
- func ReadAndValidate(rs io.ReadSeeker, conf *model.Configuration) (ctx *model.Context, err error)
- func ReadContext(rs io.ReadSeeker, conf *model.Configuration) (*model.Context, error)
- func ReadContextFile(inFile string) (*model.Context, error)
- func ReadValidateAndOptimize(rs io.ReadSeeker, conf *model.Configuration) (ctx *model.Context, err error)
- func RemainingPagesForPageRemoval(pageCount int, pageSelection []string, log bool) (types.IntSet, error)
- func RemoveAnnotations(rs io.ReadSeeker, w io.Writer, selectedPages, idsAndTypes []string, ...) error
- func RemoveAnnotationsAsIncrement(rws io.ReadWriteSeeker, selectedPages, idsAndTypes []string, objNrs []int, ...) error
- func RemoveAnnotationsFile(inFile, outFile string, selectedPages, idsAndTypes []string, objNrs []int, ...) (err error)
- func RemoveAttachments(rs io.ReadSeeker, w io.Writer, files []string, conf *model.Configuration) error
- func RemoveAttachmentsFile(inFile, outFile string, files []string, conf *model.Configuration) (err error)
- func RemoveBookmarks(rs io.ReadSeeker, w io.Writer, conf *model.Configuration) error
- func RemoveBookmarksFile(inFile, outFile string, conf *model.Configuration) (err error)
- func RemoveBoxes(rs io.ReadSeeker, w io.Writer, selectedPages []string, ...) error
- func RemoveBoxesFile(inFile, outFile string, selectedPages []string, pb *model.PageBoundaries, ...) (err error)
- func RemoveFormFields(rs io.ReadSeeker, w io.Writer, fieldIDsOrNames []string, ...) error
- func RemoveFormFieldsFile(inFile, outFile string, fieldIDsOrNames []string, conf *model.Configuration) (err error)
- func RemoveKeywords(rs io.ReadSeeker, w io.Writer, keywords []string, conf *model.Configuration) error
- func RemoveKeywordsFile(inFile, outFile string, keywords []string, conf *model.Configuration) (err error)
- func RemovePages(rs io.ReadSeeker, w io.Writer, selectedPages []string, ...) error
- func RemovePagesFile(inFile, outFile string, selectedPages []string, conf *model.Configuration) (err error)
- func RemoveProperties(rs io.ReadSeeker, w io.Writer, properties []string, conf *model.Configuration) error
- func RemovePropertiesFile(inFile, outFile string, properties []string, conf *model.Configuration) (err error)
- func RemoveWatermarks(rs io.ReadSeeker, w io.Writer, selectedPages []string, ...) error
- func RemoveWatermarksFile(inFile, outFile string, selectedPages []string, conf *model.Configuration) (err error)
- func ResetFormFields(rs io.ReadSeeker, w io.Writer, fieldIDsOrNames []string, ...) error
- func ResetFormFieldsFile(inFile, outFile string, fieldIDsOrNames []string, conf *model.Configuration) (err error)
- func ResetPageLayout(rs io.ReadSeeker, w io.Writer, conf *model.Configuration) error
- func ResetPageLayoutFile(inFile, outFile string, conf *model.Configuration) (err error)
- func ResetPageMode(rs io.ReadSeeker, w io.Writer, conf *model.Configuration) error
- func ResetPageModeFile(inFile, outFile string, conf *model.Configuration) (err error)
- func ResetViewerPreferences(rs io.ReadSeeker, w io.Writer, conf *model.Configuration) error
- func ResetViewerPreferencesFile(inFile, outFile string, conf *model.Configuration) (err error)
- func Resize(rs io.ReadSeeker, w io.Writer, selectedPages []string, resize *model.Resize, ...) error
- func ResizeFile(inFile, outFile string, selectedPages []string, resize *model.Resize, ...) (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 SetPageLayout(rs io.ReadSeeker, w io.Writer, val model.PageLayout, conf *model.Configuration) error
- func SetPageLayoutFile(inFile, outFile string, val model.PageLayout, conf *model.Configuration) (err error)
- func SetPageMode(rs io.ReadSeeker, w io.Writer, val model.PageMode, conf *model.Configuration) error
- func SetPageModeFile(inFile, outFile string, val model.PageMode, conf *model.Configuration) (err error)
- func SetPermissions(rs io.ReadSeeker, w io.Writer, conf *model.Configuration) error
- func SetPermissionsFile(inFile, outFile string, conf *model.Configuration) (err error)
- func SetViewerPreferences(rs io.ReadSeeker, w io.Writer, vp model.ViewerPreferences, ...) error
- func SetViewerPreferencesFile(inFile, outFile string, vp model.ViewerPreferences, conf *model.Configuration) (err error)
- func SetViewerPreferencesFileFromJSONBytes(inFile, outFile string, jsonBytes []byte, conf *model.Configuration) (err error)
- func SetViewerPreferencesFileFromJSONFile(inFilePDF, outFilePDF, inFileJSON string, conf *model.Configuration) error
- func SetViewerPreferencesFromJSONBytes(rs io.ReadSeeker, w io.Writer, jsonBytes []byte, conf *model.Configuration) error
- func SetViewerPreferencesFromJSONReader(rs io.ReadSeeker, w io.Writer, rd io.Reader, conf *model.Configuration) error
- func Split(rs io.ReadSeeker, outDir, fileName string, span int, conf *model.Configuration) error
- func SplitByPageNr(rs io.ReadSeeker, outDir, fileName string, pageNrs []int, ...) error
- func SplitByPageNrFile(inFile, outDir string, pageNrs []int, conf *model.Configuration) error
- func SplitFile(inFile, outDir string, span int, conf *model.Configuration) error
- func TextWatermark(text, desc string, onTop, update bool, u types.DisplayUnit) (*model.Watermark, error)
- func Trim(rs io.ReadSeeker, w io.Writer, selectedPages []string, ...) error
- func TrimFile(inFile, outFile string, selectedPages []string, conf *model.Configuration) (err error)
- func UnlockFormFields(rs io.ReadSeeker, w io.Writer, fieldIDsOrNames []string, ...) error
- func UnlockFormFieldsFile(inFile, outFile string, fieldIDsOrNames []string, conf *model.Configuration) (err error)
- func UpdateImageWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, ...) error
- func UpdateImages(rs io.ReadSeeker, rd io.Reader, w io.Writer, objNr, pageNr int, id string, ...) error
- func UpdateImagesFile(inFile, imageFile, outFile string, objNr, pageNr int, id string, ...) (err 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 *model.Configuration) error
- func ValidateContext(ctx *model.Context) error
- func ValidateFile(inFile string, conf *model.Configuration) error
- func ValidateFiles(inFiles []string, conf *model.Configuration) error
- func ViewerPreferences(rs io.ReadSeeker, conf *model.Configuration) (*model.ViewerPreferences, *model.Version, error)
- func ViewerPreferencesFile(inFile string, all bool, conf *model.Configuration) (*model.ViewerPreferences, error)
- func WatermarkContext(ctx *model.Context, selectedPages types.IntSet, wm *model.Watermark) error
- func Write(ctx *model.Context, w io.Writer, conf *model.Configuration) error
- func WriteContext(ctx *model.Context, w io.Writer) error
- func WriteContextFile(ctx *model.Context, outFile string) error
- func WriteIncr(ctx *model.Context, rws io.ReadWriteSeeker, conf *model.Configuration) error
- func WriteIncrement(ctx *model.Context, w io.Writer) error
- func WritePage(r io.Reader, outDir, fileName string, pageNr int) error
- func Zoom(rs io.ReadSeeker, w io.Writer, selectedPages []string, zoom *model.Zoom, ...) error
- func ZoomFile(inFile, outFile string, selectedPages []string, zoom *model.Zoom, ...) (err error)
- type PageSpan
Examples ¶
- AddAttachmentsFile
- AddWatermarksFile
- ChangeOwnerPasswordFile
- ChangeUserPasswordFile
- DecryptFile
- EncryptFile
- ExtractAttachmentsFile
- ExtractContentFile
- ExtractFontsFile
- ExtractImagesFile
- ExtractMetadataFile
- ExtractPagesFile
- ImportImagesFile
- InsertPagesFile
- MergeAppendFile
- MergeCreateFile
- NUpFile
- OptimizeFile
- RemoveAttachmentsFile
- RemovePagesFile
- RemoveWatermarksFile
- RotateFile
- SetPermissionsFile
- SplitFile
- TrimFile
- ValidateFile
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoOutlines = errors.New("pdfcpu: no outlines available") ErrOutlines = errors.New("pdfcpu: existing outlines") )
var ( ErrNoFormData = errors.New("pdfcpu: missing form data") ErrNoFormFieldsAffected = errors.New("pdfcpu: no form fields affected") ErrInvalidCSV = errors.New("pdfcpu: invalid csv input file") ErrInvalidJSON = errors.New("pdfcpu: invalid JSON encoding") )
var ErrNoOp = errors.New("pdfcpu: no operation")
Functions ¶
func AddAnnotations ¶ added in v0.3.12
func AddAnnotations(rs io.ReadSeeker, w io.Writer, selectedPages []string, ann model.AnnotationRenderer, conf *model.Configuration) error
AddAnnotations adds annotations for selected pages in rs and writes the result to w.
func AddAnnotationsAsIncrement ¶ added in v0.3.12
func AddAnnotationsAsIncrement(rws io.ReadWriteSeeker, selectedPages []string, ar model.AnnotationRenderer, conf *model.Configuration) error
AddAnnotationsAsIncrement adds annotations for selected pages in rws and writes out a PDF increment.
func AddAnnotationsFile ¶ added in v0.3.12
func AddAnnotationsFile(inFile, outFile string, selectedPages []string, ar model.AnnotationRenderer, conf *model.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 ¶ added in v0.3.12
func AddAnnotationsMap(rs io.ReadSeeker, w io.Writer, m map[int][]model.AnnotationRenderer, conf *model.Configuration) error
AddAnnotationsMap adds annotations in m to corresponding pages of rs and writes the result to w.
func AddAnnotationsMapAsIncrement ¶ added in v0.3.12
func AddAnnotationsMapAsIncrement(rws io.ReadWriteSeeker, m map[int][]model.AnnotationRenderer, conf *model.Configuration) error
AddAnnotationsMapAsIncrement adds annotations in m to corresponding pages of rws and writes out a PDF increment.
func AddAnnotationsMapFile ¶ added in v0.3.12
func AddAnnotationsMapFile(inFile, outFile string, m map[int][]model.AnnotationRenderer, conf *model.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 *model.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 ¶ added in v0.2.3
func AddAttachmentsFile(inFile, outFile string, files []string, coll bool, conf *model.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 ¶ added in v0.3.12
func AddBookmarks(rs io.ReadSeeker, w io.Writer, bms []pdfcpu.Bookmark, replace bool, conf *model.Configuration) error
AddBookmarks adds a single bookmark outline layer to the PDF context read from rs and writes the result to w.
func AddBookmarksFile ¶ added in v0.3.12
func AddBookmarksFile(inFile, outFile string, bms []pdfcpu.Bookmark, replace bool, conf *model.Configuration) (err error)
AddBookmarksFile adds outlines to the PDF context read from inFile and writes the result to outFile.
func AddBoxes ¶ added in v0.3.8
func AddBoxes(rs io.ReadSeeker, w io.Writer, selectedPages []string, pb *model.PageBoundaries, conf *model.Configuration) error
AddBoxes adds page boundaries for selected pages of rs and writes result to w.
func AddBoxesFile ¶ added in v0.3.8
func AddBoxesFile(inFile, outFile string, selectedPages []string, pb *model.PageBoundaries, conf *model.Configuration) (err error)
AddBoxesFile adds page boundaries for selected pages of inFile and writes result to outFile.
func AddImageWatermarksFile ¶ added in v0.3.4
func AddImageWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, fileName, desc string, conf *model.Configuration) error
AddImageWatermarksFile adds image stamps/watermarks to all selected pages of inFile and writes the result to outFile.
func AddImageWatermarksForReaderFile ¶ added in v0.3.12
func AddImageWatermarksForReaderFile(inFile, outFile string, selectedPages []string, onTop bool, r io.Reader, desc string, conf *model.Configuration) error
AddImageWatermarksForReaderFile adds image stamps/watermarks to all selected pages of inFile for r and writes the result to outFile.
func AddKeywords ¶ added in v0.3.2
func AddKeywords(rs io.ReadSeeker, w io.Writer, files []string, conf *model.Configuration) error
AddKeywords adds keywords to rs's infodict and writes the result to w.
func AddKeywordsFile ¶ added in v0.3.2
func AddKeywordsFile(inFile, outFile string, files []string, conf *model.Configuration) (err error)
AddKeywordsFile adds keywords to inFile's infodict and writes the result to outFile.
func AddPDFWatermarksFile ¶ added in v0.3.4
func AddPDFWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, fileName, desc string, conf *model.Configuration) error
AddPDFWatermarksFile adds PDF stamps/watermarks to inFile and writes the result to outFile.
func AddProperties ¶ added in v0.3.2
func AddProperties(rs io.ReadSeeker, w io.Writer, properties map[string]string, conf *model.Configuration) error
AddProperties adds properties to rs's infodict and writes the result to w.
func AddPropertiesFile ¶ added in v0.3.2
func AddPropertiesFile(inFile, outFile string, properties map[string]string, conf *model.Configuration) (err error)
AddPropertiesFile adds properties to inFile's infodict and writes the result to outFile.
func AddTextWatermarksFile ¶ added in v0.3.4
func AddTextWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, text, desc string, conf *model.Configuration) error
AddTextWatermarksFile adds text stamps/watermarks to all selected pages of inFile and writes the result to outFile.
func AddWatermarks ¶ added in v0.1.16
func AddWatermarks(rs io.ReadSeeker, w io.Writer, selectedPages []string, wm *model.Watermark, conf *model.Configuration) error
AddWatermarks adds watermarks to all pages selected in rs and writes the result to w.
func AddWatermarksFile ¶ added in v0.2.3
func AddWatermarksFile(inFile, outFile string, selectedPages []string, wm *model.Watermark, conf *model.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, types.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, scale:1 abs, ", onTop, update, types.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, types.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", "scale:.5 abs, diagonal:2", onTop, update, types.POINTS) AddWatermarksFile("in.pdf", "", nil, wm, nil)
Output:
func AddWatermarksMap ¶ added in v0.3.8
func AddWatermarksMap(rs io.ReadSeeker, w io.Writer, m map[int]*model.Watermark, conf *model.Configuration) error
AddWatermarksMap adds watermarks in m to corresponding pages in rs and writes the result to w.
func AddWatermarksMapFile ¶ added in v0.3.8
func AddWatermarksMapFile(inFile, outFile string, m map[int]*model.Watermark, conf *model.Configuration) (err error)
AddWatermarksMapFile adds watermarks to corresponding pages in m of inFile and writes the result to outFile.
func AddWatermarksSliceMap ¶ added in v0.3.10
func AddWatermarksSliceMap(rs io.ReadSeeker, w io.Writer, m map[int][]*model.Watermark, conf *model.Configuration) error
AddWatermarksSliceMap adds watermarks in m to corresponding pages in rs and writes the result to w.
func AddWatermarksSliceMapFile ¶ added in v0.3.10
func AddWatermarksSliceMapFile(inFile, outFile string, m map[int][]*model.Watermark, conf *model.Configuration) (err error)
AddWatermarksSliceMapFile adds watermarks to corresponding pages in m of inFile and writes the result to outFile.
func Annotations ¶ added in v0.5.0
func Annotations(rs io.ReadSeeker, selectedPages []string, conf *model.Configuration) (map[int]model.PgAnnots, error)
Annotations returns page annotations of rs for selected pages.
func Attachments ¶ added in v0.5.0
func Attachments(rs io.ReadSeeker, conf *model.Configuration) ([]model.Attachment, error)
Attachments returns rs's attachments.
func Booklet ¶ added in v0.3.9
func Booklet(rs io.ReadSeeker, w io.Writer, imgFiles, selectedPages []string, nup *model.NUp, conf *model.Configuration) error
Booklet arranges PDF pages on larger sheets of paper and writes the result to w.
func BookletFile ¶ added in v0.3.9
func BookletFile(inFiles []string, outFile string, selectedPages []string, nup *model.NUp, conf *model.Configuration) (err error)
BookletFile rearranges PDF pages or images into a booklet layout and writes the result to outFile.
func BookletFromImages ¶ added in v0.3.9
func BookletFromImages(conf *model.Configuration, imageFileNames []string, nup *model.NUp) (*model.Context, error)
BookletFromImages creates a booklet from images.
func Bookmarks ¶ added in v0.5.0
func Bookmarks(rs io.ReadSeeker, conf *model.Configuration) ([]pdfcpu.Bookmark, error)
Bookmarks returns rs's bookmark hierarchy.
func Boxes ¶ added in v0.5.0
func Boxes(rs io.ReadSeeker, selectedPages []string, conf *model.Configuration) ([]model.PageBoundaries, error)
Boxes returns rs's page boundaries for selected pages of rs.
func ChangeOwnerPassword ¶
func ChangeOwnerPassword(rs io.ReadSeeker, w io.Writer, pwOld, pwNew string, conf *model.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 ¶ added in v0.2.3
func ChangeOwnerPasswordFile(inFile, outFile string, pwOld, pwNew string, conf *model.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 := model.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 *model.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 ¶ added in v0.2.3
func ChangeUserPasswordFile(inFile, outFile string, pwOld, pwNew string, conf *model.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 := model.NewAESConfiguration("upw", "opw", 256) ChangeUserPasswordFile("in.pdf", "", "upw", "upwNew", conf)
Output:
func Collect ¶ added in v0.3.2
func Collect(rs io.ReadSeeker, w io.Writer, selectedPages []string, conf *model.Configuration) error
Collect creates a custom PDF page sequence for selected pages of rs and writes the result to w.
func CollectFile ¶ added in v0.3.2
func CollectFile(inFile, outFile string, selectedPages []string, conf *model.Configuration) (err error)
CollectFile creates a custom PDF page sequence for inFile and writes the result to outFile.
func Create ¶ added in v0.4.0
func Create(rs io.ReadSeeker, rd io.Reader, w io.Writer, conf *model.Configuration) error
Create renders the PDF structure represented by rs into w. If rs is present, new PDF content will be appended including any empty pages needed. rd is a JSON representation of PDF page content which may include form data.
func CreateCheatSheetsUserFonts ¶ added in v0.3.7
CreateCheatSheetsUserFonts creates single page PDF cheat sheets for installed user fonts.
func CreateFile ¶ added in v0.4.0
func CreateFile(inFilePDF, inFileJSON, outFilePDF string, conf *model.Configuration) (err error)
CreateFile renders the PDF structure represented by inFileJSON into outFilePDF. If inFilePDF is present, new PDF content will be appended including any empty pages needed. inFileJSON represents PDF page content which may include form data.
func CreatePDFFile ¶ added in v0.2.3
CreatePDFFile creates a PDF file for an xRefTable and writes it to outFile.
func CreateUserFontDemoFiles ¶ added in v0.3.7
CreateUserFontDemoFiles creates single page PDF for each Unicode plane covered.
func Crop ¶ added in v0.3.8
func Crop(rs io.ReadSeeker, w io.Writer, selectedPages []string, b *model.Box, conf *model.Configuration) error
Crop adds crop boxes for selected pages of rs and writes result to w.
func CropFile ¶ added in v0.3.8
func CropFile(inFile, outFile string, selectedPages []string, b *model.Box, conf *model.Configuration) (err error)
CropFile adds crop boxes for selected pages of inFile and writes result to outFile.
func Cut ¶ added in v0.4.1
func Cut(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, cut *model.Cut, conf *model.Configuration) error
Cut applies cutConf for selected pages of rs and writes results to outDir.
func CutFile ¶ added in v0.4.1
func CutFile(inFile, outDir, outFile string, selectedPages []string, cut *model.Cut, conf *model.Configuration) error
CutFile applies cutConf for selected pages of inFile and writes results to outDir.
func Decrypt ¶
func Decrypt(rs io.ReadSeeker, w io.Writer, conf *model.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 ¶ added in v0.2.3
func DecryptFile(inFile, outFile string, conf *model.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 := model.NewAESConfiguration("upw", "opw", 256) DecryptFile("in.pdf", "", conf)
Output:
func DisableConfigDir ¶ added in v0.3.6
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 DumpObject ¶ added in v0.4.0
func DumpObject(rs io.ReadSeeker, mode, objNr int, conf *model.Configuration) error
DumpObject writes an object from rs to stdout.
func DumpObjectFile ¶ added in v0.4.0
func DumpObjectFile(inFile string, mode, objNr int, conf *model.Configuration) error
DumpObjectFile writes an object from rs to stdout.
func Encrypt ¶
func Encrypt(rs io.ReadSeeker, w io.Writer, conf *model.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 ¶ added in v0.2.3
func EncryptFile(inFile, outFile string, conf *model.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 := model.NewAESConfiguration("upw", "opw", 256) EncryptFile("in.pdf", "", conf)
Output:
func EnsureDefaultConfigAt ¶ added in v0.3.6
EnsureDefaultConfigAt switches to the pdfcpu config dir located at path. If path/pdfcpu is not existent, it will be created including config.yml
func ExportBookmarksFile ¶ added in v0.5.0
func ExportBookmarksFile(inFilePDF, outFileJSON string, conf *model.Configuration) (err error)
ExportBookmarksFile extracts outline data from inFilePDF and writes the result to outFileJSON.
func ExportBookmarksJSON ¶ added in v0.5.0
func ExportBookmarksJSON(rs io.ReadSeeker, w io.Writer, source string, conf *model.Configuration) error
ExportBookmarksJSON extracts outline data from rs (originating from source) and writes the result to w.
func ExportForm ¶ added in v0.4.0
func ExportForm(rs io.ReadSeeker, source string, conf *model.Configuration) (*form.FormGroup, error)
ExportForm extracts form data originating from source from rs.
func ExportFormFile ¶ added in v0.4.0
func ExportFormFile(inFilePDF, outFileJSON string, conf *model.Configuration) (err error)
ExportFormFile extracts form data from inFilePDF and writes the result to outFileJSON.
func ExportFormJSON ¶ added in v0.5.0
func ExportFormJSON(rs io.ReadSeeker, w io.Writer, source string, conf *model.Configuration) error
ExportFormJSON extracts form data originating from source from rs and writes the result to w.
func ExtractAttachments ¶
func ExtractAttachments(rs io.ReadSeeker, outDir string, fileNames []string, conf *model.Configuration) error
ExtractAttachments extracts embedded files from a PDF context read from rs into outDir.
func ExtractAttachmentsFile ¶ added in v0.2.3
func ExtractAttachmentsFile(inFile, outDir string, files []string, conf *model.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 ¶ added in v0.3.12
func ExtractAttachmentsRaw(rs io.ReadSeeker, outDir string, fileNames []string, conf *model.Configuration) ([]model.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 *model.Configuration) error
ExtractContent dumps "PDF source" files from rs into outDir for selected pages.
func ExtractContentFile ¶ added in v0.2.3
func ExtractContentFile(inFile, outDir string, selectedPages []string, conf *model.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 *model.Configuration) error
ExtractFonts dumps embedded fontfiles from rs into outDir for selected pages.
func ExtractFontsFile ¶ added in v0.2.3
func ExtractFontsFile(inFile, outDir string, selectedPages []string, conf *model.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(model.Image, bool, int) error, conf *model.Configuration) error
ExtractImages extracts and digests embedded image resources from rs for selected pages.
func ExtractImagesFile ¶ added in v0.2.3
func ExtractImagesFile(inFile, outDir string, selectedPages []string, conf *model.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 ¶ added in v0.3.12
func ExtractImagesRaw(rs io.ReadSeeker, selectedPages []string, conf *model.Configuration) ([]map[int]model.Image, error)
ExtractImagesRaw returns []pdfcpu.Image containing io.Readers for images contained in selectedPages. Beware of memory intensive returned slice.
func ExtractMetadata ¶ added in v0.1.16
func ExtractMetadata(rs io.ReadSeeker, outDir, fileName string, conf *model.Configuration) error
ExtractMetadata dumps all metadata dict entries for rs into outDir.
func ExtractMetadataFile ¶ added in v0.2.3
func ExtractMetadataFile(inFile, outDir string, conf *model.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 ExtractPage ¶ added in v0.8.0
ExtractPage extracts the page with pageNr out of ctx into an io.Reader.
func ExtractPages ¶
func ExtractPages(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, conf *model.Configuration) error
ExtractPages generates single page PDF files from rs in outDir for selected pages.
func ExtractPagesFile ¶ added in v0.2.3
func ExtractPagesFile(inFile, outDir string, selectedPages []string, conf *model.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 FillForm ¶ added in v0.4.0
func FillForm(rs io.ReadSeeker, rd io.Reader, w io.Writer, conf *model.Configuration) error
FillForm populates the form rs with data from rd and writes the result to w.
func FillFormFile ¶ added in v0.4.0
func FillFormFile(inFilePDF, inFileJSON, outFilePDF string, conf *model.Configuration) (err error)
FillFormFile populates the form inFilePDF with data from inFileJSON and writes the result to outFilePDF.
func FormFields ¶ added in v0.5.0
func FormFields(rs io.ReadSeeker, conf *model.Configuration) ([]form.Field, error)
FormFields returns all form fields of rs.
func GetPermissions ¶ added in v0.3.4
func GetPermissions(rs io.ReadSeeker, conf *model.Configuration) (*int16, error)
GetPermissions returns the permissions for rs.
func GetPermissionsFile ¶ added in v0.3.4
func GetPermissionsFile(inFile string, conf *model.Configuration) (*int16, error)
GetPermissionsFile returns the permissions for inFile.
func HasWatermarks ¶ added in v0.3.1
func HasWatermarks(rs io.ReadSeeker, conf *model.Configuration) (bool, error)
HasWatermarks checks rs for watermarks.
func HasWatermarksFile ¶ added in v0.3.1
func HasWatermarksFile(inFile string, conf *model.Configuration) (bool, error)
HasWatermarksFile checks inFile for watermarks.
func ImageBookletConfig ¶ added in v0.3.9
ImageBookletConfig returns an NUp configuration for Booklet-ing image files.
func ImageGridConfig ¶ added in v0.3.9
ImageGridConfig returns a grid configuration for Grid-ing image files.
func ImageNUpConfig ¶ added in v0.3.9
ImageNUpConfig returns an NUp configuration for Nup-ing image files.
func ImageWatermark ¶ added in v0.3.4
func ImageWatermark(fileName, desc string, onTop, update bool, u types.DisplayUnit) (*model.Watermark, error)
ImageWatermark returns an image watermark configuration.
func ImageWatermarkForReader ¶ added in v0.3.12
func ImageWatermarkForReader(r io.Reader, desc string, onTop, update bool, u types.DisplayUnit) (*model.Watermark, error)
ImageWatermarkForReader returns an image watermark configuration for r.
func Images ¶ added in v0.5.0
func Images(rs io.ReadSeeker, selectedPages []string, conf *model.Configuration) ([]map[int]model.Image, error)
Images returns all embedded images of rs.
func ImportBookmarks ¶ added in v0.5.0
func ImportBookmarks(rs io.ReadSeeker, rd io.Reader, w io.Writer, replace bool, conf *model.Configuration) error
ImportBookmarks creates/replaces outlines in rs and writes the result to w.
func ImportBookmarksFile ¶ added in v0.5.0
func ImportBookmarksFile(inFilePDF, inFileJSON, outFilePDF string, replace bool, conf *model.Configuration) (err error)
ImportBookmarks creates/replaces outlines in inFilePDF and writes the result to outFilePDF.
func ImportImages ¶ added in v0.1.20
func ImportImages(rs io.ReadSeeker, w io.Writer, imgs []io.Reader, imp *pdfcpu.Import, conf *model.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 ¶ added in v0.2.3
func ImportImagesFile(imgFiles []string, outFile string, imp *pdfcpu.Import, conf *model.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", types.POINTS) ImportImagesFile([]string{"a1.png", "a2.jpg", "a3.tiff"}, "out.pdf", imp, nil)
Output:
func InsertPages ¶ added in v0.2.3
func InsertPages(rs io.ReadSeeker, w io.Writer, selectedPages []string, before bool, pageConf *pdfcpu.PageConfiguration, conf *model.Configuration) error
InsertPages inserts a blank page before or after every page selected of rs and writes the result to w.
func InsertPagesFile ¶ added in v0.2.3
func InsertPagesFile(inFile, outFile string, selectedPages []string, before bool, pageConf *pdfcpu.PageConfiguration, conf *model.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, nil) // Insert a blank page into in.pdf after every page. InsertPagesFile("in.pdf", "", nil, false, nil, nil)
Output:
func InstallFonts ¶ added in v0.3.1
InstallFonts installs true type fonts for embedding.
func Keywords ¶ added in v0.5.0
func Keywords(rs io.ReadSeeker, conf *model.Configuration) ([]string, error)
Keywords returns the keywords of rs's info dict.
func ListPageLayout ¶ added in v0.6.0
func ListPageLayout(rs io.ReadSeeker, conf *model.Configuration) ([]string, error)
ListPageLayout lists rs's page layout.
func ListPageLayoutFile ¶ added in v0.6.0
func ListPageLayoutFile(inFile string, conf *model.Configuration) ([]string, error)
ListPageLayoutFile lists inFile's page layout.
func ListPageMode ¶ added in v0.6.0
func ListPageMode(rs io.ReadSeeker, conf *model.Configuration) ([]string, error)
ListPageMode lists rs's page mode.
func ListPageModeFile ¶ added in v0.6.0
func ListPageModeFile(inFile string, conf *model.Configuration) ([]string, error)
ListPageModeFile lists inFile's page mode.
func ListViewerPreferences ¶ added in v0.6.0
func ListViewerPreferences(rs io.ReadSeeker, all bool, conf *model.Configuration) ([]string, error)
ListViewerPreferences returns rs's viewer preferences.
func ListViewerPreferencesFile ¶ added in v0.6.0
func ListViewerPreferencesFile(inFile string, all, json bool, conf *model.Configuration) ([]string, error)
ListViewerPreferencesFile lists inFile's viewer preferences.
func ListViewerPreferencesFileJSON ¶ added in v0.6.0
func ListViewerPreferencesFileJSON(inFile string, all bool, conf *model.Configuration) ([]string, error)
ListViewerPreferencesFile lists inFile's viewer preferences in JSON.
func LoadConfiguration ¶ added in v0.3.7
func LoadConfiguration() *model.Configuration
LoadConfiguration locates and loads the default configuration and also loads installed user fonts.
func LockFormFields ¶ added in v0.4.0
func LockFormFields(rs io.ReadSeeker, w io.Writer, fieldIDsOrNames []string, conf *model.Configuration) error
LockFormFields turns form fields in rs into read-only and writes the result to w.
func LockFormFieldsFile ¶ added in v0.4.0
func LockFormFieldsFile(inFile, outFile string, fieldIDsOrNames []string, conf *model.Configuration) (err error)
LockFormFieldsFile turns form fields of inFile into read-only and writes the result to outFile.
func Merge ¶
func Merge(destFile string, inFiles []string, w io.Writer, conf *model.Configuration, dividerPage bool) error
Merge concatenates inFiles. if destFile is supplied it appends the result to destfile (=MERGEAPPEND) if no destFile supplied it writes the result to the first entry of inFiles (=MERGECREATE).
func MergeAppendFile ¶ added in v0.3.3
func MergeAppendFile(inFiles []string, outFile string, dividerPage bool, conf *model.Configuration) (err error)
MergeAppendFile appends inFiles to outFile.
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", false, nil)
Output:
func MergeCreateFile ¶ added in v0.3.3
func MergeCreateFile(inFiles []string, outFile string, dividerPage bool, conf *model.Configuration) (err error)
MergeCreateFile merges inFiles and writes the result to outFile.
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", false, nil)
Output:
func MergeCreateZip ¶ added in v0.6.0
func MergeCreateZip(rs1, rs2 io.ReadSeeker, w io.Writer, conf *model.Configuration) error
MergeCreateZip zips rs1 and rs2 into w.
func MergeCreateZipFile ¶ added in v0.6.0
func MergeCreateZipFile(inFile1, inFile2, outFile string, conf *model.Configuration) (err error)
MergeCreateZipFile zips inFile1 and inFile2 into outFile.
func MergeRaw ¶ added in v0.4.1
func MergeRaw(rsc []io.ReadSeeker, w io.Writer, dividerPage bool, conf *model.Configuration) error
MergeRaw merges a sequence of PDF streams and writes the result to w.
func MultiFillForm ¶ added in v0.4.0
func MultiFillForm(inFilePDF string, rd io.Reader, outDir, fileName string, format form.DataFormat, merge bool, conf *model.Configuration) error
MultiFillForm populates multiples instances of inFilePDF's form with data from rd and writes the result to outDir.
func MultiFillFormFile ¶ added in v0.4.0
func MultiFillFormFile(inFilePDF, inFileData, outDir, outFilePDF string, merge bool, conf *model.Configuration) (err error)
MultiFillFormFile populates multiples instances of inFilePDFs form with data from inFileData and writes the result to outDir.
func NDown ¶ added in v0.4.1
func NDown(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, n int, cut *model.Cut, conf *model.Configuration) error
NDown applies n & cutConf for selected pages of rs and writes results to outDir.
func NDownFile ¶ added in v0.4.1
func NDownFile(inFile, outDir, outFile string, selectedPages []string, n int, cut *model.Cut, conf *model.Configuration) error
NDownFile applies n & cutConf for selected pages of inFile and writes results to outDir.
func NUp ¶ added in v0.1.21
func NUp(rs io.ReadSeeker, w io.Writer, imgFiles, selectedPages []string, nup *model.NUp, conf *model.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 ¶ added in v0.2.3
func NUpFile(inFiles []string, outFile string, selectedPages []string, nup *model.NUp, conf *model.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, "", nil) 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", nil) inFiles = []string{"in1.png", "in2.jpg", "in3.tiff"} NUpFile(inFiles, "out.pdf", nil, nup, nil) // TestGridFromPDF nup, _ = PDFGridConfig(1, 3, "f:LegalL", nil) inFiles = []string{"in.pdf"} NUpFile(inFiles, "out.pdf", nil, nup, nil) // TestGridFromImages nup, _ = ImageGridConfig(4, 2, "d:500 500, m:20, b:off", nil) inFiles = []string{"in1.png", "in2.jpg", "in3.tiff"} NUpFile(inFiles, "out.pdf", nil, nup, nil)
Output:
func NUpFromImage ¶ added in v0.3.8
func NUpFromImage(conf *model.Configuration, imageFileNames []string, nup *model.NUp) (*model.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 *model.Configuration) error
Optimize reads a PDF stream from rs and writes the optimized PDF stream to w.
func OptimizeContext ¶ added in v0.1.18
OptimizeContext optimizes ctx.
func OptimizeFile ¶ added in v0.2.3
func OptimizeFile(inFile, outFile string, conf *model.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 := model.NewDefaultConfiguration() // Set passwords for encrypted files. conf.UserPW = "upw" conf.OwnerPW = "opw" // Configure end of line sequence for writing. conf.Eol = types.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 ¶ added in v0.3.9
PDFBookletConfig returns an NUp configuration for Booklet-ing PDF files.
func PDFGridConfig ¶ added in v0.3.9
PDFGridConfig returns a grid configuration for Grid-ing PDF files.
func PDFInfo ¶ added in v0.5.0
func PDFInfo(rs io.ReadSeeker, fileName string, selectedPages []string, conf *model.Configuration) (*pdfcpu.PDFInfo, error)
PDFInfo returns information about rs.
func PDFMultiWatermarkForReadSeeker ¶ added in v0.6.0
func PDFMultiWatermarkForReadSeeker(rs io.ReadSeeker, startPageNrSrc, startPageNrDest int, desc string, onTop, update bool, u types.DisplayUnit) (*model.Watermark, error)
PDFMultiWatermarkForReadSeeker returns a PDF watermark configuration. Define a source PDF watermark/stamp sequence using rs from page startPageNrSrc thru the last page of rs. Apply this sequence to the destination PDF file starting at page startPageNrDest for selected pages.
func PDFNUpConfig ¶ added in v0.3.9
PDFNUpConfig returns an NUp configuration for Nup-ing PDF files.
func PDFWatermark ¶ added in v0.3.4
func PDFWatermark(fileName, desc string, onTop, update bool, u types.DisplayUnit) (*model.Watermark, error)
PDFWatermark returns a PDF watermark configuration.
func PDFWatermarkForReadSeeker ¶ added in v0.6.0
func PDFWatermarkForReadSeeker(rs io.ReadSeeker, pageNrSrc int, desc string, onTop, update bool, u types.DisplayUnit) (*model.Watermark, error)
PDFWatermarkForReadSeeker returns a PDF watermark configuration. Apply watermark/stamp to destination file with pageNrSrc of rs for selected pages. If pageNr == 0 apply a multi watermark/stamp applying all src pages in ascending manner to destination pages.
func PageBoundaries ¶ added in v0.3.8
func PageBoundaries(s string, unit types.DisplayUnit) (*model.PageBoundaries, error)
PageBoundaries parses a list of box definitions and assignments.
func PageBoundariesFromBoxList ¶ added in v0.3.8
func PageBoundariesFromBoxList(s string) (*model.PageBoundaries, error)
PageBoundariesFromBoxList parses a list of box types.
func PageCount ¶ added in v0.2.3
func PageCount(rs io.ReadSeeker, conf *model.Configuration) (int, error)
PageCount returns rs's page count.
func PageCountFile ¶ added in v0.3.1
PageCountFile returns inFile's page count.
func PageDims ¶ added in v0.2.4
func PageDims(rs io.ReadSeeker, conf *model.Configuration) ([]types.Dim, error)
PageDims returns a sorted slice of mediaBox dimensions for rs.
func PageDimsFile ¶ added in v0.2.5
PageDimsFile returns a sorted slice of mediaBox dimensions for inFile.
func PageLayout ¶ added in v0.6.0
func PageLayout(rs io.ReadSeeker, conf *model.Configuration) (*model.PageLayout, error)
PageLayout returns rs's page layout.
func PageLayoutFile ¶ added in v0.6.0
func PageLayoutFile(inFile string, conf *model.Configuration) (*model.PageLayout, error)
PageLayoutFile returns inFile's page layout.
func PageMode ¶ added in v0.6.0
func PageMode(rs io.ReadSeeker, conf *model.Configuration) (*model.PageMode, error)
PageMode returns rs's page mode.
func PageModeFile ¶ added in v0.6.0
PageModeFile returns inFile's page mode.
func PagesForPageCollection ¶ added in v0.3.2
PagesForPageCollection returns a slice of page numbers for a page collection. Any page number in any order any number of times allowed.
func PagesForPageRange ¶ added in v0.3.6
PagesForPageRange returns a slice of page numbers for a page range.
func PagesForPageSelection ¶ added in v0.3.2
func PagesForPageSelection(pageCount int, pageSelection []string, ensureAllforNone bool, log bool) (types.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 Permissions ¶ added in v0.5.0
func Permissions(rs io.ReadSeeker, conf *model.Configuration) (int, error)
Permissions returns user access permissions for rs.
func Poster ¶ added in v0.4.1
func Poster(rs io.ReadSeeker, outDir, fileName string, selectedPages []string, cut *model.Cut, conf *model.Configuration) error
Poster applies cut for selected pages of rs and generates corresponding poster tiles in outDir.
func PosterFile ¶ added in v0.4.1
func PosterFile(inFile, outDir, outFile string, selectedPages []string, cut *model.Cut, conf *model.Configuration) error
PosterFile applies cut for selected pages of inFile and generates corresponding poster tiles in outDir.
func Properties ¶ added in v0.5.0
func Properties(rs io.ReadSeeker, conf *model.Configuration) (map[string]string, error)
Properties returns rs's properties as recorded in infoDict.
func ReadAndValidate ¶ added in v0.7.0
func ReadAndValidate(rs io.ReadSeeker, conf *model.Configuration) (ctx *model.Context, err error)
ReadAndValidate returns a model.Context of rs ready for processing.
func ReadContext ¶ added in v0.1.18
func ReadContext(rs io.ReadSeeker, conf *model.Configuration) (*model.Context, error)
ReadContext uses an io.ReadSeeker to build an internal structure holding its cross reference table aka the Context.
func ReadContextFile ¶ added in v0.2.3
ReadContextFile returns inFile's validated context.
func ReadValidateAndOptimize ¶ added in v0.5.0
func ReadValidateAndOptimize(rs io.ReadSeeker, conf *model.Configuration) (ctx *model.Context, err error)
ReadValidateAndOptimize returns an optimized model.Context of rs ready for processing a specific command. conf.Cmd is expected to be configured properly.
func RemainingPagesForPageRemoval ¶ added in v0.7.0
func RemoveAnnotations ¶ added in v0.3.12
func RemoveAnnotations(rs io.ReadSeeker, w io.Writer, selectedPages, idsAndTypes []string, objNrs []int, conf *model.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 ¶ added in v0.3.12
func RemoveAnnotationsAsIncrement(rws io.ReadWriteSeeker, selectedPages, idsAndTypes []string, objNrs []int, conf *model.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 ¶ added in v0.3.12
func RemoveAnnotationsFile(inFile, outFile string, selectedPages, idsAndTypes []string, objNrs []int, conf *model.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 *model.Configuration) error
RemoveAttachments deletes embedded files from a PDF context read from rs and writes the result to w.
func RemoveAttachmentsFile ¶ added in v0.2.3
func RemoveAttachmentsFile(inFile, outFile string, files []string, conf *model.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 RemoveBookmarks ¶ added in v0.5.0
func RemoveBookmarks(rs io.ReadSeeker, w io.Writer, conf *model.Configuration) error
RemoveBookmarks deletes outlines from rs and writes the result to w.
func RemoveBookmarksFile ¶ added in v0.5.0
func RemoveBookmarksFile(inFile, outFile string, conf *model.Configuration) (err error)
RemoveBookmarksFile deletes outlines from inFile and writes the result to outFile.
func RemoveBoxes ¶ added in v0.3.8
func RemoveBoxes(rs io.ReadSeeker, w io.Writer, selectedPages []string, pb *model.PageBoundaries, conf *model.Configuration) error
RemoveBoxes removes page boundaries as specified in pb for selected pages of rs and writes result to w.
func RemoveBoxesFile ¶ added in v0.3.8
func RemoveBoxesFile(inFile, outFile string, selectedPages []string, pb *model.PageBoundaries, conf *model.Configuration) (err error)
RemoveBoxesFile removes page boundaries as specified in pb for selected pages of inFile and writes result to outFile.
func RemoveFormFields ¶ added in v0.4.0
func RemoveFormFields(rs io.ReadSeeker, w io.Writer, fieldIDsOrNames []string, conf *model.Configuration) error
RemoveFormFields deletes form fields in rs and writes the result to w.
func RemoveFormFieldsFile ¶ added in v0.4.0
func RemoveFormFieldsFile(inFile, outFile string, fieldIDsOrNames []string, conf *model.Configuration) (err error)
RemoveFormFieldsFile deletes form fields in inFile and writes the result to outFile.
func RemoveKeywords ¶ added in v0.3.2
func RemoveKeywords(rs io.ReadSeeker, w io.Writer, keywords []string, conf *model.Configuration) error
RemoveKeywords deletes keywords from rs's infodict and writes the result to w.
func RemoveKeywordsFile ¶ added in v0.3.2
func RemoveKeywordsFile(inFile, outFile string, keywords []string, conf *model.Configuration) (err error)
RemoveKeywordsFile deletes keywords from inFile's infodict and writes the result to outFile.
func RemovePages ¶ added in v0.2.3
func RemovePages(rs io.ReadSeeker, w io.Writer, selectedPages []string, conf *model.Configuration) error
RemovePages removes selected pages from rs and writes the result to w.
func RemovePagesFile ¶ added in v0.2.3
func RemovePagesFile(inFile, outFile string, selectedPages []string, conf *model.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 ¶ added in v0.3.2
func RemoveProperties(rs io.ReadSeeker, w io.Writer, properties []string, conf *model.Configuration) error
RemoveProperties deletes properties from rs's infodict and writes the result to w.
func RemovePropertiesFile ¶ added in v0.3.2
func RemovePropertiesFile(inFile, outFile string, properties []string, conf *model.Configuration) (err error)
RemovePropertiesFile deletes properties from inFile's infodict and writes the result to outFile.
func RemoveWatermarks ¶ added in v0.2.5
func RemoveWatermarks(rs io.ReadSeeker, w io.Writer, selectedPages []string, conf *model.Configuration) error
RemoveWatermarks removes watermarks from all pages selected in rs and writes the result to w.
func RemoveWatermarksFile ¶ added in v0.2.5
func RemoveWatermarksFile(inFile, outFile string, selectedPages []string, conf *model.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, types.POINTS) AddWatermarksFile("in.pdf", "", nil, wm, nil) // Update stamp for correction: update = true wm, _ = TextWatermark("Confidential", "", onTop, update, types.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, types.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 ResetFormFields ¶ added in v0.4.0
func ResetFormFields(rs io.ReadSeeker, w io.Writer, fieldIDsOrNames []string, conf *model.Configuration) error
ResetFormFields resets form fields of rs and writes the result to w.
func ResetFormFieldsFile ¶ added in v0.4.0
func ResetFormFieldsFile(inFile, outFile string, fieldIDsOrNames []string, conf *model.Configuration) (err error)
ResetFormFieldsFile resets form fields of inFile and writes the result to outFile.
func ResetPageLayout ¶ added in v0.6.0
func ResetPageLayout(rs io.ReadSeeker, w io.Writer, conf *model.Configuration) error
ResetPageLayout resets rs's page layout and writes the result to w.
func ResetPageLayoutFile ¶ added in v0.6.0
func ResetPageLayoutFile(inFile, outFile string, conf *model.Configuration) (err error)
ResetPageLayoutFile resets inFile's page layout and writes the result to outFile.
func ResetPageMode ¶ added in v0.6.0
func ResetPageMode(rs io.ReadSeeker, w io.Writer, conf *model.Configuration) error
ResetPageMode resets rs's page mode and writes the result to w.
func ResetPageModeFile ¶ added in v0.6.0
func ResetPageModeFile(inFile, outFile string, conf *model.Configuration) (err error)
ResetPageModeFile resets inFile's page mode and writes the result to outFile.
func ResetViewerPreferences ¶ added in v0.6.0
func ResetViewerPreferences(rs io.ReadSeeker, w io.Writer, conf *model.Configuration) error
ResetViewerPreferences resets rs's viewer preferences and writes the result to w.
func ResetViewerPreferencesFile ¶ added in v0.6.0
func ResetViewerPreferencesFile(inFile, outFile string, conf *model.Configuration) (err error)
ResetViewerPreferencesFile resets inFile's viewer preferences and writes the result to outFile.
func Resize ¶ added in v0.4.0
func Resize(rs io.ReadSeeker, w io.Writer, selectedPages []string, resize *model.Resize, conf *model.Configuration) error
Resize applies resizeConf for selected pages of rs and writes result to w.
func ResizeFile ¶ added in v0.4.0
func ResizeFile(inFile, outFile string, selectedPages []string, resize *model.Resize, conf *model.Configuration) (err error)
ResizeFile applies resizeConf for selected pages of inFile and writes result to outFile.
func Rotate ¶ added in v0.1.20
func Rotate(rs io.ReadSeeker, w io.Writer, rotation int, selectedPages []string, conf *model.Configuration) error
Rotate rotates selected pages of rs clockwise by rotation degrees and writes the result to w.
func RotateFile ¶ added in v0.2.3
func RotateFile(inFile, outFile string, rotation int, selectedPages []string, conf *model.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 SetPageLayout ¶ added in v0.6.0
func SetPageLayout(rs io.ReadSeeker, w io.Writer, val model.PageLayout, conf *model.Configuration) error
SetPageLayout sets rs's page layout and writes the result to w.
func SetPageLayoutFile ¶ added in v0.6.0
func SetPageLayoutFile(inFile, outFile string, val model.PageLayout, conf *model.Configuration) (err error)
SetPageLayoutFile sets inFile's page layout and writes the result to outFile.
func SetPageMode ¶ added in v0.6.0
func SetPageMode(rs io.ReadSeeker, w io.Writer, val model.PageMode, conf *model.Configuration) error
SetPageMode sets rs's page mode and writes the result to w.
func SetPageModeFile ¶ added in v0.6.0
func SetPageModeFile(inFile, outFile string, val model.PageMode, conf *model.Configuration) (err error)
SetPageModeFile sets inFile's page mode and writes the result to outFile.
func SetPermissions ¶ added in v0.2.3
func SetPermissions(rs io.ReadSeeker, w io.Writer, conf *model.Configuration) error
SetPermissions sets user access permissions. inFile has to be encrypted. A configuration containing the current passwords is required.
func SetPermissionsFile ¶ added in v0.2.3
func SetPermissionsFile(inFile, outFile string, conf *model.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 := model.NewAESConfiguration("upw", "opw", 256) conf.Permissions = model.PermissionsAll SetPermissionsFile("in.pdf", "", conf) // Restricting permissions for the AES-256 encrypted in.pdf. conf = model.NewAESConfiguration("upw", "opw", 256) conf.Permissions = model.PermissionsNone SetPermissionsFile("in.pdf", "", conf)
Output:
func SetViewerPreferences ¶ added in v0.6.0
func SetViewerPreferences(rs io.ReadSeeker, w io.Writer, vp model.ViewerPreferences, conf *model.Configuration) error
SetViewerPreferences sets rs's viewer preferences and writes the result to w.
func SetViewerPreferencesFile ¶ added in v0.6.0
func SetViewerPreferencesFile(inFile, outFile string, vp model.ViewerPreferences, conf *model.Configuration) (err error)
SetViewerPreferencesFile sets inFile's viewer preferences and writes the result to outFile.
func SetViewerPreferencesFileFromJSONBytes ¶ added in v0.6.0
func SetViewerPreferencesFileFromJSONBytes(inFile, outFile string, jsonBytes []byte, conf *model.Configuration) (err error)
SetViewerPreferencesFileFromJSONBytes sets inFile's viewer preferences corresponding to jsonBytes and writes the result to outFile.
func SetViewerPreferencesFileFromJSONFile ¶ added in v0.6.0
func SetViewerPreferencesFileFromJSONFile(inFilePDF, outFilePDF, inFileJSON string, conf *model.Configuration) error
SetViewerPreferencesFileFromJSONFile sets inFile's viewer preferences corresponding to inFileJSON and writes the result to outFile.
func SetViewerPreferencesFromJSONBytes ¶ added in v0.6.0
func SetViewerPreferencesFromJSONBytes(rs io.ReadSeeker, w io.Writer, jsonBytes []byte, conf *model.Configuration) error
SetViewerPreferencesFromJSONBytes sets rs's viewer preferences corresponding to jsonBytes and writes the result to w.
func SetViewerPreferencesFromJSONReader ¶ added in v0.6.0
func SetViewerPreferencesFromJSONReader(rs io.ReadSeeker, w io.Writer, rd io.Reader, conf *model.Configuration) error
SetViewerPreferencesFromJSONReader sets rs's viewer preferences corresponding to rd and writes the result to w.
func Split ¶
func Split(rs io.ReadSeeker, outDir, fileName string, span int, conf *model.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 SplitByPageNr ¶ added in v0.6.0
func SplitByPageNr(rs io.ReadSeeker, outDir, fileName string, pageNrs []int, conf *model.Configuration) error
SplitFile generates a sequence of PDF files in outDir for rs splitting along pageNrs.
func SplitByPageNrFile ¶ added in v0.6.0
func SplitByPageNrFile(inFile, outDir string, pageNrs []int, conf *model.Configuration) error
SplitFile generates a sequence of PDF files in outDir for inFile splitting it along pageNrs.
func SplitFile ¶ added in v0.2.3
func SplitFile(inFile, outDir string, span int, conf *model.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 ¶ added in v0.3.4
func TextWatermark(text, desc string, onTop, update bool, u types.DisplayUnit) (*model.Watermark, error)
TextWatermark returns a text watermark configuration.
func Trim ¶
func Trim(rs io.ReadSeeker, w io.Writer, selectedPages []string, conf *model.Configuration) error
Trim generates a trimmed version of rs containing all selected pages and writes the result to w.
func TrimFile ¶ added in v0.2.3
func TrimFile(inFile, outFile string, selectedPages []string, conf *model.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 UnlockFormFields ¶ added in v0.4.0
func UnlockFormFields(rs io.ReadSeeker, w io.Writer, fieldIDsOrNames []string, conf *model.Configuration) error
UnlockFormFields makess form fields in rs writeable and writes the result to w.
func UnlockFormFieldsFile ¶ added in v0.4.0
func UnlockFormFieldsFile(inFile, outFile string, fieldIDsOrNames []string, conf *model.Configuration) (err error)
UnlockFormFieldsFile makes form fields of inFile writeable and writes the result to outFile.
func UpdateImageWatermarksFile ¶ added in v0.3.4
func UpdateImageWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, fileName, desc string, conf *model.Configuration) error
UpdateImageWatermarksFile adds image stamps/watermarks to all selected pages of inFile and writes the result to outFile.
func UpdateImages ¶ added in v0.9.0
func UpdateImages(rs io.ReadSeeker, rd io.Reader, w io.Writer, objNr, pageNr int, id string, conf *model.Configuration) error
UpdateImages replaces the XObject identified by objNr or (pageNr and resourceId).
func UpdateImagesFile ¶ added in v0.9.0
func UpdateImagesFile(inFile, imageFile, outFile string, objNr, pageNr int, id string, conf *model.Configuration) (err error)
UpdateImagesFile replaces the XObject identified by objNr or (pageNr and resourceId).
func UpdatePDFWatermarksFile ¶ added in v0.3.4
func UpdatePDFWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, fileName, desc string, conf *model.Configuration) error
UpdatePDFWatermarksFile adds PDF stamps/watermarks to all selected pages of inFile and writes the result to outFile.
func UpdateTextWatermarksFile ¶ added in v0.3.4
func UpdateTextWatermarksFile(inFile, outFile string, selectedPages []string, onTop bool, text, desc string, conf *model.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 *model.Configuration) error
Validate validates a PDF stream read from rs.
func ValidateContext ¶ added in v0.1.18
ValidateContext validates ctx.
func ValidateFile ¶ added in v0.2.3
func ValidateFile(inFile string, conf *model.Configuration) error
ValidateFile validates inFile.
Example ¶
// Use the default configuration to validate in.pdf. ValidateFile("in.pdf", nil)
Output:
func ValidateFiles ¶ added in v0.3.13
func ValidateFiles(inFiles []string, conf *model.Configuration) error
ValidateFiles validates inFiles.
func ViewerPreferences ¶ added in v0.6.0
func ViewerPreferences(rs io.ReadSeeker, conf *model.Configuration) (*model.ViewerPreferences, *model.Version, error)
ViewerPreferences returns rs's viewer preferences.
func ViewerPreferencesFile ¶ added in v0.6.0
func ViewerPreferencesFile(inFile string, all bool, conf *model.Configuration) (*model.ViewerPreferences, error)
ViewerPreferences returns inFile's viewer preferences.
func WatermarkContext ¶ added in v0.3.1
WatermarkContext applies wm for selected pages to ctx.
func WriteContext ¶ added in v0.1.18
WriteContext writes ctx to w.
func WriteContextFile ¶ added in v0.3.1
WriteContextFile writes ctx to outFile.
func WriteIncr ¶ added in v0.7.0
func WriteIncr(ctx *model.Context, rws io.ReadWriteSeeker, conf *model.Configuration) error
func WriteIncrement ¶ added in v0.3.12
WriteIncrement writes a PDF increment for ctx to w.
func WritePage ¶ added in v0.8.0
WritePage consumes an io.Reader containing some PDF bytes and writes to outDir/fileName.
Types ¶
type PageSpan ¶ added in v0.4.0
func SplitRaw ¶ added in v0.4.0
func SplitRaw(rs io.ReadSeeker, span int, conf *model.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
Source Files ¶
- annotation.go
- api.go
- attach.go
- booklet.go
- bookmark.go
- box.go
- collect.go
- create.go
- crypto.go
- cut.go
- extract.go
- font.go
- form.go
- image.go
- importImage.go
- info.go
- keyword.go
- merge.go
- nup.go
- optimize.go
- page.go
- pageLayout.go
- pageMode.go
- permission.go
- property.go
- resize.go
- rotate.go
- selectPages.go
- split.go
- stamp.go
- trim.go
- validate.go
- viewerPreferences.go
- zoom.go