GitHub
ComponentsImage

Image

A React component for displaying network or local (Node only) JPG or PNG images, as well as base64 encoded image strings.

import { Image } from '@react-pdf/renderer';

const Logo = () => (
  <Image
    src="https://react-pdf.org/images/luke.jpg"
    style={{ width: 120, height: 120 }}
  />
);
Show preview

Valid props

Prop nameDescriptionTypeDefault
srcSource of the image. See moreSource objectundefined
sourceAlias of src. See moreSource objectundefined
styleDefines view styles. See moreObject, Arrayundefined
debugEnables debug mode on view bounding box. See moreBooleanfalse
fixedRenders component in all wrapped pages. See moreBooleanfalse
breakForces the wrapping algorithm to start a new page when rendering this element. See moreBooleanfalse
minPresenceAheadHint that no page wrapping should occur between all sibling elements following the element within n points. See moreNumber0
cacheEnables image caching between consecutive rendersBooleantrue
srcSetResponsive image sources for resolution-based selection. E.g. "small.jpg 300w, medium.jpg 600w"Stringundefined
sizesDisplay width used for srcSet source selectionString, Numberundefined
bookmarkAttach bookmark to element. See moreString or Bookmarkundefined

Source object

Defines the source of an image. Can be in any of these four valid forms:

Form typeDescriptionExample
StringValid image URL or filesystem path (Node only)www.react-pdf.org/test.jpg
URL objectEnables to pass extra parameters on how to fetch images{ uri: valid-url, method: 'GET', headers: {}, body: '', credentials: 'include' }
BufferRenders image directly from Buffer. Image format (png or jpg) will be guessed based on Buffer.Buffer
Data bufferRenders buffer image via the data key. It's also recommended to provide the image format so the engine knows how to proccess it{ data: Buffer, format: 'png' | 'jpg' }
FunctionA function that returns (can also return a promise that resolves to) any of the above formats() => String | Promise<String>

On this page