Frequently Asked Question:
Drawing into DC - scaling problem.
Hi,
I have a window, it's size is W[px] x H[px] .
I would like to to draw pdf page content using RenderPageToDC
.
This function supports only DPI setting.
Knowing page width from PageWidth()
how can I set such DPI that rendered pdf will have the same width (in pixels) as my window? I use windows api.
The PageWidth()
function returns the page size in points (1/72 inch) by default.
For example, if you received a value of 612 that would mean a page width of 8.5 inches.
To display this in a window that has a width of 1024 pixels you would need to set the DPI to 1024 pixels / 8.5 inches = 120.47
The QPL rendering functions only accept integer DPI values. Using 120 in this case would result in an image that is 1020 pixels wide - so there would be a gap of 4 pixels.