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 > Sample Code
  New Posts New Posts RSS Feed - Insert pages to PDF file from other file PDF
  FAQ FAQ  Forum Search   Register Register  Login Login

Insert pages to PDF file from other file PDF

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

Joined: 19 Jan 10
Location: Baku
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote kavaler Quote  Post ReplyReply Direct Link To This Post Topic: Insert pages to PDF file from other file PDF
    Posted: 20 Jan 10 at 3:35PM
Hello
How can I insert pages to PDF file from other file PDF?
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: 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



Edited by Ingo - 20 Jan 10 at 6:33PM
Back to Top
kavaler View Drop Down
Beginner
Beginner
Avatar

Joined: 19 Jan 10
Location: Baku
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote kavaler Quote  Post ReplyReply Direct Link To This Post Posted: 21 Jan 10 at 2:28PM
Hello
How can I  append the page at the new document?

Back to Top
kavaler View Drop Down
Beginner
Beginner
Avatar

Joined: 19 Jan 10
Location: Baku
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote kavaler Quote  Post ReplyReply Direct Link To This Post Posted: 21 Jan 10 at 4:12PM
Originally posted by kavaler kavaler wrote:

Hello
How can I  append the page at the new document? (in Delphi)

Back to Top
Jack View Drop Down
Team Player
Team Player
Avatar

Joined: 03 Jun 09
Location: Lompoc, CA
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jack Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
kavaler View Drop Down
Beginner
Beginner
Avatar

Joined: 19 Jan 10
Location: Baku
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote kavaler Quote  Post ReplyReply Direct Link To This Post Posted: 21 Jan 10 at 7:26PM
this is my e-mail 
islam261@gmail.com
adress please send me example(s)  about this
Back to Top
kavaler View Drop Down
Beginner
Beginner
Avatar

Joined: 19 Jan 10
Location: Baku
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote kavaler Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Jack View Drop Down
Team Player
Team Player
Avatar

Joined: 03 Jun 09
Location: Lompoc, CA
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote Jack Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
kavaler View Drop Down
Beginner
Beginner
Avatar

Joined: 19 Jan 10
Location: Baku
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote kavaler Quote  Post ReplyReply Direct Link To This Post Posted: 23 Jan 10 at 8:03AM
Smilehello
thank you very vuch
I thank you for everything
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