You can do this for free (using PDFs, not Blobs) using the PDFtk control.
https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/
long ll_row
long ll_rows
string ls_pdf_type
string ls_file
string ls_file_list
string ls_run
int li_seqnum
int li_filenum
blob b_pdf
boolean lbl_have_pdfs = false
SetPointer(HourGlass!)
//Checks if the Directory Exists
if (DirectoryExists("C:\_APPS\HazardousWaste\CombinedPDFs")) then
//Populates LB with contents of directory
lb_pdf.DirList("C:\_APPS\HazardousWaste\CombinedPDFs", 0)
//Total # of Items
ll_rows = lb_pdf.TotalItems()
//Removes all files in the directory
for ll_row = 1 to ll_rows
lb_pdf.SelectItem(ll_row)
lb_pdf.DirSelect(ls_file)
FileDelete(ls_file)
next
else
//Directory doesn't exist, so create it
CreateDirectory("C:\_APPS\HazardousWaste\CombinedPDFs")
end if
//Cursor to gather all the addtional PDFs for the Incident
declare pdf cursor for
select pdf_type, seq_num
from hwp_pdfs
where incident_num = :s_email.incident_num
order by pdf_type, seq_num;
//Open cursor
open pdf;
//Gets first row of data
fetch pdf into :ls_pdf_type, :li_seqnum;
//Loops through the rows
do while(SQLCA.SQLCode = 0)
//Gets the PDF
selectblob pdf_file
into :b_pdf
from hwp_pdfs
where incident_num = :s_email.incident_num
and pdf_type = :ls_pdf_type
and seq_num = :li_seqnum;
//Open a file for writing
li_filenum = FileOpen("C:\_APPS\HazardousWaste\CombinedPDFs\" + ls_pdf_type + string(li_seqnum) + ".pdf", StreamMode!, Write!)
//Saves the PDF as a file
FileWriteEx(li_filenum, b_pdf)
//Closes file
FileClose(li_filenum)
//Changes flag
lbl_have_pdfs = true
//Gets the next row of data
fetch pdf into :ls_pdf_type, :li_seqnum;
loop
//Close cursor
close pdf;
//We have some PDFs
if (lbl_have_pdfs) then
//Fills LB with contents of directory
lb_pdf.DirList("C:\_APPS\HazardousWaste\CombinedPDFs", 0)
//Gets the # of files
ll_rows = lb_pdf.TotalItems()
//Loops through all the files and creates a File List
for ll_row = 1 to ll_rows
lb_pdf.SelectItem(ll_row)
lb_pdf.DirSelect(ls_file)
if (ll_row = 1) then
ls_file_list = "C:\_APPS\HazardousWaste\CombinedPDFs\" + ls_file
else
ls_file_list += " " + "C:\_APPS\HazardousWaste\CombinedPDFs\" + ls_file
end if
next
//Runs the tool to combine the PDFs
ls_run = 'C:\_APPS\HazardousWaste\pdftk "\\Waste-16FS01\ENVR$\Waste Inspection\Incident Reports\PDFs\Incident_' + string(s_email.incident_num) + '.pdf" ' &
+ ls_file_list + ' cat output ' + 'C:\_APPS\HazardousWaste\CombinedPDFs\Incident_' + string(s_email.incident_num) + 'Combined.pdf'
inv_run.of_run(ls_run, Normal!)
//Specify the new PDF to email
s_email.alternate_pdf_path = "C:\_APPS\HazardousWaste\CombinedPDFs\"
s_email.alternate_pdf_file = "Incident_" + string(s_email.incident_num) + "Combined.pdf"
end if
For those wondering what "inv_run" is, my guess is that you've used Roland's "RunAndWait" code that can be downloaded from topwizprogramming.com.
regards,
miguelL