react- native创建pdf

 npm i react-native-html-to-pdf

  • AndroidManifest.xml添加以下WRITE_EXTERNAL_STORAGE权限:

 

使用:
 

import React, { Component } from 'react';
import {
  Text,
  TouchableHighlight,
  View,
} from 'react-native';
import RNHTMLtoPDF from 'react-native-html-to-pdf';

export default class Example extends Component {
  async createPDF() {
    const options = {
      html: '

PDF 测试

', fileName: 'test', directory: 'Documents', }; const file = await RNHTMLtoPDF.convert(options); // console.log(file.filePath); alert(file.filePath); } render() { return ( 创建PDF ); } }

你可能感兴趣的:(react.js,pdf,前端,react,native)