Solved

Merge two pdf documents using Ghostscript

Posted on 2006-11-20
9
993 Views
Last Modified: 2013-12-02
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.
0
Comment
Question by:wnerbun
  • 6
  • 3
9 Comments
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
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

0
 

Author Comment

by:wnerbun
Comment Utility
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?
0
 

Author Comment

by:wnerbun
Comment Utility
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?
0
 

Author Comment

by:wnerbun
Comment Utility
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??
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
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?
0
 

Author Comment

by:wnerbun
Comment Utility
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
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
Comment Utility
so is this line working?
gswin32 -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=Merged.pdf -dBATCH 15100.pdf eSurvey.pdf


if so, u can try using Shell command

dim sVendor as string

'say u set your vendor here, it could be a form variable like Me.vendor or something
sVendor = "15100"

chdir("C:\VendorPDF")
Shell("gswin32 -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=eSurvey.pdf -dBATCH " & sVendor & ".pdf")


another way is to create a temp dos batch script and run that

dim iHandle as integer
dim sFile as String

sFile="tmp.bat"
iHandle = freefile
open sFile for output as #iHandle
print #iHandle, "Cd \VendorPDF"
print #iHandle, "gswin32 -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=eSurvey.pdf -dBATCH " & sVendor & ".pdf"
close iHandle

Shell("tmp.bat")

0
 

Author Comment

by:wnerbun
Comment Utility
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.
0
 

Author Comment

by:wnerbun
Comment Utility
Eureka! Kudos! Bravo Zulu! You've solved my problem! Points to you!!!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Update 21-May-2015: I temporarily removed the source code to make major changes to the program. Regards, Joe INTRODUCTION This article presents a solution to a question (http://www.experts-exchange.com/Programming/Installation/Q_28396542.html)…
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
We often encounter PDF files that are pure images, that is, they do not have text characters, but instead contain only raster graphics. The most common causes of this are document scanning software and faxing software/services that create image-only…
This video Micro Tutorial is the first in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 (http://www.experts-exchange.com/articles/17490/). But the ability to create custom scanning profiles al…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now