/** * 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: '

Silent Print

' }) } async printHTML() { await RNPrint.print({ html: '

Heading 1

Heading 2

Heading 3

' }) } async printPDF() { const results = await RNHTMLtoPDF.convert({ html: '

Custom converted PDF Document

', fileName: 'test', base64: true, }) await RNPrint.print({ filePath: results.filePath }) } async printRemotePDF() { await RNPrint.print({ filePath: 'https://graduateland.com/api/v2/users/jesper/cv' }) } customOptions = () => { return ( {this.state.selectedPrinter && {`Selected Printer Name: ${this.state.selectedPrinter.name}`} {`Selected Printer URI: ${this.state.selectedPrinter.url}`} }