Print Page | Close Window

MergeFileListe - overwritten

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2657
Printed Date: 04 Apr 26 at 7:52PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: MergeFileListe - overwritten
Posted By: marcus
Subject: MergeFileListe - overwritten
Date Posted: 30 May 13 at 10:15AM
Hi,

i have a vbscript to collecting a lot of pdf files (sorting by customer) to one pdf with a cover page (per customer).

There a 2 database queries with a loop but at the end the script is overwritting the output pdf and the result are only the last database entry.


------ Source Code ------
DateRevers = Right(Year(Date),2) & String(2-Len(Month(Date)), "0") & Month(Date) & String(2-Len(Day(Date)), "0") & Day(Date)
NewDate = Right(date,4)&"-"&MID(date,4,2)&"-"&Left(date,2)

' --- Erstellen der Datenbankverbindung

Set Conn = CreateObject("ADODB.Connection")
    conn.ConnectionTimeout = 120
    conn.open "<databaseconnection>"

' --- SQL-Statement erstellen
    SQL = "Select customerno,company,count(invoiceno) from invoice_manager group by customerno,company order by customerno"

Set RS = CreateObject("ADODB.Recordset")
    RS.Open SQL, Conn, 3, 3


IF rs.BOF And rs.EOF then
rs.Close
Set rs = Nothing
    conn.Close
Set conn = Nothing


else


rs.MoveFirst
do while Not rs.eof

' -------------------------- PDF Cover

Dim QP
Dim FontID1
Dim FontID2

Set QP = CreateObject("DebenuPDFLibrary64AX0913.PDFLibrary")

Call QP.UnlockKey("XXXXXXXXXXXXXXXXXXXXXX")
QP.ClearFileList("DE")
QP.SetTempPath("d:\temp")

fontID1 = QP.AddStandardFont(4) 'Helvetica
fontID2 = QP.AddStandardFont(5) 'Helvetica bold

Call QP.SelectFont(fontID1)

Call QP.SetTextSize(25)
Call QP.DrawText(100, 550, "INVOICE PRINT OUT")
Call QP.DrawText(100, 500, date & " / "&time)

Call QP.SelectFont(fontID2)
Call QP.SetTextSize(35)
Call QP.DrawText(50, 400, rs(1))
Call QP.DrawText(50, 350, "No. "&rs(0))
Call QP.DrawText(50, 300, "Total invoices: "&rs(2))

QP.SaveToFile("de_print_cover_"&rs(0)&".pdf")

SQL1 = "SELECT [filename] from invoice_manager where customerno = '" & RS(0) & "'"

Set RS1 = CreateObject("ADODB.Recordset")
    RS1.Open SQL1, Conn, 3, 3

Call QP.AddToFileList("DE","de_print_cover_"&rs(0)&".pdf") ' add Cover Page to LIST DE

rs1.MoveFirst
do while Not rs1.eof

Call QP.AddToFileList("DE",rs1(0)) ' add single invoice pdfs to List DE
       
RS1.MoveNext
Loop


rs1.Close
set rs1=nothing


RS.MoveNext
Loop

Call QP.MergeFileListFast("DE","invoice.pdf") 'output file


    RS.Close
  Conn.Close


set rs=nothing
set conn=nothing

Set QP = Nothing
 
end if
---------------------

I have 4 entries in the database and the script creating 4 Coverpages but the ouput files contain the last database entry only - why ?

THanks for your help

Marcus






Replies:
Posted By: AndrewC
Date Posted: 04 Jun 13 at 4:03AM
Marcus,

You will need to do some debugging.  Make sure RS1 does in fact have 4 records selected.   Add some debug statements to  MessageBox  ("de_print_cover_"&rs(0)&".pdf"); or similar.  I am no VB expert.  Are the filenames valid and unique ?

Check the return value of QP.MergeFileListFast to see if it returns 4 pages merged. 

Andrew.




Posted By: marcus
Date Posted: 06 Jun 13 at 8:23AM
Hi Andrew,

thanks for your post - i just found a solution for my problem. But on the other hand a have a new one.

If i create the cover pages with content from the data base in a loop the content on the cover are always overwritten. So the first cover pages was fine and stored, the second cover pages had the content of the first as well and so on...

Do you have a idea to clear the "memory" after QP.SaveToFile("de_print_cover_"&rs(0)&".pdf")

Thanks

Marcus


Posted By: theowlpo
Date Posted: 06 Jun 13 at 4:10PM
Hi
 
To remove from memory, after saving the doc, execute the following:
 
qp.RemoveDocument(qp.SelectedDocument)
 
Regards,
Antonio



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk