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 - MERGING 2 or MORE PDF FIles into ONE PDF File
  FAQ FAQ  Forum Search   Register Register  Login Login

MERGING 2 or MORE PDF FIles into ONE PDF File

 Post Reply Post Reply
Author
Message
isyscorp View Drop Down
Beginner
Beginner
Avatar

Joined: 30 Aug 12
Location: Philippines
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote isyscorp Quote  Post ReplyReply Direct Link To This Post Topic: MERGING 2 or MORE PDF FIles into ONE PDF File
    Posted: 30 Aug 12 at 1:38AM
Hi Guys,

Been browsing all the forums and Delphi programmers discussions how to merge 2 or more PDF files into one PDF File. I finally found this Quick PDF Library, interesting BUT I can't really make it to work. Here's a code from Rowan, kindly help where's my mistake?

USES ***QuickPDF0816;

function MergeStreamsViaMergeDocument(FirstStream, SecondStream,
    OutputStream: TMemoryStream): Integer;
  var
    doc1, doc2: Integer;
  begin
    with TQuickPDF.Create do
    try
      FirstStream.Seek(0, soFromBeginning);
      LoadFromStream(FirstStream);
      doc1 := SelectedDocument;
      SecondStream.Seek(0, soFromBeginning);
      LoadFromStream(SecondStream);
      doc2 := SelectedDocument;
      SelectDocument(doc1);
      MergeDocument(doc2);
      OutputStream.Seek(0, soFromBeginning);
      SaveToStream(OutputStream);
    finally
      Free;
    end;
  end;


I got the error message "Not Enough Parameters" at line "LoadFromStream(FirstStream);"

Thank you for your help,
Vid
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: 30 Aug 12 at 7:31AM
A quick read of the "Quick PDF Library 8.16 Reference Guide.pdf" will reveal that LoadFromStream also requires a password parameter as of QPL 8.xx.  The PDF file can be found in the Quick PDF installation directory.


  LoadFromStream(FirstStream, Password);  // add the password parameter - can be blank ie. ""

The Demo code was originally written for QPL 7.xx.  The changes between 7.xx and 8.xx are documented in the "Quick PDF Library 8 Upgrade Warnings.pdf" which is also in the QuickPDF installation directory.

It would also be helpful to know what development system you are using.

Andrew.


Edited by AndrewC - 30 Aug 12 at 7:33AM
Back to Top
isyscorp View Drop Down
Beginner
Beginner
Avatar

Joined: 30 Aug 12
Location: Philippines
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote isyscorp Quote  Post ReplyReply Direct Link To This Post Posted: 31 Aug 12 at 12:14AM
Thanks much Andrew. Trying now... :)
Back to Top
isyscorp View Drop Down
Beginner
Beginner
Avatar

Joined: 30 Aug 12
Location: Philippines
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote isyscorp Quote  Post ReplyReply Direct Link To This Post Posted: 31 Aug 12 at 12:20AM
Hi Andrew, what command should i put inside a BUTTON?

Example: MergeStreamsViaMergeDocument(<pdf1>, <pdf2>,<pdfresult>).

Thanks...
Vid
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: 31 Aug 12 at 10:14AM

I would suggest you have a read of the 'Quick PDF Library 8 Developer Guide.pdf' file which is installed in the Quick PDF installation directory.

Page 26 shows some sample code using files and calling MergeDocument.  It would be much easier using files than memorystreams to start with.

You would add this code into a Delphi procedure 

   procedure MergePDFFiles(firstDoc, secondDoc, DestFileName: Ansistring);

and then in your button code you would add 

  MergePDFFiles("file1.pdf", "file2.pdf", "output.pdf");

Back to Top
isyscorp View Drop Down
Beginner
Beginner
Avatar

Joined: 30 Aug 12
Location: Philippines
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote isyscorp Quote  Post ReplyReply Direct Link To This Post Posted: 02 Sep 12 at 5:06AM
Hi Andrew, got no luck.. :(

Do you have a sample program to merge two or more files? Really appreciate it... I got the Quick PDF Library installed to my GUI already. Thank you...

Vid
Back to Top
Wheeley View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 Oct 05
Location: United States
Status: Offline
Points: 146
Post Options Post Options   Thanks (0) Thanks(0)   Quote Wheeley Quote  Post ReplyReply Direct Link To This Post Posted: 02 Sep 12 at 6:40AM
Have you bothered to read to function documentation? It's all there for you.So for > 2 files do this (no I am not going to give you actual code. We all struggled through this and nothing good n life comes free)

AddToFileList (myfiles,1.pdf)
AddToFileList (myfiles,2.pdf)
AddToFileList (myfiles,3.pdf)
mergefilelist(myfiles,combined.pdf)

Wheeley
Lamp

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: 02 Sep 12 at 7:00AM
Vid,

Are you asking how to merge 2 or more files or are you asking help to create a Delphi program using Quick PDF Library ?

The QPL code to merge files is pretty simple

        QP.ClearFileList("test");
        QP.AddToFileList("test", "1-1805B663 data.pdf");
        QP.AddToFileList("test", "1805B results.pdf");
        QP.AddToFileList("test", "som0102a.pdf");
        QP.AddToFileList("test", "c3639-03DL.pdf");
        QP.AddToFileList("test", "c3639-04.pdf");
        QP.MergeFileList("test", "merged.pdf");

Here is some pretty basic delphi code that attaches the code the Delphi button. 

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, ShellApi,
  Dialogs, QuickPDF0816, StdCtrls, ExtCtrls, RichEdit, ToolWin, ComCtrls, Printers;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure FormDestroy(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  QP: TQuickPDF;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin

  QP := TQuickPDF.Create;
  QP.UnlockKey('<paste your license key here');   // <<<<<<<<<<<<<  Paste your key here before compiling

  SetCurrentDirectory('f:\downloads');
  QP.SetTempPath('F:\Downloads');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin

  DeleteFile('merged.pdf');
  QP.ClearFileList('test');

  QP.AddToFileList('test', 'f:\downloads\out.pdf');
  QP.AddToFileList('test', 'f:\downloads\out2.pdf');

  QP.MergeFileList('test', 'f:\downloads\merged.pdf');

  ShellExecute(hinstance,'open',PChar('merged.pdf'),nil,nil,SW_SHOWNORMAL);
end;

end.


Back to Top
isyscorp View Drop Down
Beginner
Beginner
Avatar

Joined: 30 Aug 12
Location: Philippines
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote isyscorp Quote  Post ReplyReply Direct Link To This Post Posted: 02 Sep 12 at 9:30AM
Thank Andrew, the program seems running with no errors... I am just wondering it cannot generate an output file.
I changed the folder locations with two pdf files in it:
c:\Temp\pdf1.pdf
c:\Temp\pdf2.pdf

procedure TForm1.FormCreate(Sender: TObject);
begin

  QP := TQuickPDF.Create;
  QP.UnlockKey('<paste your license key here');   // <<<<<<<<<<<<<  Paste your key here before compiling

  SetCurrentDirectory('c:\Temp');
  QP.SetTempPath('c:\Temp');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin

  DeleteFile('merged.pdf');
  QP.ClearFileList('test');

  QP.AddToFileList('test', 'c:\Temp\pdf1.pdf');
  QP.AddToFileList('test', 'c:\Temp\pdf2.pdf');

  QP.MergeFileList('test', 'c:\Temp\merged.pdf');

  ShellExecute(hinstance,'open',PChar('merged.pdf'),nil,nil,SW_SHOWNORMAL);
end;

end.

========= Thank again...
Vid


Edited by isyscorp - 02 Sep 12 at 9:42AM
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: 02 Sep 12 at 9:37AM
Did you paste your license key into the line that says 

  QP.UnlockKey('<paste your license key here');   // <<<<<<<<<<<<<  Paste your key here before compiling

It will need to look something like this

  QP.UnlockKey('5hk4gh65ghk52ghkg3hj4e3');    // This is an invalid key.


We should also be checking the return value.

..
var

  ret: Integer;

...
...

  ret := QP.UnlockKey('5hk4gh65ghk52ghkg3hj4e3'); 

  if (ret <> 1)
      ShowMessage("Quick PDF Library has not been unlocked - Please check the license key");

Andrew
    



Edited by AndrewC - 02 Sep 12 at 9:41AM
Back to Top
isyscorp View Drop Down
Beginner
Beginner
Avatar

Joined: 30 Aug 12
Location: Philippines
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote isyscorp Quote  Post ReplyReply Direct Link To This Post Posted: 02 Sep 12 at 9:45AM
Yes I did, 

I have a licensed one and added to my code, but when i added VAR RET, i now received an INVALID license key...

Thanks much,
Vid 
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: 02 Sep 12 at 10:10AM

Please create an official support case at  http://www.quickpdflibrary.com/support/support-query.php and when you receive a ticket number reply to the email and attach your latest source code (including your license key) and also attach the two PDF files you are trying to merge.

Andrew.
Back to Top
isyscorp View Drop Down
Beginner
Beginner
Avatar

Joined: 30 Aug 12
Location: Philippines
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote isyscorp Quote  Post ReplyReply Direct Link To This Post Posted: 02 Sep 12 at 10:55AM
Hi Andrew!!! Ha ha thank you... it works now... whew... you really made my day. Thanks you so much!

Vid :)
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