# react-native-print Print documents using React Native. ## Installation Run `npm install react-native-print --save` ## Add it to your project ### Automatic Run `react-native link` ### Manual #### iOS 1. Open your project in XCode, right click on [Libraries](http://url.brentvatne.ca/jQp8) and select [Add Files to "Your Project Name](http://url.brentvatne.ca/1gqUD). 2. Choose the file `node_modules/react-native-print/RNPrint.xcodeproj` 3. Go to `Project Manager` tab and click on your project's name. Select the name of the target and click on `Build Phases` 4. Add `libRNPrint.a` to `Link Binary With Libraries` [(Screenshot)](http://url.brentvatne.ca/17Xfe). #### Android - Edit `android/settings.gradle` to included ```java include ':react-native-print' project(':react-native-print').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-print/android') ``` - Edit `android/app/build.gradle` file to include ```java dependencies { .... compile project(':react-native-print') } ``` - Edit `MainApplication.java` to include ```java // import the package import com.christopherdro.RNPrint.RNPrintPackage; // include package new MainReactPackage(), new RNPrintPackage(), ``` ## Usage ```javascript /** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import { AppRegistry, Button, StyleSheet, NativeModules, Platform, Text, View } from 'react-native'; import RNHTMLtoPDF from 'react-native-html-to-pdf'; import RNPrint from 'react-native-print'; export default class RNPrintExample extends Component { state = { selectedPrinter: null } // @NOTE iOS Only selectPrinter = async () => { const selectedPrinter = await RNPrint.selectPrinter() this.setState({ selectedPrinter }) } // @NOTE iOS Only silentPrint = async () => { if (!this.state.selectedPrinter) { alert('Must Select Printer First') } const jobName = await RNPrint.print({ printerURL: this.state.selectedPrinter.url, html: '