Solved

Merge PDFs from VB 6 Application

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month6 days, 11 hours left to enroll

636 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