<img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?event=init&amp;tid=2612994575055&amp;pd[em]=<hashed_email_address>&amp;noscript=1">
Skip to content
    AdminSep 16, 2023 9:47:19 PM< 1 min read

    React native PDF Creator

    React native PDF Creator

    install package react-native-html-to-pdf.

    import React, { Component } from 'react';
    
    import {
      Text,
      TouchableHighlight,
      View,
    } from 'react-native';
    
    import RNHTMLtoPDF from 'react-native-html-to-pdf';
    
    class Example extends Component {
      async createPDF() {
        let options = {
          html: '<h1>Example PDF</h1>',
          fileName: 'example',
          directory: 'Documents',
        };
    
        let file = await RNHTMLtoPDF.convert(options)
        console.log(file.filePath);
      }
    
      render() {
        return(
          <View>
            <TouchableHighlight onPress={this.createPDF}>
              <Text>Create PDF</Text>
            </TouchableHighlight>
          </View>
        )
      }
    }
    
    export default Example;

    click for more React codes

    COMMENTS

    RELATED ARTICLES