Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 575

Previous Page 574   Index   Next Page 576

Function Reference
Page 575 of 750
The image size can be calculated as follows (C++):
UI32 w = 0, h = 0;
UI32 fw = 2540, fh = 1440; // Size of output rectangle in pixels
// Get a pointer of the page object to enable fast access to the page
// properties.
IPGE* pagePtr = pdfGetPageObject(m_PDF, pageNum);
// CalcPagePixelSize() returns the height of the image in this example.
// RenderPage() calculates the image size in the exact same way when
// called with the same parameters.
rasCalcPagePixelSize(pagePtr,psFitWidth,1.0f,fw,fh,rfDefault,&w,&h);
// Now you can allocate the image buffer or check whether the existing
// one is large enough.
if (w != lastWidth || h != lastHeight)
{
}
Calculating the size of the image buffer is easy, and scrolling is easy too when the zoom factor is
100%. The handling of other zoom factors is the most complex part in a viewer application. For zoom
factors between 10% and 200% it is usually best to render the entire page as described above but
larger zoom factors cannot be handled in this way because at some point the image becomes too
large and the rendering time would become too long.
For larger zoom factors it is mostly better to render the page directly with the required zoom factor
into the client rectangle since the rasterizer can then skip invisible objects to speed up processing.
The Transformation Matrix
The transformation matrix can be used to scroll the page up and down, and to scale it with an
arbitrary zoom factor, or to rotate it if necessary. The matrix must be defined in device space, that is
the coordinate space of the image buffer. This makes it very easy to scroll and zoom into the page
since you don't need to consider the coordinate space of the PDF page.
The coordinate space of the rendering engine is top down and not bottom up like the native PDF
coordinate space. So, negative y-coordinates move the PDF image to the top direction of the window
and positive values move it to the opposite direction.
Example:
// This matrix scrolls the PDF image 120 pixels down
img.Matrix.a = 1.0;
img.Matrix.b = 0.0;
img.Matrix.c = 0.0;
img.Matrix.d = 1.0;
img.Matrix.x = 0.0;
img.Matrix.y = -120.0;
 

Previous topic: Rendering PDF Pages

Next topic: UpdateOnPathCount limit