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 - access violations merging PDFs
  FAQ FAQ  Forum Search   Register Register  Login Login

access violations merging PDFs

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


Joined: 11 May 16
Location: FL
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote pdsdev Quote  Post ReplyReply Direct Link To This Post Topic: access violations merging PDFs
    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;

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

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
pdsdev View Drop Down
Beginner
Beginner


Joined: 11 May 16
Location: FL
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote pdsdev Quote  Post ReplyReply Direct Link To This Post 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

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

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
pdsdev View Drop Down
Beginner
Beginner


Joined: 11 May 16
Location: FL
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote pdsdev Quote  Post ReplyReply Direct Link To This Post 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? 

Back to Top
pdsdev View Drop Down
Beginner
Beginner


Joined: 11 May 16
Location: FL
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote pdsdev Quote  Post ReplyReply Direct Link To This Post 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 - 

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

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
pdsdev View Drop Down
Beginner
Beginner


Joined: 11 May 16
Location: FL
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote pdsdev Quote  Post ReplyReply Direct Link To This Post Posted: 16 May 16 at 1:16PM
thanks, i'll try that and see if it makes a difference.
sal
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