Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

Scale a page for numbering?

Question

I want to be able to add page numbers to a PDF file without the risk of drawing the number on top of existing data. Can the content of a page be "scaled" leaving a margin at the bottom?

Answer

I have put some sample code to show how this can be done. Just change scale factor to set the scaling to whatever you wish.

// Delete the old file just in case.
File.Delete("newpages.pdf");

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);
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");

© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum