 | PdfiumFPDF_RenderPageBitmap_Start Method |
Start to render page contents to a device independent bitmap progressively.
Namespace: Patagames.PdfAssembly: Patagames.Pdf (in Patagames.Pdf.dll) Version: 4.94.2704
Syntaxpublic static ProgressiveStatus FPDF_RenderPageBitmap_Start(
IntPtr bitmap,
IntPtr page,
int start_x,
int start_y,
int size_x,
int size_y,
PageRotate rotate,
RenderFlags flag,
IFSDK_PAUSE pause
)
Public Shared Function FPDF_RenderPageBitmap_Start (
bitmap As IntPtr,
page As IntPtr,
start_x As Integer,
start_y As Integer,
size_x As Integer,
size_y As Integer,
rotate As PageRotate,
flag As RenderFlags,
pause As IFSDK_PAUSE
) As ProgressiveStatus
public:
static ProgressiveStatus FPDF_RenderPageBitmap_Start(
IntPtr bitmap,
IntPtr page,
int start_x,
int start_y,
int size_x,
int size_y,
PageRotate rotate,
RenderFlags flag,
IFSDK_PAUSE^ pause
)
static member FPDF_RenderPageBitmap_Start :
bitmap : IntPtr *
page : IntPtr *
start_x : int *
start_y : int *
size_x : int *
size_y : int *
rotate : PageRotate *
flag : RenderFlags *
pause : IFSDK_PAUSE -> ProgressiveStatus
public static ProgressiveStatus FPDF_RenderPageBitmap_Start(
IntPtr bitmap,
IntPtr page,
int start_x,
int start_y,
int size_x,
int size_y,
PageRotate rotate,
RenderFlags flag,
IFSDK_PAUSE pause
)
Patagames.Pdf.Pdfium.FPDF_RenderPageBitmap_Start = function(bitmap, page, start_x, start_y, size_x, size_y, rotate, flag, pause);
Parameters
- bitmap IntPtr
- Handle to the device independent bitmap (as the output buffer). Bitmap handle can be created by FPDFBitmap_Create(Int32, Int32, Boolean) function.
- page IntPtr
- Handle to the page. Returned by FPDF_LoadPage(IntPtr, Int32) function
- start_x Int32
- Left pixel position of the display area in the bitmap coordinate.
- start_y Int32
- Top pixel position of the display area in the bitmap coordinate.
- size_x Int32
- Horizontal size (in pixels) for displaying the page.
- size_y Int32
- Vertical size (in pixels) for displaying the page.
- rotate PageRotate
- Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise).
- flag RenderFlags
- 0 for normal display, or combination of flags defined above.
- pause IFSDK_PAUSE
- The IFSDK_PAUSE interface.A callback mechanism allowing the page rendering process
Return Value
ProgressiveStatusRendering Status. See flags for progressive process status for the details.
Examplepublic void ProgressiveRenderPage()
{
IntPtr doc = Pdfium.FPDF_LoadDocument(@"Files\test001.pdf");
IntPtr page = Pdfium.FPDF_LoadPage(doc, 0);
double width, height;
Pdfium.FPDF_GetPageSizeByIndex(doc, 0, out width, out height);
IntPtr bitmap = Pdfium.FPDFBitmap_Create((int)width, (int)height, true);
bool needPause = true;
IFSDK_PAUSE pause = new IFSDK_PAUSE();
pause.needToPauseNowCallback = (pthis) =>
{
return needPause;
};
var ret = Pdfium.FPDF_RenderPageBitmap_Start(bitmap, page, 0, 0, (int)width, (int)height, PageRotate.Normal, RenderFlags.None, pause);
if (ret == ProgressiveRenderingStatuses.RenderFailed)
throw new Exception();
else if (ret == ProgressiveRenderingStatuses.RenderTobeContinued)
{
needPause = false;
ret = Pdfium.FPDF_RenderPage_Continue(page, pause);
}
if (ret == ProgressiveRenderingStatuses.RenderDone)
Pdfium.FPDF_RenderPage_Close(page);
else
throw new Exception();
IntPtr buffer = Pdfium.FPDFBitmap_GetBuffer(bitmap);
int stride = Pdfium.FPDFBitmap_GetStride(bitmap);
using (System.Drawing.Bitmap bmp = new System.Drawing.Bitmap((int)width, (int)height, stride, System.Drawing.Imaging.PixelFormat.Format32bppArgb, buffer))
{
bmp.Save("FPDF_RenderPage_Continue.png", System.Drawing.Imaging.ImageFormat.Png);
}
Pdfium.FPDFBitmap_Destroy(bitmap);
Pdfium.FPDF_ClosePage(page);
Pdfium.FPDF_CloseDocument(doc);
}
See Also