|
-
May 25th, 2010, 10:27 AM
#1
Thread Starter
PowerPoster
[RESOLVED] Combining PDF files
I have a routine that uses Crystal reports. It generates 2 PDF files. Now, I want to arrive at one PDF file that combines those two. Sales does not want to continue sending two files to the customer. Unfortunately, which two reports get generated is determined by what gets entered by the sales person, so I really can't hard code it. For instance, I have five different page one reports and three different page two reports. So, if I hard coded it, I would have to choose between 15 different report (combinations) in order to create one file. In addition, I would have 15 reports to maintain, rather than five or three, if things change.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
May 25th, 2010, 10:36 AM
#2
Re: Combining PDF files
Why not download a freeware which does what you want?
http://www.brothersoft.com/pdf-merge-25708.html
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 25th, 2010, 10:37 AM
#3
Thread Starter
PowerPoster
Re: Combining PDF files
Unfortunately, the security implemented at my company does not allow me to download freeware. Arghh...
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
May 25th, 2010, 10:43 AM
#4
Re: Combining PDF files
 Originally Posted by Pasvorto
Unfortunately, the security implemented at my company does not allow me to download freeware. Arghh...
lolz...
See if this helps then 
http://www.eggheadcafe.com/community...e-two-pdf.aspx
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 25th, 2010, 10:45 AM
#5
Thread Starter
PowerPoster
Re: Combining PDF files
Certainly a place to start. Thanks. I was hoping for something easy, like a shell command that concatenates the files. But, nothing is easy, right?
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
May 25th, 2010, 10:47 AM
#6
Re: Combining PDF files
Wish it was that easy... 
Or maybe I don't know of such a method if it exists...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 25th, 2010, 12:21 PM
#7
Addicted Member
Re: Combining PDF files
I was hoping for something easy, like a shell command that concatenates the files. But, nothing is easy, right?
Actually it is that easy with a tried and true utility... pdftk. It's used in companies large and small and has been for years. To merge multiple pdf files you would shell the following one liner"
pdftk file1.pdf file2.pdf cat output 123.pdf
Your problem is your company. They need to provide you the tools necessary to accomplish your assigned task at hand. If you can't download freeware, I would campaign for having whoever can download freeware to obtain this tool for you.
If your company has a policy against using freeware period then your company needs to purchase the tools you need. A relatively inexpensive, but powerful, piece of PDF manipulation software is QuickPDF.
Here are the web links for each.
For pdftk: http://www.pdftk.com/#docs
For QuickPDF: http://www.quickpdflibrary.com/promo...vb-activex.php
Good luck!
-
May 25th, 2010, 12:25 PM
#8
Re: Combining PDF files
Very True Tom. It is very easy only if the company policies allow it. Else I am not aware of this possible with any inbuilt windows utilities.
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 25th, 2010, 12:45 PM
#9
Addicted Member
Re: Combining PDF files
Very True Tom. It is very easy only if the company policies allow it. Else I am not aware of this possible with any inbuilt windows utilities.
You're absolutely correct. There is no native windows or VB6 solution AFAIK. Even if he were to use the egghead code referred in your earlier post... that requires Adobe Acrobat which is a far more expensive solution if the company doesn't already own it.
I don't understand some companies... they ask you to perform a task and then don't (or won't) provide the proper tools. It's like handing a box of nails to a carpenter and telling him to go pound nails and not providing (or allowing him to obtain) a hammer.
Sheesh!
-
May 25th, 2010, 12:50 PM
#10
Re: Combining PDF files
I don't understand some companies... they ask you to perform a task and then don't (or won't) provide the proper tools.
Ask me about it 

I am from a non software background (Basically I am from BPO Operations) and I help them with their websites, Excel Macros, small vb6 programs but they refuse to give me vb6 or a basic HTML Editor...!!!!
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
May 25th, 2010, 01:40 PM
#11
Thread Starter
PowerPoster
Re: Combining PDF files
I'm told to swim upstream. "Oh, by the way, can you take this anvil along with you?"
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
May 26th, 2010, 08:24 AM
#12
Thread Starter
PowerPoster
Re: Combining PDF files
OK. I was able to get a copy of pdftk. It works pretty slick in manual mode. Now, I need to be able to use a shell command to invoke it. I have no problem with the Shell command, per se. However, at the time I need to combine the PDFs, I don't have their names. The program creates the PDF by concatenating a couple variables and adding the PDF suffix. From what I can see of pdftk, I either need the supply a name or "PROMPT". I can't use PROMPT because, in addition to being a PITA, the user would not have that information at hand.
If any of you pdftk experts could give me some direction, I would be most appreciative.
Thanks.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
May 26th, 2010, 09:34 AM
#13
Thread Starter
PowerPoster
Re: Combining PDF files
I added thsi code:
Code:
'-------------------
' test PDF merging
'-------------------
'
Dim RESULT As Integer
Dim parm1 As String
Dim parm2 As String
Dim PARM3 As String
Dim output As String
Dim strfolder As String
strfolder = "Z:\DAD\QUOTES\"
parm1 = strfolder & glbQuoteNumber & "Quote.pdf"
parm2 = strfolder & glbQuoteNumber & "Quote Page 2.pdf"
PARM3 = strfolder & glbQuoteNumber & "TEST COMBINED PDF.PDF"
output = strfolder & PARM3
RESULT = Shell(strfolder & " PDFTK.EXE " & parm1 & " " & parm2 & " CAT OUTPUT " & output)
'
'---------------------
I get an invalid procedure call on the RESULT = line
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
May 26th, 2010, 09:48 AM
#14
Thread Starter
PowerPoster
Re: Combining PDF files
I changed the code to read:
Code:
PARM3 = strfolder & glbQuoteNumber & "TEST COMBINED PDF.PDF"
output = PARM3
call Shell(strfolder & " PDFTK.EXE " & parm1 & " " & parm2 & " CAT OUTPUT " & output)
I don't get the error anymore, but it does not create the merged file either. I traced it and the line is being processed.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
May 26th, 2010, 10:04 AM
#15
Addicted Member
Re: Combining PDF files
1. The reason you don't get the error is you origially Dimmed RESULT as an integer. The return for a Shell command should be dimmed as Variant.
2. Take out leading space in PDFTK.EXE. Right now your sending SHELL "Z:\DAD\QUOTES\ PDFTK.EXE" It should be Z:\DAD\QUOTES\PDFTK.EXE
3. My guess is qlbQuoteNumber may also be giving you unwanted spaces. I don't see that variable declared in your code so I'm guessing it's an Integer. Trim it and assign to string before you assign it to another string variable. Ex: qlbQuoteNum$ = Trim(Str(qlbQuoteNumber)). Then pass the String instead of the Integer.
Be careful of spaces! Even in filenames. I generally make it a practice to replace spaces in file names with an Underscore, _ , instead of a space.
Tom
-
May 26th, 2010, 10:15 AM
#16
Thread Starter
PowerPoster
Re: Combining PDF files
Trial and error has shopw that the spaces are the problem.
This screws it up ""Quote Page 2.pdf"". When I use "Quote_Page_2.pdf" and "TEST_COMBINED_PDF.PDF", everything works fine. So, if I can't get around the spaces, I need to change the routine that creates the page 2 document to add the underscore.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
May 26th, 2010, 10:19 AM
#17
Addicted Member
Re: Combining PDF files
Cool! Glad you got it.
Spaces can be evil
-
May 26th, 2010, 10:57 AM
#18
Thread Starter
PowerPoster
Re: Combining PDF files
Yeah, I hear ya. Spaces, quotes, and DOS (command line) just don't mix.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|