Print Page | Close Window

AddToFileList not working....

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=1339
Printed Date: 22 Nov 24 at 2:35PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: AddToFileList not working....
Posted By: agent86
Subject: AddToFileList not working....
Date Posted: 06 Feb 10 at 6:23PM

Delphi 7
QPDF 0717

When I merge files using the following procedure I get 1 blank page.  The resulting document has the correct name but no contents.  I've searched in vain for what I'm doing wrong.  I've looked at the Delphi demos and can't see what I'm doing wrong.  I've already searched the forum but there is no sample code to show how to successfully use AddToFileList and MergeFileList. 

I'm still evaluating Quick PDF but this is one of my last hurdles before I buy. 

procedure TAutoPrintMainFormForm.MergeEmailPDFsQPDF ;
var source, destination, pname : string ;
   i : integer ;
   Unlockresult : integer ;
   QPDF : TQuickPDF0717 ;
   groupfolder, problemsfolder, pdftempfolder : string ;
   sFileName, pdfname : AnsiString ;
begin
   try
     QPDF := TQuickPDF0717.Create ;
     UnlockResult := QPDF.UnlockKey(QPDFKey);

     QPDF.ClearFileList(sFileName) ;

     // add pdfs to list for merging
     for i := 0 to EmailPDFsFolderMemo.Lines.Count - 1 do
     begin
       // filename with path
       pdfname := Trim(EmailPDFsFolderMemo.Lines) ;
       QPDF.AddToFileList( sFileName, pdfname );
     end ;

     // make folder if it does not exist

     groupfolder := EmailPDFProcessFolderDBEdit.Text + '\' +
                    EmailFolderName ;

     // does folder already exist? if not create

     if not ( DirectoryExists ( groupfolder ) ) then
     begin
       ForceDirectories ( groupfolder ) ;
     end ;

     MergedPDFName := groupfolder + '\' +
                      EmailTransactionDateTime + '_' +
                      EmailFolderName + '.pdf' ;

     QPDF.MergeFileList( sFileName, MergedPDFName ) ;

     QPDF.SaveToFile(MergedPDFName) ;

   finally
     QPDF.Free ;
   end ;
  
end;




Replies:
Posted By: Wheeley
Date Posted: 06 Feb 10 at 11:38PM
You are overwriting your merged file with a blank page. Remove the line QPDF.SaveToFile(MergedPDFName). Also don't forget to clear the file list before you do the free.

Wheeley



Posted By: agent86
Date Posted: 06 Feb 10 at 11:56PM
Thanks!  That took care of it.  Now I only have to deal with what happens when there is only 1 file in the folder.



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