Link to home
Start Free TrialLog in
Avatar of wnerbun
wnerbunFlag for United States of America

asked on

Merge two pdf documents using Ghostscript

I have just installed Ghostscript 8.54. It works great. Does anyone know of a way to use ghostscript to merge the printed document with another pdf document on file (eg. C:\Temp\test.pdf)? I am using the email function to attach the created document to the Outlook Message form that opens.
Avatar of rockiroads
rockiroads
Flag of United States of America image

there is this toolkit called pdftk that may help you  http://www.accesspdf.com/pdftk/

and according to this, u can use ghostscript and run it as a dos command

gswin32 -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=Merged.pdf -dBATCH 1.pdf 2.pdf 3.pdf

taken from
https://www.cs.tcd.ie/Shane.OConchuir/Misc/MergingPDFs.html

Avatar of wnerbun

ASKER

I've tried both of the following as an event procedure to merge two files (15100.pdf and eSurvey.pdf) and neither work:
gswin32 -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=Merged.pdf -dBATCH 15100.pdf eSurvey.pdf
or
pdftk 15100.pdf eSurvey.pdf cat output merged.pdf

I've tried adding the path to the statement and that does not seem to help. Any ideas as to what I'm doing wrong?
Avatar of wnerbun

ASKER

evidently my Ghostscript and pdftk programs are "not registered" because when I run the command line from Start\Run, I get the following message: "Windows cannot find pdfgk." (or gswin32). How do I register the program with windows?
Avatar of wnerbun

ASKER

ok, I registered the program and can now run it from the Start\Run window, but now I'm trying to figure out how to get it to execute from a Command Button on my form. Anyone know the proper syntax??
Hi wnerbun,

I dont have Ghostscript hence the link supplied

Regarding the code however, that I can do

Now, how do u determine what pdf files u want merging?
Avatar of wnerbun

ASKER

file #1 path=C:\VendorPDFs\[Vendor].pdf (e.g., 15100.pdf)
file #2 path=C:\VendorPDFs\eSurvey.pdf

merged file name and path=C:\VendorPDFs\VendorSurvey.pdf
ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wnerbun

ASKER

The following statement works:
gswin32 -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE="C:\VendorPDFs\Merged.pdf" -dBATCH C:\VendorPDFs\15100.pdf C:\VendorPDFs\eSurvey.pdf

I will  try your shell command today.
Avatar of wnerbun

ASKER

Eureka! Kudos! Bravo Zulu! You've solved my problem! Points to you!!!