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!
Scale all pages in a PDF with CapturePage |
Post Reply |
Author | |
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(2)
Posted: 26 Oct 11 at 4:58AM |
Here is some C# code I wrote to scale all pages on a PDF by 70% and it shows how to use CapturePage. It also shows how to construct the loop to process all pages and maintain the original page order. private void button8_Click(object sender, EventArgs e) { File.Delete("newpages.pdf"); // Delete the old file just in case. double pageWidth, pageHeight, horizBorder, vertBorder; double scaleFactor = 0.70; // 70 % scaling reduction. 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. pageWidth = QP.PageWidth(); pageHeight = QP.PageHeight(); horizBorder = pageWidth * (1.0 - scaleFactor) / 2; vertBorder = pageHeight * (1.0 - scaleFactor) / 2; capturedPageId = QP.CapturePage(1); // This deletes the page from the document. pageId = QP.NewPage(); QP.SetPageDimensions(pageWidth, pageHeight); ret = QP.DrawCapturedPage(capturedPageId, horizBorder, vertBorder, pageWidth - 2 * horizBorder, pageHeight - 2 * vertBorder); } QP.SaveToFile("newpages.pdf"); System.Diagnostics.Process.Start(@"newpages.pdf"); } Edited by AndrewC - 28 Nov 13 at 12:57PM |
|
Carneno
Team Player Joined: 19 Apr 11 Status: Offline Points: 24 |
Post Options
Thanks(0)
|
Hello,
I am using QuickPDF Library 8.11 Active-x in a VB 6.0 program. It uses LoadFromFile to load PDF documents, overlay the bottom part of the PDF with a box and some text then print them. I would like to reduce the size of the content for each page so that it appears on the top 80% of the page and add the box and text at the bottom so that it does not overlay the original PDF page. Will this sample code allow me to do that? It should not be a problem for me to convert to VB 6.0. Any help would be gratefully appreciated. Thanks, Tony
|
|
Stop The World, I want To Get Off.
|
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
Yes. It will work very well.
1. Change scaleFactor to 0.80 for 80%. 2. You will need to move the image up the page a little as the current implementation centres in on the page. The following change should do what you need. ret = QP.DrawCapturedPage(capturedPageId, horizBorder, vertBorder * 2, pageWidth - 2 * horizBorder, pageHeight); Also : You are entitled to a free upgrade to 8.14 which has many bug fixes and improvements. It can be downloaded from http://www.quickpdflibrary.com/products/quickpdf/updates.php Edited by AndrewC - 19 Mar 14 at 11:09AM |
|
Carneno
Team Player Joined: 19 Apr 11 Status: Offline Points: 24 |
Post Options
Thanks(0)
|
Excellent Andrew.
Thanks very much. Tony
|
|
Stop The World, I want To Get Off.
|
|
Pulkitsoft
Beginner Joined: 10 Oct 20 Location: New Delhi Status: Offline Points: 16 |
Post Options
Thanks(0)
|
Is Anyone can help? Above given page scaling code working very well. I wants to specify left, top, bottom, right margin in above given code. Note: Output page not to be stretch.
|
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3527 |
Post Options
Thanks(0)
|
You can't set it directly.
All related functions are working with top, left, width and height - so you have to do some calculations ;-) |
|
Cheers,
Ingo |
|
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