pdfKit

package
v3.1.101 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Optimize func(rs io.ReadSeeker, w io.Writer, conf *model.Configuration) error = api.Optimize

	OptimizeContext func(ctx *model.Context) error = api.OptimizeContext

	OptimizeFile func(inFile, outFile string, conf *model.Configuration) error = api.OptimizeFile
)
View Source
var (
	// Split 推荐使用 SplitFile,是对本函数的封装.
	Split func(rs io.ReadSeeker, outDir, fileName string, span int, conf *model.Configuration) error = api.Split

	// SplitByPageNr 推荐使用 SplitByPageNrFile,是对本函数的封装.
	SplitByPageNr func(rs io.ReadSeeker, outDir, fileName string, pageNrs []int, conf *model.Configuration) error = api.SplitByPageNr
)
View Source
var (
	// Merge
	/*
		Deprecated: 使用 MergeCreateFile 或 MergeAppendFile,它们实际上是对此函数的封装.
	*/
	Merge func(destFile string, inFiles []string, w io.Writer, conf *model.Configuration, dividerPage bool) error = api.Merge
)

Functions

func ExtractImagesFile added in v3.0.106

func ExtractImagesFile(inFile, outDir string, selectedPages []string, conf *model.Configuration) error

ExtractImagesFile 导出pdf文件中的图片.

!!!: pdfcpu 库仅支持提取原始嵌入的图像(如果图像经过压缩或编码,则可能无法提取).

@param outDir 输出目录 @param selectedPages 可以为nil,即该pdf文件的所有页

e.g. 第1页和第2页
	[]string{"1", "2"}

@param conf 可以为nil

func MergeAppendFile

func MergeAppendFile(inFiles []string, outFile string, dividerPage bool, conf *model.Configuration) error

MergeAppendFile 合并pdf(如果outFile已经存在且是个文件,会"在最后追加"内容).

@param inFiles		要合并的pdf文件(复数)
@param outFile		合并后的pdf文件
@param dividerPage	true: 在每个pdf文件之间插入一个空白页
@param conf 		可以为nil,将使用默认值

func MergeCreateFile

func MergeCreateFile(inFiles []string, outFile string, dividerPage bool, conf *model.Configuration) error

MergeCreateFile 合并pdf(如果outFile已经存在且是个文件,会"覆盖"内容).

func SplitByPageNrFile added in v3.0.106

func SplitByPageNrFile(inFile, outDir string, pageNrs []int, conf *model.Configuration) error

SplitByPageNrFile

@param pageNrs 拆分的页数s(其中元素应该>=2) @param conf 可以为nil

e.g. 34页的pdf文件,传参pageNrs为[]int{2},结果: 拆分为2个pdf文件,第一个pdf文件有 1 页,第二个pdf文件有 33页

inputPDF := "/Users/richelieu/Desktop/34页(1).pdf"
outputDir := "_tmp"
if err := pdfKit.SplitByPageNrFile(inputPDF, outputDir, []int{2}, nil); err != nil {
	panic(err)
}

func SplitFile added in v3.0.106

func SplitFile(inFile, outDir string, span int, conf *model.Configuration) error

SplitFile 拆分pdf文件(可以指定生成pdf文件的页数).

@param outDir 拆分后的文件保存目录 @param span 每几页拆分为一个pdf文件?应该>=1 @param conf 可以为nil

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL