Print Page | Close Window

access violations merging PDFs

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=3326
Printed Date: 29 Apr 24 at 6:03AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: access violations merging PDFs
Posted By: pdsdev
Subject: access violations merging PDFs
Date Posted: 11 May 16 at 8:42PM
seems i can use MergeList or MergeListFast for 2 files but when i add a third file i get an access violation.
it also fails the second time i call the procedure even with 2 files. 
basically, i get 1 call - for 2 files only.  3 files on the first call or a 2nd call fails.
and it only AVs on the actual Merge call...

any ideas would be appreciated...

btw - i get the same errors trying to use the activeX component - 
merge 2 files ok, 2nd merge fails.

here's my code...

procedure TMainForm.Merge1Click(Sender: TObject);
var
done : boolean;
fn1, fn2, ftmp, savename, listname :string;
zz, i, ures : Integer;
dqpl : TDebenuPDFLibrary1212;
begin

savedlg.Title := 'Enter Your Save File Name';
savedlg.Execute;
savename := savedlg.FileName;
if savename = '' then exit;
if pos('.PDF',Uppercase(savename)) = 0 then
   savename := savename +'.PDF';


// open file - get first file
opendlg.Title := 'Select your initial PDF file to merge ';
opendlg.execute;
fn1 := opendlg.FileName;
if fn1='' then exit;
listname:= 'mergeList';

dqpl := TDebenuPDFLibrary1212.Create();
ures:= dqpl.UnlockKey('key here');

if ures = 1 then begin


    DQPL.ClearFileList(listname);
    DQPL.AddToFileList(listname,fn1);


    done := false;

    // loop
    opendlg.Title := 'Select the PDF file to append ';

    while not done  do begin
        // open file get next
        opendlg.FileName :='';
        opendlg.Execute;
        opendlg.Title := 'Select the PDF next file to append ';

        fn2:= opendlg.FileName;

        DQPL.AddToFileList(listname,fn2);

        // continue/done
        if MessageDlg( 'Done?' ,mtconfirmation,[mbYes,mbNo],0) = mrYes then Done := true;
    end;

    DQPL.MergeFileListFast(listname,savename);

    dqpl.free;

end;


end;




Replies:
Posted By: Ingo
Date Posted: 11 May 16 at 9:12PM
Hi,

it's not easy to read your code...
If you don't select an initial file you'll leave the routine without a free on dqpl.
Access violation means that your code has still access to objects when you start it a second time.
You should use a try...finally...end. In finally you should post your free.



-------------
Cheers,
Ingo



Posted By: pdsdev
Date Posted: 11 May 16 at 9:22PM
that was a wasted post - i told you it fails the first time with more than 2 files in the list.
before i ever get to the free.  i just added that it also fails the second time through hoping that might
give you more info.

i step through it and each part executes til the merge - then access viol.
when i test the 2 passes - it does do the free. doesn't matter.
is there some kind of clear or release that i need to do??
 
is there any kind of restriction on the file list - they are all fully qualified file names (including the directories).

sal



Posted By: Ingo
Date Posted: 11 May 16 at 9:34PM
Hi,

first i've thought i shouldn't waste my free time here but ... 
Here's a sample from Wilbur:
http://www.quickpdf.org/forum/problem-with-mergefilelistfast-in-delphi_topic3309_post13174.html?KW=MergeFileListFast#13174
Here's another sample:
http://www.quickpdf.org/forum/how-to-use-this-function_topic2087.html
Something relevant from the kb:
http://www.debenu.com/kb/merge-pdf-files-together-programmatically/
On page 28/29 of the developer guide you'll find a working sample, too.

But first you should clean and restructure your code ;-)
The functionality is an old one - so you can be sure that the prob isn't the lib.
To find the prob you should always look what's the content of your variables.
After each call you should check if the call was okay or not.
Additionally there's the function LastErrorCode. ... A lot you can do ...



-------------
Cheers,
Ingo



Posted By: pdsdev
Date Posted: 11 May 16 at 10:49PM
it appears the code works fine - ugly as it might be... 
i can merge as many PDFs as i like of %PDF-1.4 or   %PDF-1.5
but no more than 2 of  %PDF-1.3  - which appears to corrupt the
instance and cause access violations.  

they display fine and i can add annotations and post text to them 
but not merge them. 

guess we can't be too sure the problem isn't in the lib.

any suggestions? 



Posted By: pdsdev
Date Posted: 11 May 16 at 10:55PM
here's a bit more info - 
as long as the   first   document isn't a 1.3 -
it appears that i can include as many 1.3s that i want - 



Posted By: Ingo
Date Posted: 12 May 16 at 6:21PM
Here were some problems in the fast regarding MergeFileList but that the pdf-specs-version shall be the reason???
Anyway i'm asking me what can be the sense of different encryptions if it's all merged together?
So before merging a pdf you should reset the encryption:
If ( QP.EncryptionStatus > 0 ) Then
     QP.Decrypt;




-------------
Cheers,
Ingo



Posted By: pdsdev
Date Posted: 16 May 16 at 1:16PM
thanks, i'll try that and see if it makes a difference.
sal



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