Insert pages to PDF file from other file PDF
Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: Sample Code
Forum Description: Share Debenu Quick PDF Library sample code with other forum members
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1318
Printed Date: 22 Nov 24 at 6:57PM Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com
Topic: Insert pages to PDF file from other file PDF
Posted By: kavaler
Subject: Insert pages to PDF file from other file PDF
Date Posted: 20 Jan 10 at 3:35PM
Hello How can I insert pages to PDF file from other file PDF?
|
Replies:
Posted By: Ingo
Date Posted: 20 Jan 10 at 6:32PM
Yes. 1. Open the first document. Open the second document. Create a new document. 2. You can extract the page you need from a second document. 3. You can extract the first part from your first document into a new document. 4. You can append the page from "2." at the new document. 5. You can append the second part of the first document from "3." at the new document. 6. Save the new document. Here you'll find the relevant functions: http://www.quickpdflibrary.com/help/quickpdf/PageManipulation.php
Cheers, Ingo
|
Posted By: kavaler
Date Posted: 21 Jan 10 at 2:28PM
Hello How can I append the page at the new document?
|
Posted By: kavaler
Date Posted: 21 Jan 10 at 4:12PM
kavaler wrote:
Hello How can I append the page at the new document? (in Delphi)
|
|
Posted By: Jack
Date Posted: 21 Jan 10 at 5:31PM
This is something I have to do in my program a lot, so I came up with a process. I wrote a wrapper class that has a WorkingPDF and a ResultPDF (both instances of TQuickPDF). Here's my procedure for appending: procedure TPDF.AppendWorkingPDF(var oPDFWorking, oPDFResult: TQuickPDF); var iDoc1, iDoc2: Integer; oPDFStream: TStream; sBuffer: String; begin oPDFStream := TStringStream.Create(sBuffer); FPDFWorking.SaveToStream(oPDFStream); //save your working PDF to a stream iDoc1 := FPDFResult.SelectedDocument; //get a handle on your result PDF Doc before changes oPDFStream.Seek(0, soFromBeginning); //don't forget to reset the stream cursor FPDFResult.LoadFromStream(oPDFStream); //adds the Working PDF Doc to the Result PDF //note that the Result PDF now has 2 docs if FPageNo = 1 then begin //the first doc in the Result PDF is the blank that QuickPDF starts with FPDFResult.RemoveDocument(iDoc1); end else begin iDoc2 := FPDFResult.SelectedDocument; //the Doc we just added from the stream FPDFResult.SelectDocument(iDoc1); //we stored this earlier FPDFResult.MergeDocument(iDoc2); //ta da! end; oPDFStream.Free; end; If, like me you are working with forms, then you should be aware that if you create a document with 50 pages and you have a field on each page named "Name", then all 50 pages will get whatever you put in last. For this, you need another process.
Hope this is helpful.
Jack
|
Posted By: kavaler
Date Posted: 21 Jan 10 at 7:26PM
this is my e-mail islam261@gmail.com adress please send me example(s) about this
|
Posted By: kavaler
Date Posted: 22 Jan 10 at 3:53PM
hello thank you very much for this code but I can't use this on my project I shall be very happy if you send me example(s) about this this is my e-mail islam261@gmail.com
|
Posted By: Jack
Date Posted: 22 Jan 10 at 5:03PM
Kavaler, Actually, what I posted is an example. What you need to do now is try to apply the steps in the code to your situation. I see that there are actually a couple of problems in the code the way I originally posted it. Let me modify it here:
procedure TPDF.AppendWorkingPDF(var oPDFWorking, oPDFResult: TQuickPDF); var
iDoc1, iDoc2: Integer; oPDFStream: TStream;
sBuffer: String; begin oPDFStream :=
TStringStream.Create(sBuffer); oPDFWorking.SaveToStream(oPDFStream); //save your working PDF to a
stream iDoc1 := oPDFResult.SelectedDocument; //get a handle on
your result PDF Doc before changes oPDFStream.Seek(0,
soFromBeginning); //don't forget to reset the stream cursor oPDFResult.LoadFromStream(oPDFStream); //adds the Working PDF Doc to
the Result PDF //note that the Result PDF now has 2 docs if
FPageNo = 1 then begin //the first doc in the Result PDF is the blank
that QuickPDF starts with oPDFResult.RemoveDocument(iDoc1);
end else begin iDoc2 := oPDFResult.SelectedDocument; //the Doc
we just added from the stream oPDFResult.SelectDocument(iDoc1);
//we stored this earlier oPDFResult.MergeDocument(iDoc2); //ta
da! end; oPDFStream.Free; end;
|
I think it is okay now. You should be able to drop this procedure into your code and then call it like
AppendWorkingPDF(MyPDF, MyPDFToAppend);
|
Give that a try and see if it works. -Jack
|
Posted By: kavaler
Date Posted: 23 Jan 10 at 8:03AM
hello thank you very vuch I thank you for everything
|
|