Solved

Merge PDFs from VB 6 Application

Posted on 2011-03-12
2
1,047 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
[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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…

738 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