{"modulePath":"github.com/hhrutter/pdfcpu","version":"v0.2.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package api\n\nPackage api lets you integrate pdfcpu's operations into your Go backend.\n\nThere are two api layers supporting all pdfcpu operations:\n\n 1. The file based layer (used by pdfcpu's cli)\n 2. The io.ReadSeeker/io.Writer based layer for backend integration.\n\nFor any pdfcpu command there are two functions.\n\nThe file based function always calls the io.ReadSeeker/io.Writer based function:\n\n\tfunc CommandFile(inFile, outFile string, conf *pdf.Configuration) error\n\tfunc Command(rs io.ReadSeeker, w io.Writer, conf *pdf.Configuration) error\n\neg. for optimization:\n\n\tfunc OptimizeFile(inFile, outFile string, conf *pdf.Configuration) error\n\tfunc Optimize(rs io.ReadSeeker, w io.Writer, conf *pdf.Configuration) error\n\n## Functions\n\n```go\nfunc AddAttachments(rs io.ReadSeeker, w io.Writer, files []string, conf *pdf.Configuration) error\n```\nAddAttachments embeds files into a PDF context read from rs and writes the result to w.\n\n```go\nfunc AddAttachmentsFile(inFile, outFile string, files []string, conf *pdf.Configuration) (err error)\n```\nAddAttachmentsFile embeds files into a PDF context read from inFile and writes the result to outFile.\n\n```go\nfunc AddWatermarks(rs io.ReadSeeker, w io.Writer, selectedPages []string, wm *pdf.Watermark, conf *pdf.Configuration) error\n```\nAddWatermarks adds watermarks to all pages selected in rs and writes the result to w.\n\n```go\nfunc AddWatermarksFile(inFile, outFile string, selectedPages []string, wm *pdf.Watermark, conf *pdf.Configuration) (err error)\n```\nAddWatermarksFile adds watermarks to all selected pages of inFile and writes the result to outFile.\n\n```go\nfunc ChangeOwnerPasswordFile(inFile, outFile string, pwOld, pwNew string, conf *pdf.Configuration) error\n```\nChangeOwnerPasswordFile reads inFile, changes the user password and writes the result to outFile. A configuration containing the current passwords is required.\n\n```go\nfunc ChangeUserPasswordFile(inFile, outFile string, pwOld, pwNew string, conf *pdf.Configuration) error\n```\nChangeUserPasswordFile reads inFile, changes the user password and writes the result to outFile. A configuration containing the current passwords is required.\n\n```go\nfunc CreatePDFFile(xRefTable *pdf.XRefTable, outFile string, conf *pdf.Configuration) error\n```\nCreatePDFFile creates a PDF file for an xRefTable and writes it to outFile.\n\n```go\nfunc DecryptFile(inFile, outFile string, conf *pdf.Configuration) error\n```\nDecryptFile decrypts inFile and writes the result to outFile. A configuration containing the current passwords is required.\n\n```go\nfunc EncryptFile(inFile, outFile string, conf *pdf.Configuration) error\n```\nEncryptFile encrypts inFile and writes the result to outFile. A configuration containing the current passwords is required.\n\n```go\nfunc ExtractAttachments(rs io.ReadSeeker, outDir string, fileNames []string, conf *pdf.Configuration) error\n```\nExtractAttachments extracts embedded files from a PDF context read from rs into outDir.\n\n```go\nfunc ExtractAttachmentsFile(inFile, outDir string, fileNames []string, conf *pdf.Configuration) error\n```\nExtractAttachmentsFile extracts embedded files from a PDF context read from inFile into outDir.\n\n```go\nfunc ExtractContent(rs io.ReadSeeker, outDir string, selectedPages []string, conf *pdf.Configuration) error\n```\nExtractContent dumps \"PDF source\" files from rs into outDir for selected pages.\n\n```go\nfunc ExtractContentFile(inFile, outDir string, selectedPages []string, conf *pdf.Configuration) error\n```\nExtractContentFile dumps \"PDF source\" files from inFile into outDir for selected pages.\n\n```go\nfunc ExtractFonts(rs io.ReadSeeker, outDir string, selectedPages []string, conf *pdf.Configuration) error\n```\nExtractFonts dumps embedded fontfiles from rs into outDir for selected pages.\n\n```go\nfunc ExtractFontsFile(inFile, outDir string, selectedPages []string, conf *pdf.Configuration) error\n```\nExtractFontsFile dumps embedded fontfiles from inFile into outDir for selected pages.\n\n```go\nfunc ExtractImages(rs io.ReadSeeker, outDir string, selectedPages []string, conf *pdf.Configuration) error\n```\nExtractImages dumps embedded image resources from rs into outDir for selected pages.\n\n```go\nfunc ExtractImagesFile(inFile, outDir string, selectedPages []string, conf *pdf.Configuration) error\n```\nExtractImagesFile dumps embedded image resources from inFile into outDir for selected pages.\n\n```go\nfunc ExtractMetadata(rs io.ReadSeeker, outDir string, selectedPages []string, conf *pdf.Configuration) error\n```\nExtractMetadata dumps all metadata dict entries for rs into outDir.\n\n```go\nfunc ExtractMetadataFile(inFile, outDir string, selectedPages []string, conf *pdf.Configuration) error\n```\nExtractMetadataFile dumps all metadata dict entries for inFile into outDir.\n\n```go\nfunc ExtractPages(rs io.ReadSeeker, outDir string, selectedPages []string, conf *pdf.Configuration) error\n```\nExtractPages generates single page PDF files from rs in outDir for selected pages.\n\n```go\nfunc ExtractPagesFile(inFile, outDir string, selectedPages []string, conf *pdf.Configuration) error\n```\nExtractPagesFile generates single page PDF files from inFile in outDir for selected pages.\n\n```go\nfunc ImportImages(rs io.ReadSeeker, w io.Writer, imgs []io.Reader, imp *pdf.Import, conf *pdf.Configuration) error\n```\nImportImages 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.\n\n```go\nfunc ImportImagesFile(imgFiles []string, outFile string, imp *pdf.Import, conf *pdf.Configuration) (err error)\n```\nImportImagesFile appends PDF pages containing images to outFile which will be created if necessary.\n\n```go\nfunc Info(rs io.ReadSeeker, conf *pdf.Configuration) ([]string, error)\n```\nInfo returns information about rs.\n\n```go\nfunc InfoFile(inFile string, conf *pdf.Configuration) ([]string, error)\n```\nInfoFile returns information about inFile.\n\n```go\nfunc InsertPages(rs io.ReadSeeker, w io.Writer, selectedPages []string, conf *pdf.Configuration) error\n```\nInsertPages inserts a blank page at every page selected of rs and writes the result to w.\n\n```go\nfunc InsertPagesFile(inFile, outFile string, selectedPages []string, conf *pdf.Configuration) (err error)\n```\nInsertPagesFile inserts a blank page at every inFile page selected and writes the result to w.\n\n```go\nfunc ListAttachments(rs io.ReadSeeker, conf *pdf.Configuration) ([]string, error)\n```\nListAttachments returns a list of embedded file attachments of rs.\n\n```go\nfunc ListAttachmentsFile(inFile string, conf *pdf.Configuration) ([]string, error)\n```\nListAttachmentsFile returns a list of embedded file attachments of inFile.\n\n```go\nfunc ListPermissions(rs io.ReadSeeker, conf *pdf.Configuration) ([]string, error)\n```\nListPermissions returns a list of user access permissions.\n\n```go\nfunc ListPermissionsFile(inFile string, conf *pdf.Configuration) ([]string, error)\n```\nListPermissionsFile returns a list of user access permissions for inFile.\n\n```go\nfunc Merge(rsc []io.ReadSeeker, w io.Writer, conf *pdf.Configuration) error\n```\nMerge merges a sequence of PDF streams and writes the result to w.\n\n```go\nfunc MergeFile(inFiles []string, outFile string, conf *pdf.Configuration) error\n```\nMergeFile 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.\n\n```go\nfunc NUp(rs io.ReadSeeker, w io.Writer, imgFiles, selectedPages []string, nup *pdf.NUp, conf *pdf.Configuration) error\n```\nNUp rearranges PDF pages or images into page grids and writes the result to w. Either rs or imgFiles will be used.\n\n```go\nfunc NUpFile(inFiles []string, outFile string, selectedPages []string, nup *pdf.NUp, conf *pdf.Configuration) (err error)\n```\nNUpFile rearranges PDF pages or images into page grids and writes the result to outFile.\n\n```go\nfunc Optimize(rs io.ReadSeeker, w io.Writer, conf *pdf.Configuration) error\n```\nOptimize reads a PDF stream from rs and writes the optimized PDF stream to w.\n\n```go\nfunc OptimizeContext(ctx *pdf.Context) error\n```\nOptimizeContext optimizes a PDF context.\n\n```go\nfunc OptimizeFile(inFile, outFile string, conf *pdf.Configuration) (err error)\n```\nOptimizeFile 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.\n\n```go\nfunc PageCount(inFile string) (int, error)\n```\nPageCount returns inFile's page count.\n\n```go\nfunc ParsePageSelection(s string) ([]string, error)\n```\nParsePageSelection ensures a correct page selection expression.\n\n```go\nfunc ReadContext(rs io.ReadSeeker, conf *pdf.Configuration) (*pdf.Context, error)\n```\nReadContext uses an io.Readseeker to build an internal structure holding its cross reference table aka the Context.\n\n```go\nfunc ReadContextFile(inFile string) (*pdf.Context, error)\n```\nReadContextFile returns inFile's validated context.\n\n```go\nfunc RemoveAttachments(rs io.ReadSeeker, w io.Writer, fileNames []string, conf *pdf.Configuration) error\n```\nRemoveAttachments deletes embedded files from a PDF context read from rs and writes the result to w.\n\n```go\nfunc RemoveAttachmentsFile(inFile, outFile string, files []string, conf *pdf.Configuration) (err error)\n```\nRemoveAttachmentsFile deletes embedded files from a PDF context read from inFile and writes the result to outFile.\n\n```go\nfunc RemovePages(rs io.ReadSeeker, w io.Writer, selectedPages []string, conf *pdf.Configuration) error\n```\nRemovePages removes selected pages from rs and writes the result to w.\n\n```go\nfunc RemovePagesFile(inFile, outFile string, selectedPages []string, conf *pdf.Configuration) (err error)\n```\nRemovePagesFile removes selected inFile pages and writes the result to outFile..\n\n```go\nfunc Rotate(rs io.ReadSeeker, w io.Writer, rotation int, selectedPages []string, conf *pdf.Configuration) error\n```\nRotate rotates selected pages of rs clockwise by rotation degrees and writes the result to w.\n\n```go\nfunc RotateFile(inFile, outFile string, rotation int, selectedPages []string, conf *pdf.Configuration) (err error)\n```\nRotateFile rotates selected pages of inFile clockwise by rotation degrees and writes the result to outFile.\n\n```go\nfunc SetPermissions(rs io.ReadSeeker, w io.Writer, conf *pdf.Configuration) error\n```\nSetPermissions sets user access permissions. inFile has to be encrypted. A configuration containing the current passwords is required.\n\n```go\nfunc SetPermissionsFile(inFile, outFile string, conf *pdf.Configuration) (err error)\n```\nSetPermissionsFile sets inFile's user access permissions. inFile has to be encrypted. A configuration containing the current passwords is required.\n\n```go\nfunc Split(rs io.ReadSeeker, outDir, fileName string, span int, conf *pdf.Configuration) error\n```\nSplit generates a sequence of PDF files in outDir for the PDF stream read from rs obeying given split span. The default span 1 creates a sequence of single page PDFs.\n\n```go\nfunc SplitFile(inFile, outDir string, span int, conf *pdf.Configuration) error\n```\nSplitFile generates a sequence of PDF files in outDir for inFile obeying given split span. The default span 1 creates a sequence of single page PDFs.\n\n```go\nfunc Trim(rs io.ReadSeeker, w io.Writer, selectedPages []string, conf *pdf.Configuration) error\n```\nTrim generates a trimmed version of rs containing all selected pages and writes the result to w.\n\n```go\nfunc TrimFile(inFile, outFile string, selectedPages []string, conf *pdf.Configuration) (err error)\n```\nTrimFile generates a trimmed version of inFile containing all selected pages and writes the result to outFile.\n\n```go\nfunc Validate(rs io.ReadSeeker, conf *pdf.Configuration) error\n```\nValidate validates a PDF stream read from rs.\n\n```go\nfunc ValidateContext(ctx *pdf.Context) error\n```\nValidateContext validates a PDF context.\n\n```go\nfunc ValidateFile(inFile string, conf *pdf.Configuration) error\n```\nValidateFile validates inFile.\n\n```go\nfunc WriteContext(ctx *pdf.Context, w io.Writer) error\n```\nWriteContext writes a PDF context to w.\n\n## Types\n\n```go\ntype ReadSeekerCloser interface {\n\tio.ReadSeeker\n\tio.Closer\n}\n```\nReadSeekerCloser combines io.ReadSeeker and io.Closer\n\n","path":"github.com/hhrutter/pdfcpu/pkg/api","name":"api","synopsis":"Package api lets you integrate pdfcpu's operations into your Go backend.","isRedistributable":true}
