Skip to content

Instantly share code, notes, and snippets.

@Karnak19
Created June 24, 2019 11:03
Show Gist options
  • Select an option

  • Save Karnak19/110d04a7852549c23200d900e69cc0d0 to your computer and use it in GitHub Desktop.

Select an option

Save Karnak19/110d04a7852549c23200d900e69cc0d0 to your computer and use it in GitHub Desktop.
React-PDF props
import React from "react";
import { PDFViewer } from "@react-pdf/renderer";
import "./App.css";
import MyDocument from "./MyDocument";
const datas = {
name: "Basile",
lastName: "Vernouillet",
job: "React Node Trainer",
company: "Wild Code School"
};
function App() {
return (
<div className="App">
<PDFViewer>
<MyDocument {...datas} />
</PDFViewer>
</div>
);
}
export default App;
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 = ({ name, lastName, job, company }) => (
<Document>
<Page size="A4" style={styles.page}>
<View style={styles.section}>
<Text>{name}</Text>
<Text>{lastName}</Text>
</View>
<View style={styles.section}>
<Text>{job}</Text>
<Text>{company}</Text>
</View>
</Page>
</Document>
);
export default MyDocument;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment