Solved

Merge PDFs from VB 6 Application

Posted on 2011-03-12
2
1,032 Views
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.

0
Comment
Question by:mlmcc
2 Comments
 
LVL 11

Accepted Solution

by:
kbirecki earned 176 total points
ID: 35121315
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
 
LVL 100

Author Comment

by:mlmcc
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

mlmcc
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

746 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

11 Experts available now in Live!

Get 1:1 Help Now