PXCV_DrawPageToDC

<< Click to Display Table of Contents >>

Navigation:  Functions >

PXCV_DrawPageToDC


 

pdf-xchange-editor-simple-sdk_100x100 PXCV_DrawPageToDC

 


 

PXCV_DrawPageToDC draws specified pages to a device context.

 

HRESULT  PXCV_DrawPageToDC(

PXVDocument Doc,

DWORD page_num,

HDC hDC,

LPPXV_CommonRenderParameters pParams

);

 

Parameters

 

Doc

[in] Specifies a document that PXCV_Init created.

 

page_num

[in] Specifies the zero-based page number to be drawn.

 

hDC

[in] Specifies the handle of the device context onto which page information is drawn.

 

pParams

[in] Pointer to the PXV_CommonRenderParameters structure that defines drawing parameters.

 

Please note that all functions and parameters are case-sensitive.

 

Return Values

 

If the function fails then the return value is an error code.

 

If the function succeeds then the return value is DS_OK or a different value that isn't an error code.

 

Example (C++)

 

HRESULT DrawPageThumbnail(PXVDocument pDoc, DWORD page_num, LPCRECT thumb_bound_rect, HDC dc)

{

HRESULT hr;

double pwph;

hr = PXCV_GetPageDimensions(pDoc, page_num, &pw, &ph);

if (IS_DS_FAILED(hr))

return hr;

// calculation rect of thumbnail in pixels

// (fitting page proportional into thumb_bound_rect)

LONG tbw = thumb_bound_rect->right - thumb_bound_rect->left;

LONG tbh = thumb_bound_rect->bottom - thumb_bound_rect->top;

LONG tw = tbw;

LONG th = tbh;

double z1 = (double)tw / pw;

double z2 = (double)th / ph;

if (z1 >= z2)

{

tw = (LONG)(z2 * pw + 0.5);

}

else

{

th = (LONG)(z1 * ph + 0.5);

}

RECT thumb_rect;

thumb_rect.left = thumb_bound_rect->left + (tbw - tw) / 2;

thumb_rect.top = thumb_bound_rect->top + (tbh - th) / 2;

thumb_rect.right = thumb_rect.left + tw;

thumb_rect.bottom = thumb_rect.top + th;

// now filling PXV_CommonRenderParameters structure

PXV_CommonRenderParameters crp;

crp.WholePageRect = &thumb_rect;

crp.DrawRect = NULL; // because we will draw whole page. It is equal to: crp.DrawRect = &thumb_rect;

crp.Flags = 0;       // should be zero as specified

crp.RenderTarget = pxvrm_Viewing;

hr = PXCV_DrawPageToDC(pDocpage_numdc, &crp);

return hr;

}