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!
![]() |
Background image in existing PDF |
Post Reply ![]() |
Author | |
nexent ![]() Beginner ![]() Joined: 07 Sep 11 Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() 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. |
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
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.
|
|
![]() |
|
nexent ![]() Beginner ![]() Joined: 07 Sep 11 Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
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"); |
|
![]() |
|
nexent ![]() Beginner ![]() Joined: 07 Sep 11 Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
nexent ![]() Beginner ![]() Joined: 07 Sep 11 Status: Offline Points: 4 |
![]() ![]() ![]() ![]() ![]() |
Never mind, problem solved.
Thanks |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store