A complete Office Suite in your React Native App

Soon you might be able to build your Office Suite in your React Native App thanks to Christopher Dro.

For now he has released two key Components.

react-native-html-to-pdf on GitHub (Example)

Convert HTML strings to PDF documents using React Native

The example project included demonstrates how you can create a PDF file from a html string and email it as an attachment using react-native-mail.

var Example = React.createClass({

  createPDF() {
    var options = {
      html: '<h1>PDF TEST</h1>', // HTML String

      fileName: 'test'           // Optional: Custom Filename excluded extention
                                 // Default: Randomly generated

      directory: 'docs'          // Optional: 'docs' will save the file in the `Documents`
                                 // Default: Temp directory
    };

    HTMLtoPDF.convert(options).then((filePath) => {
      console.log(filePath);
    });
  },

  render() {
    <View>
      <TouchableHighlight onPress={this.createPDF}>
        <Text>Create PDF</Text>
      </TouchableHighlight>
    </View>
  }
});

react-native-print on GitHub (Example)

Print documents using React Native.

The example project included demonstrates how you use react-native-html-to-pdf to create a PDF from a html string then prompt the print dialog.

var Example = React.createClass({
  printDocument(filePath) {
    RNPrint.print(filePath).then((jobName) => {
      console.log(`Printing ${jobName} complete!`);
    });
  },

  render() {
    <View>
      <TouchableHighlight onPress={this.printPDF(filePath)}>
        <Text>Print Document</Text>
      </TouchableHighlight>
    </View>;
  },
});