1 Star 0 Fork 355

阿彪/PDF-Guru

forked from Kevin2li/PDF-Guru 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
extract.go 1.36 KB
一键复制 编辑 原始数据 按行查看 历史
Kevin2li 提交于 2023-07-18 15:06 . refactor
package main
func (a *App) ExtractTextFromPDF(inFile string, outFile string, pages string) error {
logger.Printf("inFile: %s, outFile: %s, pages: %s\n", inFile, outFile, pages)
args := []string{"extract", "--type", "text"}
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) ExtractImageFromPDF(inFile string, outFile string, pages string) error {
logger.Printf("inFile: %s, outFile: %s, pages: %s\n", inFile, outFile, pages)
args := []string{"extract", "--type", "image"}
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) OCRExtract(inFile string, outFile string, pages string, extractType string) error {
logger.Printf("inFile: %s, outFile: %s, pages: %s, extractType: %s\n", inFile, outFile, pages, extractType)
args := []string{"ocr", "extract"}
if extractType != "" {
args = append(args, "--type", extractType)
}
if pages != "" {
args = append(args, "--range", pages)
}
if outFile != "" {
args = append(args, "-o", outFile)
}
args = append(args, inFile)
logger.Println(args)
return a.cmdRunner(args, "python")
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/biao0010/PDF-Guru.git
git@gitee.com:biao0010/PDF-Guru.git
biao0010
PDF-Guru
PDF-Guru
main

搜索帮助

0d507c66 1850385 C8b1a773 1850385