我正在使用
react-native-html-to-pdf
包将 html 内容转换为 pdf,这在 Android 上运行良好,但 iOS 总是返回空白屏幕。
const options = {
html: htmlContent,
fileName:
voucher.clientID.toString() + ' - ' + voucher.archiveNo.toString(),
directory: 'Documents',
};
const pdfFile: any = await RNHTMLtoPDF.convert(options);
谁有这个问题的解决方案吗?
检查您的 iOS 应用程序是否具有写入提供的目录(“文档”)所需的权限。要在 iOS 上执行文件操作,您可能需要使用 RNFS(React Native File System)包。使您的程序有权写入 Documents 目录。
import RNFS from 'react-native-fs';
const path = RNFS.DocumentDirectoryPath + '/' + options.fileName + '.pdf';
const pdfFile = await RNHTMLtoPDF.convert({ ...options, filePath: path });