react-native - 将 ReactNative 屏幕/视图导出为 PDF
问题描述
我有 ReactNative 应用程序。我可以将应用程序的主屏幕/视图保存为 PDF 或任何其他可打印文件格式吗?
解决方案
@反应巴拉,
使用react-native-view-shot组件。
https://github.com/gre/react-native-view-shot
import RNViewShot from "react-native-view-shot";
RNViewShot.takeSnapshot(viewRef, {
format: "jpeg",
quality: 0.8
})
.then(
uri => console.log("Image saved to", uri),
error => console.error("Oops, snapshot failed", error)
);
你得到图像URI
之后
使用此组件将图像转换为 pdf...
推荐阅读
- android - 水平嵌套回收器视图在垂直父级中加载奇怪的信息
- networking - 为什么人们说 TCP Potocol 是端到端 Potocol?
- azure - 如何保留/保存特定的 Azure 备份
- java - Camel CXF 配置 WS-Adressing - ReplyTo 和 MessageID
- java - 无法在 Android 应用上使用 appium 代码执行简单的点击操作
- ios - Swift:基于奇数或偶数项的 2 列网格中的 UICollectionView 动态单元格大小
- python-3.x - windows而不是linux中的时间问题
- haskell - Haskell 中并行计算的性能问题
- ios - iOS 12 上未显示图标字体
- xml - 将数据从 XML 响应传输到 SoapUI 属性