Answers for "how to preview a pdf document in react"

3

how to preview a pdf document in react

<object data="http://africau.edu/images/default/sample.pdf" type="application/pdf" width="100%" height="100%">
      <p>Alternative text - include a link <a href="http://africau.edu/images/default/sample.pdf">to the PDF!</a></p>
  </object>
Posted by: Guest on June-11-2021
2

how to create a pdf in react

/*
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>
);
Posted by: Guest on December-14-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language