<< Click to Display Table of Contents >> Navigation: Functions > PXV_CommonRenderParameters |
The PXV_CommonRenderParameters structure defines drawing parameters for the functions PXCV_DrawPageToDC and PXCV_DrawPageToDIBSection.
typedef struct _PXV_CommonRenderParameters {
LPRECT WholePageRect;
LPRECT DrawRect;
DWORD Flags;
DWORD RenderTarget;
} PXV_CommonRenderParameters;
WholePageRect
Specifies the rectangular area in which the PDF page rectangle will be drawn. See Comments for further information.
DrawRect
Specifies the rectangular portion of the PDF page to be drawn. If this field is NULL then the entire PDF page will be drawn.
Flags
This DWORD value is a combination of flags that defines rendering options such as rotation and vector rendering. Any combination of the following values is possible:
Flag
|
Value
|
Meaning
|
pxvrpf_Rotate_NoRotate
|
0x0000
|
No rotation is carried out before pages are drawn.
|
PXCVClb_Processing
|
0x0001
|
Pages are rotated ninety degrees clockwise and then drawn. This is the standard Landscape layout.
|
pxvrpf_Rotate_Rotate180
|
0x0002
|
Pages are rotated one hundred and eighty degrees and then drawn.
|
pxvrpf_Rotate_Rotate90CCW
|
0x0003
|
Pages are rotated ninety degrees counterclockwise and then drawn.
|
|
0x0004
|
Specifies that vector rendering is used (as opposed to raster rendering). This feature is recommended as the print job and the resources it uses are considerably smaller as a result. The Microsoft GDI is used for rendering.
|
pxvrpf_RenderAsGray
|
0x0008
|
Specifies that rendering is performed in grayscale mode.
|
pxvrpf_EmbeddedFontAsCurves
|
0x0010
|
Specifies that all embedded fonts are rendered as curves - text functions will not be used. If this flag is not used then embedded, true-type fonts are installed temporarily for rendering.
N.b. this flag has meaning only when pxvrpf_UseVectorRenderer is used - otherwise it is ignored.
|
pxvrpf_AllFontsAsCuves
|
0x0030
|
Specifies that all fonts are rendered as curves and without using text output API functions.
N.b. this flag has meaning only when pxvrpf_UseVectorRenderer is used - otherwise it is ignored.
|
pxvrpf_NoTransparentBkgnd
|
0x0040
|
Specifies that raster images are filled with non-transparent white color before they are drawn. When this flag is not specified drawings are provided on a transparent background.
N.b. this flag has meaning only when pxvrpf_UseVectorRenderer is not used.
|
RenderTarget
Specifies the rendering mode to be used. This is meaningful when the optional content exists within a document that is visible only in some rendering modes, such as push-buttons within an Adobe Acroform. Any combination of the following values is possible:
Constant
|
Value
|
Meaning
|
pxvrm_Viewing
|
0
|
Sets the rendering target as View. For example, this mode can be used for displaying a document on the screen.
|
pxvrm_Printing
|
1
|
Sets the rendering target as Print. For example, this mode is used for printing a document (or for a print preview).
|
pxvrm_Exporting
|
2
|
Sets the rendering target as Export. For example, this mode is used for exporting document content to a different format, such as supported raster image formats.
|
Please note that all functions and parameters/members are case-sensitive.
Figure 1. WholePageRect/DrawRect Example
When specific sections of PDF pages are drawn, it is necessary to specify two areas. First the rectangular area of the target's DC must be given as "WholePageRect," which the entire PDF page will occupy. Then the area of the PDF page drawn within WholePageRect must be given as "DrawRect". If DrawRect is set to NULL then the entire PDF page will be drawn within the target device's WholePageRect area. This simplifies the scaling of the PDF page (zoom level) and helps prevent rounding errors during the conversion from points to pixels.
The objective is to draw a PDF page within the application window, given the following dimensions:
1. The PDF page has the dimensions 576 x 792 points (8 x 11 inches).
2. The desired "zoom level" is 400% - a scaling factor of four.
3. The application window's DC has the dimensions 600 x 800 pixels, with a DPI of 96.
4. The application window has scroll bars to control the page display. Their positions are 120 for the vertical and 180 for the horizontal, assuming that the maximum position for the horizontal scroll bar is the page's width in pixels less the window width.
The first step is to calculate the PDF page's dimensions in pixels:
page_width_in_pixels = (576 / 72) * 96 * 4 = 3072 pixels
page_height_in_pixels = (792 / 72) * 96 * 4 = 4224 pixels
If the dimensions of the PDF page and the zoom level remain constant then these values will also remain constant.
Therefore the WholePageRect and DrawRect values for the PXV_CommonRenderParameters structure are:
WholePageRect.left = -180; // horizontal scroll position
WholePageRect.top = -120; // vertical scroll position
WholePageRect.right = WholePageRect.left + page_width_in_pixels;
WholePageRect.bottom = WholePageRect.top + page_height_in_pixels;
DrawRect.left = 0;
DrawRect.top = 0;
DrawRect.right = 600; // the window width
DrawRect.top = 800; // the window height
If the zoom level is constant then WholePageRect depends on only the position of the scroll bars. This simplifies the calculations involved and reduces rounding errors.
The objective is to draw a portion of a PDF page, given the following dimensions:
1. The PDF page has a width of 576 points (8 inches) and a height of 792 points (11 inches).
2. The desired portion of the page, starting from point (10, 10), is defined as:
left = 144pt;
top = 288pt;
right = 360pt;
bottom = 648pt
3. The page portion will be drawn on the target DC with a zoom factor of 200%, or a scaling factor of two.
4. The DC has a DPI of 96.
The first step is to calculate the PDF page's dimensions in pixels:
width = (576 / 72) * 96 * (200 / 100) = 1536 pixels;
height = 2112 pixels.
Therefore the width of the required page portion is:
portion_width = ((360 - 144) / 72) * 96 * (200 / 100) = 576 pixels;
portion_height = 960 pixels.
The top-left point of the drawn area must be located at the coordinates (10, 10) on the DC. Therefore the top-left point of the complete page will have the following coordinates:
Page_Origin_X = 10 - (144 / 72) * 96 * 200 / 100 = -374;
Page_Origin_Y = 10 - (288 / 72) * 96 * 200 / 100 = -758;
The required values are therefore: WholePageRect = {-374, -758, -354 + 1536, -758 + 2112}; and DrawRect = {10, 10, 10 + 576, 10 + 960}.