react pdf generator
/*
Make sure to install the library
with yarn
yarn add @react-pdf/renderer
with npm
npm install @react-pdf/renderer --save
*/
import React from 'react';
import { Page, Text, View, Document, 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>
);var doc = new jsPDF();
doc.fromHTML(ReactDOMServer.renderToStaticMarkup(this.render()));
doc.save("myDocument.pdf");yarn add @react-pdf/renderer
Also in JavaScript:
- javascript select letter in string
- how to count duplicates in an array javascript
- expressjs create encrypted password
- if mousepressed javascript
- set node_env in windows
- array sort by alphabetical javascript
- how to get MAC id of nodemcu
- if statements javascript
- arrow functions javascript
- angular load json file with httpclient
- responsive grid using antd
- sort numbers in array javascript
- cognito listUser using amazon-cognito-identity-js
- how to select text javascript
- getFullYear within moment in angular
- check for duplicates in array javascript
- angular material input
- * http://sizzlejs.com/
- copy array javascript
- javascript how to reverse a string
- pass value from one component to another in polymer
- jquery submit form on enter
- react native passing params to nested navigators
- js call and apply