PXCV_DrawPageToIStream

<< Click to Display Table of Contents >>

Navigation:  Functions >

PXCV_DrawPageToIStream


 

pdf-xchange-editor-simple-sdk_100x100 PXCV_DrawPageToIStream

 


 

PXCV_DrawPageToIStream renders the specified page and saves it to the stream object.

 

HRESULT  PXCV_DrawPageToIStream(

PXVDocument Doc,

DWORD page_num,

LPPXV_CommonRenderParameters pParams,

COLORREF backcolor,

LPPXV_DrawToImageParams pImageParams,

IStreampDest

);

 

Parameters

 

Doc

[in] Specifies a document that PXCV_Init created.

 

page_num

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

 

pParams

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

 

backcolor

[in] Specifies the color used to fill the background before pages are rendered. The most significant byte is used as the transparency value. 0 is full transparency and 255 is no transparency.

 

pImageParams

[in] Pointer to the PXV_DrawToImageParams structure, which defines the parameters of generated image files.

 

pDest

[in] Pointer to the IStream object where images that this function creates are stored.

 

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 DrawPageToPNG(PXVDocument pDocDWORD page_numLPCWSTR sFileName)

{

    HRESULT hr = S_OK;

 

  RECT rect;

    PXV_CommonRenderParameters crp = {0};    // common render parameters - used to specify which part of the page and into with

                                             // which size should rasterised (in our example whole page into 600x800 rect)

                                             // also defines different render options

    PXV_DrawToImageParams dip = {0};         // specify resulting image parameters, like format, bits per pixel

     

    IStreampImage = NULL;            // in real app it will be the stream where image should be stored; here I'm using stream on file

     

    // lets create a stream on file where our rendered image will be stored

    hr = SHCreateStreamOnFile(sFileNameSTGM_CREATE | STGM_READWRITE, &pImage);

    // lets specify parameters for rendering

    rect.left = 0rect.top = 0;

    rect.right = 600rect.bottom = 800;

    crp.WholePageRect = &rect;

    crp.DrawRect = &rect;

    crp.Flags = pxvrpf_EmbeddedFontAsCurves | pxvrpf_NoTransparentBkgnd;

    crp.RenderTarget = pxvrm_Exporting;

    dip.ImageFormat = IMGF_PNG;

    dip.Flags = 0;    // reserved

    dip.Bpp = 24;

     

    // rendering

    hr = PXCV_DrawPageToIStream(pDoc0, &crpRGB(255255255) | 0xFF000000, &dippImage);

     

    pImage->Release();

    return hr;

}