?
Solved

Merge two pdf documents using Ghostscript

Posted on 2006-11-20
9
Medium Priority
?
1,068 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 17985472
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
ID: 17988229
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
ID: 17997655
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
Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

 

Author Comment

by:wnerbun
ID: 17997911
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
 
LVL 65

Expert Comment

by:rockiroads
ID: 17998256
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
ID: 18007966
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 2000 total points
ID: 18008161
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
ID: 18019821
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
ID: 18020388
Eureka! Kudos! Bravo Zulu! You've solved my problem! Points to you!!!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
Suggested Courses

777 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