1 Star 0 Fork 353

zkailee251/PDF-Guru

forked from Kevin2li/PDF-Guru 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
split.go 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
Kevin2li 提交于 2023-07-18 15:06 . refactor
package main
import "fmt"
func (a *App) SplitPDFByChunk(inFile string, chunkSize int, outDir string) error {
logger.Printf("inFile: %s, chunkSize: %d, outDir: %s\n", inFile, chunkSize, outDir)
args := []string{"split", "--mode", "chunk"}
args = append(args, "--chunk_size")
args = append(args, fmt.Sprintf("%d", chunkSize))
if outDir != "" {
args = append(args, "--output", outDir)
}
args = append(args, inFile)
logger.Println(args)
return a.cmdRunner(args, "pdf")
}
func (a *App) SplitPDFByBookmark(inFile string, tocLevel string, outDir string) error {
logger.Printf("inFile: %s, outDir: %s\n", inFile, outDir)
args := []string{"split", "--mode", "toc"}
if tocLevel != "" {
args = append(args, "--toc-level", tocLevel)
}
if outDir != "" {
args = append(args, "--output", outDir)
}
args = append(args, inFile)
logger.Println(args)
return a.cmdRunner(args, "pdf")
}
func (a *App) SplitPDFByPage(inFile string, pages string, outDir string) error {
logger.Printf("inFile: %s, pages: %s, outDir: %s\n", inFile, pages, outDir)
args := []string{"split", "--mode", "page"}
if pages != "" {
args = append(args, "--page_range", pages)
}
if outDir != "" {
args = append(args, "--output", outDir)
}
args = append(args, inFile)
logger.Println(args)
return a.cmdRunner(args, "pdf")
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/zk251/PDF-Guru.git
git@gitee.com:zk251/PDF-Guru.git
zk251
PDF-Guru
PDF-Guru
main

搜索帮助