Skip to main content
Version: Version 5

Interface: Image

Interface representing the image provided by the PDF renderer.

The image contains a pixel buffer and dimensions. On high-DPI displays, the buffer contains more pixels than the logical dimensions indicate.

To determine the effective DPR (device pixel ratio) used for rendering, compute it from the buffer size relative to the logical dimensions:

const dpr = Math.sqrt(buffer.byteLength / (width * height * 4));

Example: A 500x500 logical image rendered at DPR 2 has:

  • Logical size: 500x500 (used for layout/positioning)
  • Buffer size: 1000x1000 pixels (used for sharp rendering)
  • Buffer length: 1000 * 1000 * 4 = 4,000,000 bytes (RGBA)
  • Computed DPR: Math.sqrt(4000000 / (500 * 500 * 4)) = 2

Properties

buffer

buffer: ArrayBuffer

Raw RGBA pixel data. Size = (width * dpr) * (height * dpr) * 4 bytes.


height

height: number

Height in logical pixels (used for layout/positioning, unaffected by DPR).


width

width: number

Width in logical pixels (used for layout/positioning, unaffected by DPR).