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 - merge two pdf's
  FAQ FAQ  Forum Search   Register Register  Login Login

merge two pdf's

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


Joined: 14 Dec 18
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote cprins Quote  Post ReplyReply Direct Link To This Post Topic: merge two pdf's
    Posted: 19 Oct 21 at 3:57PM
Hi there

Although there is a merge function in quickPDF it isn't doing the thing I want
Imaging you have two pdf's (both have 1 page)
Now I want to have as an output 1 document with 1 page containing the two pdf's on top of each other
This is probably been questioned befor but I can't find the right search term

So is it possible to merge two pdf's to 1 without adding the both pdf's to each other

I hope I made myself clear what I want

Thaks in advance   
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: 19 Oct 21 at 6:51PM
Hi Christian,

registered in the forum since 2018 and didn't find helpful samples? ;-)
I think you want to combine the two pages on one new page - so reduce for example two DIN A4 pages to DIN A5 and put them together on one new DIN A4?
Here's a kb-document giving you more than an idea how to do it:
https://www.debenu.com/kb/merge-content-from-multiple-pages-into-one-page/
If you want to combine an invoice template with real content to one filled out invoice here's another sample:
https://www.debenu.com/kb/overlay-one-pdf-onto-another-pdf-programmatically/

>> the starting point for all questions: http://www.quickpdf.org/ <<
>> search in all ressources: https://www.debenu.com/docs/pdf_library_reference/Search.php <<
 


Cheers,
Ingo

Back to Top
cprins View Drop Down
Beginner
Beginner


Joined: 14 Dec 18
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote cprins Quote  Post ReplyReply Direct Link To This Post Posted: 19 Oct 21 at 8:45PM
Hi Ingo, 

Thaks for your response
our first email conversation started already in 2009 so I'm here for a while (In those days I created a pdf viewer for Delphi which from time to time I still see some code passing by)

However due to the ambigous term "merge" I was not able to find what I'm was looking for.

I think your second options is worthwhile  diging in to.

As soon as I have my code up and running I will let you know and share it with the Forum.

A other might be to stream the pdf's to bitmaps and "merge"them together and put them back in a new pdf.
So indeed the idea is to overlay two pdf's (;etterhead with additonal text)

Thanks
Christian

Back to Top
cprins View Drop Down
Beginner
Beginner


Joined: 14 Dec 18
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote cprins Quote  Post ReplyReply Direct Link To This Post Posted: 27 Oct 21 at 2:24PM
Ok I figured out to overlay multiple pages with multiple pages

The function takes two pdf's 
  • template with the letterhead
  • OriginFile with the text.

The function can handle a letterhead with 1, 2 or 3 pages
  • With one page you only have the letterhead on each page
  • With 2 pages you have 1 frontpage and the rest of the document is overlayed with page 2 of the template
  • With 3 pages you have 1 frontpage and the other pages take page 2 or 3 of the template depending on being a odd or even page
If you have any commands or suggestion please let me know

procedure TPDF.LetterHead(template,Text:string);
var
  TextDocID: Integer;
  TemplateDocID: Integer;
  FrontPageID:integer;
  EvenPageID:integer;
  OddPageID:integer;
  OverlayID:integer;
  PageHeight: Double;
  PageWidth: Double;
  LetterheadCount:integer;
  i: Integer;
begin

qp.LoadFromFile(Text,'');
TextDocID := qp.SelectedDocument();
qp.LoadFromFile(template,'');
TemplateDocID := qp.SelectedDocument();
LetterHeadCount:=qp.PageCount;
qp.SelectDocument(TextDocID);
qp.MergeDocument(TemplateDocID);

OddPageID := 0;
EvenPageID := 0;
FrontPageID := 0;

case LetterheadCount of
1: begin
    FrontPageID := qp.CapturePage(qp.PageCount);
   end;
2: begin
    EvenPageID := qp.CapturePage(qp.PageCount);
    FrontPageID := qp.CapturePage(qp.PageCount);
   end;
3: begin
    OddPageID := qp.CapturePage(qp.PageCount);
    EvenPageID := qp.CapturePage(qp.PageCount);
    FrontPageID := qp.CapturePage(qp.PageCount);
   end;
end;


for i := 0 to qp.PageCount-1 do
begin
 OverlayID:=0;
 case LetterheadCount of
 1: begin
       OverlayID:=FrontPageID;
    end;
 2: begin
      if i=0 then
       OverlayID:=FrontPageID
     else
      OverlayID:=EvenPageID;
    end;
 3: begin
     if i=0 then
      OverlayID:=FrontPageID
     else
     begin
      if Odd(i+1) then
       OverlayID:=OddPageID
      else
       OverlayID:=EvenPageID
     end;
   end;
 end;

 if OverlayID>0 then
 begin
  qp.SelectPage(i+1);
  PageHeight := qp.PageHeight();
  PageWidth := qp.PageWidth();
  qp.DrawCapturedPage(OverlayID, 0, PageHeight, PageWidth, PageHeight);
 end;

end;

qp.SaveToFile('H:\output.pdf');

end;




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