Print Page | Close Window

Merged overlay with multiple pages

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1507
Printed Date: 26 Jun 24 at 6:28AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Merged overlay with multiple pages
Posted By: coco
Subject: Merged overlay with multiple pages
Date Posted: 02 Jul 10 at 2:23PM
Hi all,

I'm trying to add an overlay page to a pdf files with 10 pages. This works when i use (exactly) the sample code but the overlay page is printed upsidedown on every page. 
I've tried to use the DrawRotatedCapturedPage function as well but this doesn't give me a result at all.
I'm using version "QuickPDF0719" on Windows 7.

Here's my code: 

var
  oQuickPdf: TQuickPDF;
  iUnlock: Integer;
  iPageHeight, iPageWidth: Double;
  iPrimaryDoc, iSecondaryDoc, iCapturedPageID, iCount, iPrimaryPageCount: Integer;
  sTargetFileName, sDocumentOverlayFile, sDocumentPdfFile: string;
begin

  oQuickPdf := TQuickPDF.Create;
  try
    iUnlock := oQuickPdf.UnlockKey('');

    if iUnlock = 1 then
    begin
      sDocumentPdfFile := DM.GetTempFile('.pdf');
      sDocumentOverlayFile := DM.GetTempFile('.pdf');
      sTargetFileName := DM.GetTempFile('.pdf');
      try
        oQuickPdf.LoadFromFile('c:\users\olav\desktop\Invoice DE.pdf');

        iPrimaryDoc := oQuickPdf.SelectedDocument();
        iPrimaryPageCount := oQuickPdf.PageCount;

        oQuickPdf.LoadFromFile('c:\users\olav\desktop\Overlay.pdf');

        iSecondaryDoc := oQuickPdf.SelectedDocument();

        oQuickPdf.SelectDocument(iPrimaryDoc);

        oQuickPdf.MergeDocument(iSecondaryDoc);

        iPageHeight := oQuickPdf.PageHeight();
        iPageWidth := oQuickPdf.PageWidth();

        iCapturedPageID := oQuickPdf.CapturePage(oQuickPdf.PageCount);

        oQuickPdf.SelectDocument(iPrimaryDoc);

        for iCount := 1 to iPrimaryPageCount do begin
          oQuickPdf.SelectPage(iCount);
          oQuickPdf.SetOrigin(1);
          oQuickPdf.DrawCapturedPage(iCapturedPageID, 0, 0, iPageWidth, iPageHeight);
        end;

        oQuickPdf.SaveToFile(sTargetFileName);
        ShellExecute(Application.Handle, 'open', PAnsiChar(sTargetFileName), '', '', SW_NORMAL);
      finally
    //delete files etc.
      end;

    end else
    begin
      ShowMessage('Invalid license key');
    end;
  finally
    oQuickPdf.Free;
  end;
end;



Replies:
Posted By: Ingo
Date Posted: 02 Jul 10 at 3:27PM
Hi Coco!

No time... Only a quick shot:
Try SetOrigin

Cheers and welcome here,
Ingo



Posted By: coco
Date Posted: 02 Jul 10 at 3:49PM
Thanks, but I've tried this one. Unfortunately without results...

Regards Olav


Posted By: coco
Date Posted: 26 Jul 10 at 11:12AM
Hi again, 

Is there anything else I can try?
I'm pretty stuck right now :(

Kind regards


Posted By: Ingo
Date Posted: 26 Jul 10 at 1:59PM
Originally posted by coco coco wrote:


Is there anything else I can try?


Hi!

If you don't get an answer here you should try
the official support pages.

Cheers, Ingo



Posted By: evil_hunter
Date Posted: 12 Aug 10 at 1:40PM
Hi,
I don't know if it can help you (i don't really understand your demand... i know i know my english is not perfect!^^)
I did that (in VB)
 

If Result = 1 Then

'You can only use the DrawCapturedPage function if the captured page is in the same

'document, so first we'll need to merge the two pages that we wish to overlay together

'into one document.

QP.LoadFromFile(file1)

FileA = QP.SelectedDocument()

QP.LoadFromFile(file2)

FileB = QP.SelectedDocument()

'After merging FileB is automatically deleted, leaving only FileB which is now a combination of FileA and FileB

QP.SelectDocument(FileA)

QP.MergeDocument(FileB)

'Capture the page to copy in the merged document

CapturedPageID = QP.CapturePage(QP.PageCount)

'Now select the page(s) and retrieve its height and width

For i = 1 To QP.PageCount

QP.SelectDocument(FileA)

QP.SelectPage(i)

PageHeight = QP.PageHeight()

PageWidth = QP.PageWidth()

'Draw the captured page onto the currently selected page(s)

QP.DrawCapturedPage(CapturedPageID, 0, PageHeight, PageWidth, PageHeight)

Next

 

'Save the stitched file to disk

QP.SaveToFile("")

Bye!


Posted By: coco
Date Posted: 13 Aug 10 at 12:36PM
Hi,
 
Thanks for the reply. I've found out that my code was ok like it was.
 
However, when using pdf files exported by crystal reports this strange behaviour was introduced. It worked perfectly fine with any other pdf.
 
Regards


Posted By: evil_hunter
Date Posted: 16 Aug 10 at 1:47PM
Hum exact...
my code doesn't work with pdf generated by crystal... any solutions?


Posted By: Ingo
Date Posted: 16 Aug 10 at 3:10PM
Hi!

No.
But i've made the experiences that this doesn' happen with newer (i don't know how new) versions of crystal reps.
Why not upload your prob-docs to the official support pages?
There won't be a solution but perhaps further versions of QP can work with these documents.

Cheers, Ingo



Posted By: evil_hunter
Date Posted: 17 Aug 10 at 4:20PM
It's ok i found how to generate a "good" pdf! works with crystal 9 and 11.
I'll test with 2008.


Posted By: coco
Date Posted: 18 Aug 10 at 11:28AM
That sounds great! Can you tell me how you did it?


Posted By: evil_hunter
Date Posted: 18 Aug 10 at 1:22PM

I ve find that you can't overlay a pdf on a pdf made with crystal 11 (with crystal 9 the overlay pdf is rotate and small, in my case).

But you can overlay a pdf made by crystal (9 or 11) on an other pdf!
In my case it's ok because juste one of the 2 pdf are comming from crystal! I don't know in yours...


Posted By: coco
Date Posted: 10 Sep 10 at 3:16PM
Hmm, I didn't get a mailmessage about your reply so sorry for the late reaction.
I'm having the same case but my crystal report can contain more then 1 page so that doesn't work.
 
Of course I can duplicate the overlay until it matches the number of pages that my report contains but I don't like the method :(
 
I guess there's no other way at the moment. Thanks for your reaction!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk