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 - Background image in existing PDF
  FAQ FAQ  Forum Search   Register Register  Login Login

Background image in existing PDF

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


Joined: 07 Sep 11
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote nexent Quote  Post ReplyReply Direct Link To This Post Topic: Background image in existing PDF
    Posted: 07 Sep 11 at 3:15PM
Hi there,

I'm using QuickPDFLite0725.PDFLibrary in VB6.
I need to add a background image (fitting all page) in every page of an existing PDF created by Crystal Reports 9.

I've tried the following code:

   QP.LoadFromFile SourceFile

   Dim lngImage As Long
   lngImage = QP.AddImageFromFile(ImageFile, 0)
  
   Dim I As Integer
   For I = 1 To QP.PageCount() '- 1
      QP.SelectPage I
      QP.SelectImage lngImage
      QP.SetOrigin 1

      QP.DrawImage 0, 0, QP.PageWidth(), QP.PageHeight()
   Next

   QP.SaveToFile TargetFile

The first problem is that the image is drawn over the existing content, and not behind.
The second (maybe a bug?) is that the image is drawn mirrored.
Any ideas?

I could buy the full version, if that would solve the problem.
Thanks.


Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 07 Sep 11 at 3:21PM

There is a function on the full version that fixes the Mirroring problem.

  QP.NormalizePage(page);

To draw the background underneath you would need to use the CapturePage and DrawCapturedPage functions which are not available in the Lite version.

There is a 30 day trial available as well which will make it easier to decide.

Andrew.
Back to Top
nexent View Drop Down
Beginner
Beginner


Joined: 07 Sep 11
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote nexent Quote  Post ReplyReply Direct Link To This Post Posted: 07 Sep 11 at 3:29PM
Hi Andrew,

thanks for your quick reply.
Can you give me some sample code for the CapturePage and DrawCapturedPage functions?
I could test using the trial, I need to solve the problem asap.

Thanks again



Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 07 Sep 11 at 4:12PM
This code should do everything you need.  You just need to put your image drawing code in where I have indicated.  This will work on multiple page PDF's and also for a single page PDF.

Basically when you capture a page, that page is deleted and the contents are captured.  So we add a new page to the end of the document and draw the captured page onto that new page.  We then repeat the process for each page.

            double pageWidth, pageHeight;
            int capturedPageId;

            int ret = QP.LoadFromFile("Pages.pdf", "");
            QP.SetOrigin(1);

            int numPages = QP.PageCount();
            int pageId;

            for (int i = 1; i <= numPages; i++)
            {
                QP.SelectPage(1);                       // Always select page 1 as the pages get deleted.
                QP.NormalizePage(0);                    // Fix the page mirroring.

                pageWidth = QP.PageWidth();
                pageHeight = QP.PageHeight();
                
                capturedPageId = QP.CapturePage(1);     // This deletes the page from the document.

                pageId = QP.NewPage();
                QP.SetPageDimensions(pageWidth, pageHeight);

                // TODO -----------------------------------
                // Draw your stamp or background image here
                // TODO -----------------------------------

                // Now draw the original page on top.
                ret = QP.DrawCapturedPage(capturedPageId, 0, 0, QP.PageWidth(), QP.PageHeight());
            }

            QP.SaveToFile("newpages.pdf");

Back to Top
nexent View Drop Down
Beginner
Beginner


Joined: 07 Sep 11
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote nexent Quote  Post ReplyReply Direct Link To This Post Posted: 07 Sep 11 at 5:53PM
There's a problem... :(
my collegue already installed trial version 7.26 on development pc, and that version has expired a few days ago.

Now, I have installed version 8.11, but I've got a message stating that the trial license key "could not be validated" (obviously... ;)

Can I have a new key for the 8.11 version?
Thanks




Back to Top
nexent View Drop Down
Beginner
Beginner


Joined: 07 Sep 11
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote nexent Quote  Post ReplyReply Direct Link To This Post Posted: 08 Sep 11 at 9:32AM
Never mind, problem solved.
Thanks
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