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

Render a PDF as an image with an asymmetrical DPI

Question

Is it possible to allow a PDF to be rendered as an image with an asymmetrical DPI (i.e., x=204 y=196)?

Answer

The current rendering engine is set up to use the same DPI setting for both the horizontal and vertical axis. So it isn't possible to render an image with an asymmetrical DPI, however, it is possible to get the same effect though by stretching the page.

Here's some pseudo code that shows how to do this:

QP.LoadFromFile("FaxTest-Letter.pdf");
QP.RenderPageToFile(204, 1, 5, "same-dpi.png");

// Get the original size of the page
double OriginalWidth = QP.PageWidth();
double OriginalHeight := QP.PageHeight();

// Add a new page
QP.NewPage();

// Work out the asymmetrical scaling
double NewWidth = OriginalWidth;
double NewHeight = OriginalHeight * 196 / 204;

// Set the dimensions of the new page
QP.SetPageDimensions(NewWidth, NewHeight);

// Capture the original page (it will be removed
// from the document automatically)
int CaptureID = QP.CapturePage(1);

// Set the original to the top-left corner
QP.SetOrigin(1);  

// Draw the captured page onto the new page
QP.DrawCapturedPage(CaptureID, 0, 0, NewWidth, NewHeight);

// Render the page
QP.RenderPageToFile(204, 1, 5, Dir + 'different-dpi.png');

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