
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
@react-pdf/renderer
Advanced tools
React renderer for creating PDF files on the browser and server
yarn add @react-pdf/renderer
import { Document, Page, Text, View, StyleSheet } from '@react-pdf/renderer';
// Create styles
const styles = StyleSheet.create({
page: {
flexDirection: 'row',
backgroundColor: '#E4E4E4',
},
section: {
margin: 10,
padding: 10,
flexGrow: 1,
},
});
// Create Document Component
const MyDocument = () => (
<Document>
<Page size="A4" style={styles.page}>
<View style={styles.section}>
<Text>Section #1</Text>
</View>
<View style={styles.section}>
<Text>Section #2</Text>
</View>
</Page>
</Document>
);
Web. Render in DOMimport ReactDOM from 'react-dom';
import { PDFViewer } from '@react-pdf/renderer';
const App = () => (
<PDFViewer>
<MyDocument />
</PDFViewer>
);
ReactDOM.render(<App />, document.getElementById('root'));
Node. Save in a fileimport ReactPDF from '@react-pdf/renderer';
ReactPDF.render(<MyDocument />, `${__dirname}/example.pdf`);
For each example, try opening output.pdf to see the result.
|
Text |
Resume |
Fractals |
|
Knobs |
Page wrap |
This project exists thanks to all the people who contribute. [Contribute].
Thank you to all our sponsors! [Become a sponsors]
Thank you to all our backers! [Become a backer]
MIT © Diego Muracciole
PDFKit is a JavaScript library for generating PDF documents, written in Node.js. It provides a lower-level API compared to @react-pdf/renderer, which allows for more fine-grained control over the PDF creation process. However, it lacks the declarative, component-based approach of React.
jsPDF is a popular library for generating PDF documents in the browser. It offers a wide range of features for creating and manipulating PDFs, but it does not use a React-based approach. Instead, it relies on a more traditional, imperative API.
pdfmake is a library for creating PDF documents in the browser and Node.js. It uses a declarative approach similar to @react-pdf/renderer but does not integrate with React. It provides a robust set of features for building complex PDF documents.
FAQs
Create PDF files on the browser and server
The npm package @react-pdf/renderer receives a total of 929,887 weekly downloads. As such, @react-pdf/renderer popularity was classified as popular.
We found that @react-pdf/renderer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.