1 Star 0 Fork 354

honiswang/PDF-Guru

forked from Kevin2li/PDF-Guru 
Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
insert.go 2.20 KB
Copy Edit Raw Blame History
Kevin2li authored 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")
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/whyfree/PDF-Guru.git
git@gitee.com:whyfree/PDF-Guru.git
whyfree
PDF-Guru
PDF-Guru
main

Search

0d507c66 1850385 C8b1a773 1850385