加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
insert.go 2.20 KB
一键复制 编辑 原始数据 按行查看 历史
Kevin2li 提交于 2023-07-18 15:06 . refactor
package main
import "fmt"
func (a *App) InsertPDF(inFile1 string, inFile2 string, insertPos int, dstPages string, posType string, outFile string) error {
logger.Printf("inFile1: %s, inFile2: %s, insertPos: %d, dstPages: %s, posType: %s, outFile: %s\n", inFile1, inFile2, insertPos, dstPages, posType, outFile)
args := []string{"insert"}
if insertPos != 0 {
args = append(args, "--insert_pos", fmt.Sprintf("%d", insertPos))
}
if posType != "" {
args = append(args, "--pos-type", posType)
}
if dstPages != "" {
args = append(args, "--page_range", dstPages)
}
if outFile != "" {
args = append(args, "-o", outFile)
}
args = append(args, inFile1)
args = append(args, inFile2)
logger.Println(args)
return a.cmdRunner(args, "pdf")
}
func (a *App) InsertBlankPDF(inFile string, outFile string, insertPos int, posType string, paper_size string, orientation string, count int) error {
logger.Printf("inFile: %s, outFile: %s, insertPos: %d, posType: %s, paper_size: %s, orientation: %s, count: %d\n", inFile, outFile, insertPos, posType, paper_size, orientation, count)
args := []string{"insert", "--method", "blank"}
args = append(args, "--insert_pos", fmt.Sprintf("%d", insertPos))
if posType != "" {
args = append(args, "--pos-type", posType)
}
if paper_size != "" {
args = append(args, "--paper_size", paper_size)
}
if orientation != "" {
args = append(args, "--orientation", orientation)
}
args = append(args, "--count", fmt.Sprintf("%d", count))
if outFile != "" {
args = append(args, "-o", outFile)
}
args = append(args, inFile, "placeholder.pdf")
logger.Println(args)
return a.cmdRunner(args, "pdf")
}
func (a *App) ReplacePDF(inFile1 string, inFile2 string, srcPages string, dstPages string, outFile string) error {
logger.Printf("inFile1: %s, inFile2: %s, srcPages: %s, dstPages: %s, outFile: %s\n", inFile1, inFile2, srcPages, dstPages, outFile)
args := []string{"replace"}
if srcPages != "" {
args = append(args, "--src_page_range", srcPages)
}
if dstPages != "" {
args = append(args, "--dst_page_range", dstPages)
}
if outFile != "" {
args = append(args, "-o", outFile)
}
args = append(args, inFile1)
args = append(args, inFile2)
logger.Println(args)
return a.cmdRunner(args, "pdf")
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化