react-pdf — создание PDF на React

★ 16.8K

react-pdf (the @react-pdf/renderer package) is an open-source library that creates PDF files from React components and works in both the browser and on the server. Reach for it when PDFs have to be assembled programmatically from application data and you would rather describe a page with familiar components than low-level commands, when a document should appear in a viewer inside the browser, or when a file has to be saved to disk from Node.js. Inside: its own React renderer with Document, Page, View and Text components and StyleSheet-based styling with flexbox layout. Install it with `yarn add @react-pdf/renderer`; no separate service is needed. In the browser the document is shown by the PDFViewer component, and in Node.js it is written to a file with `ReactPDF.render()`. It is written in TypeScript and MIT licensed. The focus is creating new PDFs, not displaying existing ones: for viewing existing files the README points to a different library, wojtekmaj/react-pdf. It suits React projects; not the right tool if you need to display or edit an existing PDF.