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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - MergeFileListe - overwritten
  FAQ FAQ  Forum Search   Register Register  Login Login

MergeFileListe - overwritten

 Post Reply Post Reply
Author
Message
marcus View Drop Down
Beginner
Beginner


Joined: 03 Apr 13
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote marcus Quote  Post ReplyReply Direct Link To This Post Topic: MergeFileListe - overwritten
    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



Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post 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.


Back to Top
marcus View Drop Down
Beginner
Beginner


Joined: 03 Apr 13
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote marcus Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
theowlpo View Drop Down
Beginner
Beginner


Joined: 18 May 13
Location: Portugal
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote theowlpo Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store