DocsEnginesRenderingRender Page

renderPage

Renders a full PDF page into an image.

Signature

renderPage( doc: PdfDocumentObject, page: PdfPageObject, options?: PdfRenderPageOptions ): PdfTask<T>;

Description

This is the primary method for creating a visual representation of a PDF page. It renders the entire page content, including text, graphics, and optionally annotations, into an image buffer. The output format, scaling, and rotation can be customized via the options parameter.

The generic type T will be a Blob in browser environments and a Buffer in Node.js, depending on the configured imageDataConverter.

Parameters

NameTypeDescription
docPdfDocumentObjectThe handle of the document to render from.
pagePdfPageObjectThe specific page object within the document to render.
optionsPdfRenderPageOptions(Optional) An object to customize the rendering output.

PdfRenderPageOptions Details

OptionTypeDescription
scaleFactornumberThe render scaling factor (zoom level). Default: 1.0.
rotationRotationThe rotation to apply in degrees (0, 90, 180, 270). Default: Rotation.Degree0.
dprnumberThe Device Pixel Ratio, used for rendering crisp images on high-resolution screens. Default: 1.
imageType'image/webp' | 'image/png' | 'image/jpeg'The output image format. Default: 'image/webp'.
withAnnotationsbooleanSet to true to include annotations in the rendered image. Default: false.

Returns

PdfTask<T>

A Task that resolves with the rendered image (Blob or Buffer). This can be displayed in an <img> tag, drawn on a canvas, or saved to a file.

The Task will be rejected if the document or page handle is invalid.

See Concepts: Tasks for more on how to handle asynchronous operations.

Example

// Assuming 'engine' and an open 'document' object are available async function renderFirstPage(doc) { try { const firstPage = doc.pages[0]; const imageBlob = await engine.renderPage(doc, firstPage, { scaleFactor: 1.5, // Render at 150% zoom withAnnotations: true, }).toPromise(); // In a browser, you can create a URL to display the image const imageUrl = URL.createObjectURL(imageBlob); document.getElementById('my-image-element').src = imageUrl; } catch (error) { console.error('Failed to render page:', error); } }

See Also

Last updated on August 14, 2025

Need Help?

Join our community for support, discussions, and to contribute to EmbedPDF's development.