javascript - 如何在 react native 中使用 react-native-image-to-pdf 将图像转换为 pdf
问题描述
我正在尝试使用 react-native-image-to-pdf 将图像转换为 pdf。我已经使用 react-native-view-shot 保存了该图像。但现在。我不知道为什么在下面的代码中他们使用两次像这样的 imagePaths =“imagePaths:imagePaths:[image]”。也为了名字。当我在我的 vs 代码中复制该代码时。然后由于这两个 imagePaths 和名称而出现错误。但是当我从那里删除一个 imagePaths 和名称时。然后在调用该函数后,我在空对象引用]"。请帮我。
这是图像到pdf的代码
imageToPdf = async () => {
try {
const options = {
imagePaths: imagePaths: [this.state.imagePath],
name: name: "PDFName",
maxSize: { // optional maximum image dimension - larger images will be resized
width: 900,
// height: Math.round(deviceHeight() / deviceWidth() * 900),
height: 900,
},
quality: 0.7, // optional compression paramter
};
const pdf = await RNImageToPdf.createPDFbyImages(options);
console.log(pdf.filePath);
} catch (e) {
console.log(e);
}
};
这是状态
this.state = {
imagePath: "",
};
解决方案
推荐阅读
- python-3.x - 将字节解码为文本和比较有问题吗?
- r - 在 R 中引用参数
- python - 如何只允许从 REPL 调用函数,而不是其他函数?
- python - 如何获取烧瓶中html标签中变量的值?
- ios - '证书 bundleId 与您的应用程序不匹配' Firebase Cloud Messaging
- python - xml文件的每次迭代的新列表
- docker - 如何在 k8s 中等待其他容器完成执行?
- python-3.x - 用换行符打印长字符串的 Python 指令代码
- python - Python编写函数将大写引入布尔值
- javascript - 使用 tensorflow-js 在网络摄像头上进行对象检测