Merge PDFs from VB 6 Application

Posted on 2011-03-12
Last Modified: 2013-12-20
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.

Question by:mlmcc
LVL 11

Accepted Solution

kbirecki earned 176 total points
ID: 35121315
Here are some options:
1) PDFCreator - Open source PDF utility written in VB6 available at  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 - has a number of PDF related solutions, one is PDF OCX ($49.95).  And a How-To is here:  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 (  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: and
LVL 100

Author Comment

ID: 35203313
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


Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

830 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