Javascript 如何在react native中使用react native Image to pdf将图像转换为pdf
我正在尝试使用react native image to pdf将图像转换为pdf。我使用react native view shot保存了该图像。但是现在。我不知道为什么在下面的代码中,他们使用两个时间映像路径,比如=“imagepath:imagepath:[image]”。还有名字。当我在vs代码中复制该代码时。然后我得到了错误,因为这两个图像路径和名称。但是当我从那里移除一个图像路径和名称时。调用该函数后,我得到如下错误:“(错误:尝试调用虚拟方法”boolean android.graphics.Bitmap.compress(android.graphics.Bitmap$CompressFormat,int,java.io.OutputStream)”,在空对象引用上]”。请帮帮我 以下是pdf格式的图像代码Javascript 如何在react native中使用react native Image to pdf将图像转换为pdf,javascript,react-native,pdf,Javascript,React Native,Pdf,我正在尝试使用react native image to pdf将图像转换为pdf。我使用react native view shot保存了该图像。但是现在。我不知道为什么在下面的代码中,他们使用两个时间映像路径,比如=“imagepath:imagepath:[image]”。还有名字。当我在vs代码中复制该代码时。然后我得到了错误,因为这两个图像路径和名称。但是当我从那里移除一个图像路径和名称时。调用该函数后,我得到如下错误:“(错误:尝试调用虚拟方法”boolean android.gra
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: "",
};
你找到解决办法了吗?