Board logo

标题: [文件操作] [已解决]调用kafax power pdf合并PDF [打印本页]

作者: jave000    时间: 2022-3-4 10:45     标题: [已解决]调用kafax power pdf合并PDF

本帖最后由 jave000 于 2022-3-4 13:25 编辑

操作如图,想一键双击就可以合并bat所在文件夹内的所有pdf,按照文件夹当前文件排序,不包含子文件夹。求助代码。
论坛无法上传图片和附件,不知道为啥,使用了外链。
http://
ys-g.ysepan.com/619980429/318582186/jwlwfuu54465F36JHMIH17/
0.PNG
程序路径是:
C:\Program Files (x86)\Kofax\Power PDF 40\bin\PPDFCreate.exe
作者: jave000    时间: 2022-3-4 10:46


作者: Batcher    时间: 2022-3-4 13:07

回复 1# jave000


试试 pdftk 这个命令行工具:
http://bcn.bathome.net/s/tool/index.html?key=pdftk
  1. @echo off
  2. cd /d "%~dp0"
  3. pdftk *.pdf cat output combined.pdf
复制代码

作者: Batcher    时间: 2022-3-4 13:07

回复 2# jave000


你发的图片看不到,换个图床试试吧:
http://bbs.bathome.net/thread-60985-1-1.html
作者: jave000    时间: 2022-3-4 13:14

本帖最后由 jave000 于 2022-3-4 13:26 编辑

回复 4# Batcher


    现在可以看了,之前加密了
不重要,解决了,十分感谢
作者: jave000    时间: 2022-3-9 15:27

回复 4# Batcher


    成功过一次,之后双击bat一直没反应了,报错依次如下:

1.当我放到文件所在文件夹
'pdftk' is not recognized as an internal or external command,
operable program or batch file.

2.当我放到C盘PDFTK的目录下
Error: Failed to open PDF file:
   DIN 16965-1-1982.pdf
   OWNER PASSWORD REQUIRED, but not given (or incorrect)
Error: Failed to open PDF file:
   DIN 16965-2-1982.pdf
   OWNER PASSWORD REQUIRED, but not given (or incorrect)
Error: Failed to open PDF file:
   DIN 16965-4-1982.pdf
   OWNER PASSWORD REQUIRED, but not given (or incorrect)
Error: Failed to open PDF file:
   DIN 16965-5-1982.pdf
   OWNER PASSWORD REQUIRED, but not given (or incorrect)
Errors encountered.  No output created.
Done.  Input errors, so no output created.

3.当我使用带有中文的文件名(我们必须使用英文系统)
Error: Unable to find file.
Error: Failed to open PDF file:
   DIN 16965-1-1982 Σ╕ÇΣ║îΣ╕ëσ¢¢.pdf
Error: Unable to find file.
Error: Failed to open PDF file:
   DIN 16965-2-1982 Σ╕ÇΣ║îΣ╕ëσ¢¢.pdf
Error: Unable to find file.
Error: Failed to open PDF file:
   DIN 16965-4-1982 Σ╕ÇΣ║îΣ╕ëσ¢¢.pdf
Error: Unable to find file.
Error: Failed to open PDF file:
   DIN 16965-5-1982 Σ╕ÇΣ║îΣ╕ëσ¢¢.pdf
Errors encountered.  No output created.
Done.  Input errors, so no output created.

请问有没有更好的方法,不局限于bat
我需要将PDF\DOC\DOCX\XLS\XLSX\XLSM\MSG\TXT\PNG\JPG等按照文件名排序批量合并,如果只有单个文件,就相当于一键打印。其中MSG是outlook的邮件。
作者: Batcher    时间: 2022-3-9 15:40

回复 6# jave000


试试这样能否解决问题1和问题2:

假设你的pdftk.exe的完整路径是C:\PDFTK\pdftk.exe
把3楼代码最后一行改成这样:
"C:\PDFTK\pdftk.exe" *.pdf cat output combined.pdf

确保bat文件和pdf文件在同一个目录下
作者: Batcher    时间: 2022-3-9 16:02

回复 6# jave000


我也用的英文操作系统,合并中文pdf没有问题。
你可以试试把系统区域设置里面的【非Unicode程序语言】设置成中文再试试。
  1. @echo off
  2. REM 请根据自己电脑实际情况设置该路径
  3. set "path=C:\Program Files (x86)\PDFtk Server\bin;%path%"
  4. cd /d "%~dp0"
  5. pdftk.exe 联通.pdf 移动.pdf cat output 合并.pdf
复制代码

作者: jave000    时间: 2022-3-9 23:16

回复 7# Batcher


    找不到路径,文件放在程序目录下也无法运行,我也没想到改成绝对路径名,惭愧,感谢,我明天试试
作者: jave000    时间: 2022-3-17 12:25

Error: Unable to find file.
Error: Failed to open PDF file:
   2021σ╣┤σ┐àΣ┐«(τ¢┤μÆ¡∩╝ëΦ»╛τ¿ïμèÑσéìμ╡üτ¿ï.pdf
Error: Unable to find file.
Error: Failed to open PDF file:
   2021σ╣┤σ┐àΣ┐«∩╝êτ¢┤μÆ¡∩╝ëΦ»╛τ¿ïΦÇaσïñσÆîΦÇaμá╕τ¢╕σà│Φoäσ«ü.pdf
Error: Unable to find file.
Error: Failed to open PDF file:
   2021σ╣┤ΘÇëΣ┐«Φ»╛τ¿ïμèÑσéìπÇüσ¡aΣ╣áσƒ║μ£¼μôìΣ╜£μ╡üτ¿ï.pdf
Error: Unable to find file.
Error: Failed to open PDF file:
   τ¢┤μÆ¡μ╡üτ¿ïσ¢╛.pdf
Errors encountered.  No output created.
Done.  Input errors, so no output created.
Press any key to continue . . .




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2