Merge PDFs from VB 6 Application

I have a VB6 application that creates PDF files.  I need to merge the PDFs into a single files.  Because of the method of PDF creation exporting reports, the PDFs cannot be created as a single file.

I have searched for tools to merge them but most seem to be a command line interface or their own interface.  Are there any inexpensive tools for merging PDFs through VB6 code.  my client has a PDF merge tool and is willing to do that since they are creating the individual PDF then merging them today.  My application is automating the processing of producing the reports and if they could have a single file as the result it would be better than having to manually merge the files.  There could be up to around 100 files but most of the time it will be reasonable in the 5-25 range.

LVL 101
mlmccAsked:
Who is Participating?
 
kbireckiConnect With a Mentor Commented:
Here are some options:
1) PDFCreator - Open source PDF utility written in VB6 available at http://sourceforge.net/projects/pdfcreator/.  You could interact with it through it's hooks or extract out of that the components that do what you need.  Look at frmMain.DocumentCombineAll() as a starting point.  In this case, it's an open source solution.  You'll also need the open source GhostSript as well.  I have taken this project and modified it to suit my needs and it works well.
2) Commercial solutions - http://www.skysof.com/ has a number of PDF related solutions, one is PDF OCX ($49.95).  And a How-To is here: http://www.ehow.com/how_7890935_create-ocx-visual-basic-6.html.  There are other commercial ActiveX solutions (search for "VB6 PDF ActiveX" and you'll find many.)  Some are very expensive, but I don't have any experience with them.
3) Command line (I know, you said you didn't want command line, but this is a *very* easy solution I used for a similar project)  I am currently working with some PDF and imaging tools from within VB6 and although they are command line, it is very quick and easy to use.   When I was looking into this, I only found commercial ($) solutions that looked good, until I ran into PDFTK (www.pdflabs.com).  This is how easy it is to use (from their list of examples):

Merge Two or More PDFs into a New Document
pdftk 1.pdf 2.pdf 3.pdf cat output 123.pdf
or (Using Handles):
pdftk A=1.pdf B=2.pdf cat A B output 12.pdf
or (Using Wildcards):
pdftk *.pdf cat output combined.pdf

It's the "cat" operator you want that concatenates whole PDF's or partial PDF's.  So you could just Shell out to execute these commands and they are very quick.  For myself, instead of using the native Shell command that just spawns the process and continues with the rest of the VB6 code, I use ShellAndWait to make sure the spawned process completes because I have a series of steps to perform.  Maybe this would work for you.  Here's an example command:

ShellAndWait "C:\App\pdftk\pdftk.exe ""C:\test\1.pdf"" ""C:\test\2.pdf"" ""C:\test\3.pdf"" cat output ""C:\test\123.pdf""", vbHide, 2

Open in new window


Reference: Two solutions for ShellAndWait: http://www.vbforums.com/showthread.php?t=505172 and  http://www.cpearson.com/excel/ShellAndWait.aspx
0
 
mlmccAuthor Commented:
Sorry I took so long to respond.  I was hoping more suggestions would be made.

Unfortunately, this is a commercial application and therefore the Open Source is not allowed.  That is a good way to go.

They currently have a tool they use to do this but I was hoping to find a way to automate the process.

Thanks for the information

mlmcc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.