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!
![]() |
MERGING 2 or MORE PDF FIles into ONE PDF File |
Post Reply ![]() |
Author | |
isyscorp ![]() Beginner ![]() ![]() Joined: 30 Aug 12 Location: Philippines Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() 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
|
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
isyscorp ![]() Beginner ![]() ![]() Joined: 30 Aug 12 Location: Philippines Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
Thanks much Andrew. Trying now... :)
|
|
![]() |
|
isyscorp ![]() Beginner ![]() ![]() Joined: 30 Aug 12 Location: Philippines Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
Hi Andrew, what command should i put inside a BUTTON?
Example: MergeStreamsViaMergeDocument(<pdf1>, <pdf2>,<pdfresult>). Thanks... Vid
|
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
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"); |
|
![]() |
|
isyscorp ![]() Beginner ![]() ![]() Joined: 30 Aug 12 Location: Philippines Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
|
Wheeley ![]() Senior Member ![]() ![]() Joined: 30 Oct 05 Location: United States Status: Offline Points: 146 |
![]() ![]() ![]() ![]() ![]() |
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 ![]() |
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
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. |
|
![]() |
|
isyscorp ![]() Beginner ![]() ![]() Joined: 30 Aug 12 Location: Philippines Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
isyscorp ![]() Beginner ![]() ![]() Joined: 30 Aug 12 Location: Philippines Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
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
|
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
Andrew.
|
|
![]() |
|
isyscorp ![]() Beginner ![]() ![]() Joined: 30 Aug 12 Location: Philippines Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
Hi Andrew!!! Ha ha thank you... it works now... whew... you really made my day. Thanks you so much!
Vid :)
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store