Combine all files in a folder as pdf

青春壹個敷衍的年華 提交于 2019-12-24 00:36:52

问题


My current problem is that starting from the root folder I have to look into each folder and if one file exists then save it as a pdf with the folder name in a different location. If more then one file exists then combine this into one file, save it as a pdf with the folder name in a different location.

Example:

- Root Folder
    - Folder1
        - FileA.tif
        - FileB.tif
    - Folder2
        - FileC.tif                          

- Result Folder
    - Folder1.pdf (Contains FileA.tif and FileB.tif combined into one pdf)
    - Folder2.pdf (Contains FileC.tif as pdf)

I am currently using Acrobat 9 Professional. I know I can do this manually, but I have to do this for hundreds of folders and each folder has one or more files.

My preffered solution would be in Acrobat Javascript on Windows XP.

Somethings that I am trying to figure out is if I can do some sort of:

  • For each folder in Root Folder
  • For each file in folder (Save the folder name too)
  • Combine files (I think I can mange this based on some examples I have seen)

I think that would give me a good start.

Any help would be greatly appreciated.


回答1:


GhostView is a command-line program that can manipulate PDF files. Years ago, I used this to concatenate thousands of PDF files into a single PDF for download. It can convert multiple file types to PDF, plus you can apply all of the PDF security options to your final PDF as needed. You'll need the commercial version if you're packaging this for a product.




回答2:


I am trying to solve the same problem here. You need to install GhostScript and use some bat file to do the job.


I started to write this:

@echo off 
    set folpath=%~dp0
    set PROG="c:\Program Files\gs\gs9.04\bin\gswin64"
    set OUT= "%folpath%Combined.pdf"

    pushd "%~dp0"            

    call %PROG% -o %OUT% -sOUTPUTFILE="%folpath%Merged.pdf" -dBATCH  "%folpath%doc2.pdf" "%folpath%doc1.pdf"
    pause

But it is not ready :)



来源:https://stackoverflow.com/questions/8156126/combine-all-files-in-a-folder-as-pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!