GitHub

PDFDownloadLink

Web only

Anchor tag to enable generate and download PDF documents on the fly. Refer to on the fly rendering for more information.

import { PDFDownloadLink, Document, Page, Text } from '@react-pdf/renderer';

const invoice = (
  <Document>
    <Page size="A4">
      <Text>Invoice #42</Text>
    </Page>
  </Document>
);

const App = () => (
  <PDFDownloadLink document={invoice} fileName="invoice.pdf">
    {({ loading }) => (loading ? 'Preparing document...' : 'Download')}
  </PDFDownloadLink>
);

Valid props

Prop nameDescriptionTypeDefault
documentPDF document implementationDocumentundefined
fileNameDownload PDF file nameStringundefined
styleDefines anchor tag stylesObject, Arrayundefined
classNameDefines anchor tag class nameStringundefined
childrenAnchor tag contentDOM node, Functionundefined
onClickClick handler. Receives click event and PDF instance as argumentsFunctionundefined

On this page