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 > Sample Code
  New Posts New Posts RSS Feed - Scale all pages in a PDF with CapturePage
  FAQ FAQ  Forum Search   Register Register  Login Login

Scale all pages in a PDF with CapturePage

 Post Reply Post Reply
Author
Message
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 (2) Thanks(2)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Topic: Scale all pages in a PDF with CapturePage
    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
Back to Top
Carneno View Drop Down
Team Player
Team Player
Avatar

Joined: 19 Apr 11
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote Carneno Quote  Post ReplyReply Direct Link To This Post Posted: 27 Mar 12 at 1:40PM
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.
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: 27 Mar 12 at 2:27PM
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
Back to Top
Carneno View Drop Down
Team Player
Team Player
Avatar

Joined: 19 Apr 11
Status: Offline
Points: 24
Post Options Post Options   Thanks (0) Thanks(0)   Quote Carneno Quote  Post ReplyReply Direct Link To This Post Posted: 27 Mar 12 at 3:14PM
Excellent Andrew.
 
Thanks very much.
 
Tony
Stop The World, I want To Get Off.
Back to Top
Pulkitsoft View Drop Down
Beginner
Beginner


Joined: 10 Oct 20
Location: New Delhi
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pulkitsoft Quote  Post ReplyReply Direct Link To This Post Posted: 27 Feb 21 at 9:35AM

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.
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3311
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 01 Mar 21 at 10:41PM
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

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