ViewerPDFDownloadLink
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 name | Description | Type | Default |
|---|---|---|---|
| document | PDF document implementation | Document | undefined |
| fileName | Download PDF file name | String | undefined |
| style | Defines anchor tag styles | Object, Array | undefined |
| className | Defines anchor tag class name | String | undefined |
| children | Anchor tag content | DOM node, Function | undefined |
| onClick | Click handler. Receives click event and PDF instance as arguments | Function | undefined |