Render Plugin

The Render Plugin is the visual heart of the PDF viewer. It is responsible for taking the raw PDF data from the core engine and “painting” it onto the screen. It supports high-fidelity rendering of text, images, vector graphics, and form widgets.

This plugin works seamlessly in multi-document environments, allowing you to render pages from different documents simultaneously using specific documentId references.

Installation

The plugin is available as a separate NPM package and is essential for any visual viewer.

npm install @embedpdf/plugin-render

Registration

Import RenderPluginPackage and add it to the plugins array. You can configure global defaults for form and annotation rendering here.

import { createPluginRegistration } from '@embedpdf/core' import { EmbedPDF } from '@embedpdf/core/react' // ... other imports import { RenderPluginPackage } from '@embedpdf/plugin-render/react' const plugins = [   // ... other essential plugins   createPluginRegistration(DocumentManagerPluginPackage, { /* ... */ }),   createPluginRegistration(ViewportPluginPackage),   createPluginRegistration(ScrollPluginPackage),   // Register the render plugin   createPluginRegistration(RenderPluginPackage, { // Optional: Draw form widget visuals (checkboxes, text content) // Note: This is for display only, not interaction. withForms: true, // Optional: Burn annotations into the render (usually handled by AnnotationPlugin instead) withAnnotations: false, }), ]

Usage

The plugin allows you to render pages declaratively via the <RenderLayer /> component or imperatively via the useRenderCapability hook (e.g., for exporting images).

Primary Usage: The <RenderLayer /> Component

This is the standard way to display a page. Place the <RenderLayer /> component inside the renderPage prop of your <Scroller />.

You must provide the documentId to tell the renderer which document the page belongs to. The component automatically detects the current scale and refresh version from the document state.

<Scroller documentId={activeDocumentId}   renderPage={({ pageIndex }) => (     <div style={{ position: 'relative' }}>       {/* The RenderLayer is responsible for drawing the page */}       <RenderLayer documentId={activeDocumentId} pageIndex={pageIndex} />     </div>   )} />

Advanced Usage: On-Demand Rendering

For tasks like generating thumbnails, creating snapshots, or exporting pages as images, use the useRenderCapability hook.

Because multiple documents may be open, you must scope your request using .forDocument(id).

import { useRenderCapability } from '@embedpdf/plugin-render/react'; const ExportButton = ({ documentId }) => {   const { provides: renderPlugin } = useRenderCapability();   const exportPage = () => { // 1. Scope the renderer to the specific document const renderer = renderPlugin?.forDocument(documentId); // 2. Request a render     const task = renderer?.renderPage({ pageIndex: 0, options: { scaleFactor: 2.0, imageType: 'image/png' } });     task?.wait(blob => {       // ... handle the image blob (e.g., download it)     });   };   return <button onClick={exportPage}>Export Page 1</button> }

Live Example

This example shows a PDF viewer with a custom “Export” toolbar. It uses the RenderPlugin to take a high-resolution snapshot of the first page, including annotations, and triggers a download.

Loading PDF Engine...

API Reference

Configuration (RenderPluginConfig)

OptionTypeDescription
withFormsbooleanIf true, the visual appearance of form widgets (checkboxes, filled input text) will be drawn onto the page image. This does not create interactive elements.
Default: false
withAnnotationsbooleanIf true, annotations will be baked into the page image.
Default: false

Component: <RenderLayer />

The component that renders a single PDF page.

PropTypeDescription
documentIdstring(Required) The ID of the document this page belongs to.
pageIndexnumber(Required) The 0-based index of the page to render.
scalenumberOptional scale override. If omitted, uses the document’s current zoom level.
dprnumberThe device pixel ratio to use.
Default: window.devicePixelRatio

Hook: useRenderCapability()

Access the rendering API.

Returns

PropertyTypeDescription
providesRenderCapability | nullThe render API object.

RenderCapability Methods

MethodDescription
forDocument(id)Returns a RenderScope for the specified document ID.

RenderScope Methods (Returned by forDocument)

MethodDescription
renderPage(options)Renders a full page to a Blob. options: { pageIndex, options: PdfRenderPageOptions }.
renderPageRect(options)Renders a sub-region of a page. options: { pageIndex, rect, options: PdfRenderPageOptions }.

PdfRenderPageOptions

OptionTypeDescription
scaleFactornumberThe scale to render at. Default: 1.0.
withAnnotationsbooleanInclude annotations in render. Default: Plugin config value.
withFormsbooleanInclude form visuals in render. Default: Plugin config value.
imageTypestringOutput format: 'image/webp', 'image/jpeg', 'image/png'.
imageQualitynumber0 to 1 quality for lossy formats.
Last updated on December 5, 2025

Need Help?

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