72 Star 907 Fork 300

Kevin2li / PDF-Guru

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
background.go 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
Kevin2li 提交于 2023-07-18 15:06 . refactor
package main
import "fmt"
func (a *App) AddPDFBackgroundByImage(inFile string, imgFile string, outFile string, opacity float32, angle float32, x_offset float32, y_offset float32, scale float32, pages string) error {
logger.Printf("inFile: %s, outFile: %s, imgFile: %s, opacity: %f, angle: %f, x_offset: %f, y_offset: %f, pages: %s\n", inFile, outFile, imgFile, opacity, angle, x_offset, y_offset, pages)
args := []string{"bg", "--type", "image"}
if imgFile != "" {
args = append(args, "--img-path", imgFile)
}
args = append(args, "--opacity", fmt.Sprintf("%f", opacity))
args = append(args, "--angle", fmt.Sprintf("%f", angle))
args = append(args, "--x-offset", fmt.Sprintf("%f", x_offset))
args = append(args, "--y-offset", fmt.Sprintf("%f", y_offset))
args = append(args, "--scale", fmt.Sprintf("%f", scale))
if pages != "" {
args = append(args, "--page_range", pages)
}
if outFile != "" {
args = append(args, "-o", outFile)
}
args = append(args, inFile)
logger.Println(args)
return a.cmdRunner(args, "pdf")
}
func (a *App) AddPDFBackgroundByColor(inFile string, outFile string, color string, opacity float32, angle float32, x_offset float32, y_offset float32, pages string) error {
logger.Printf("inFile: %s, outFile: %s, color: %s, opacity: %f, angle: %f, x_offset: %f, y_offset: %f, pages: %s\n", inFile, outFile, color, opacity, angle, x_offset, y_offset, pages)
args := []string{"bg", "--type", "color"}
if color != "" {
args = append(args, "--color", color)
}
args = append(args, "--opacity", fmt.Sprintf("%f", opacity))
args = append(args, "--angle", fmt.Sprintf("%f", angle))
args = append(args, "--x-offset", fmt.Sprintf("%f", x_offset))
args = append(args, "--y-offset", fmt.Sprintf("%f", y_offset))
if pages != "" {
args = append(args, "--page_range", pages)
}
if outFile != "" {
args = append(args, "-o", outFile)
}
args = append(args, inFile)
logger.Println(args)
return a.cmdRunner(args, "pdf")
}
Go
1
https://gitee.com/Kevin234/PDF-Guru.git
git@gitee.com:Kevin234/PDF-Guru.git
Kevin234
PDF-Guru
PDF-Guru
main

搜索帮助