Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
MergeFileListe - overwritten |
Post Reply
|
| Author | |
marcus
Beginner
Joined: 03 Apr 13 Status: Offline Points: 5 |
Post Options
Thanks(0)
Quote Reply
Topic: MergeFileListe - overwrittenPosted: 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 |
|
![]() |
|
AndrewC
Moderator Group
Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
Quote Reply
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. |
|
![]() |
|
marcus
Beginner
Joined: 03 Apr 13 Status: Offline Points: 5 |
Post Options
Thanks(0)
Quote Reply
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 |
|
![]() |
|
theowlpo
Beginner
Joined: 18 May 13 Location: Portugal Status: Offline Points: 3 |
Post Options
Thanks(0)
Quote Reply
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
|
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store