Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image React Native将base64图像数组转换为单个pdf_Image_Pdf_React Native_Base64 - Fatal编程技术网

Image React Native将base64图像数组转换为单个pdf

Image React Native将base64图像数组转换为单个pdf,image,pdf,react-native,base64,Image,Pdf,React Native,Base64,我正在react native/redux中开发一个移动应用程序,其中我必须将base64图像数组转换为pdf,以便将pdf发送到后端。 关于如何实现它有什么想法吗?好的,在 它是基于promis的。在一个名为“pdfConverter.js”的文件中,我创建了这个函数 import RNImageToPdf from "react-native-image-to-pdf"; export default base64Arr => { // It is a promise based

我正在react native/redux中开发一个移动应用程序,其中我必须将base64图像数组转换为pdf,以便将pdf发送到后端。
关于如何实现它有什么想法吗?

好的,在 它是基于promis的。在一个名为“pdfConverter.js”的文件中,我创建了这个函数

import RNImageToPdf from "react-native-image-to-pdf";

export default base64Arr => {
  // It is a promise based function
  // Create an array containing the path of each base64 images
  let base64Paths = [];
  base64Paths.length = 0; // re-initialize the array for further re-use

  base64Arr.forEach(base64 => {
    base64Paths.push(`data:image/jpeg;base64,${base64}`);
  });

  // Convert base64 images to pdf from the paths array
  return RNImageToPdf.createPDFbyImages({
    imagePaths: base64Paths,
    name: "PDF_Name"
  });
};
然后在我需要的另一个文件中调用它:

import toPDF from "./pdfConverter.js";

toPDF(myBase64array)
.then(pdf => {
  console.log("pdf ", pdf);
});

看看这是否有助于你实现目标谢谢你的链接,我在看到你的评论之前找到了一个解决方案;)酷,你可能想向作者扔一颗github明星来表达你的爱。到目前为止,他只有一颗星,特别是他三天前才出版的。正好赶上你的需要:D。我相信他不会介意你的鼓励。哈哈!完美的计时这里什么都不会发生mergeImage(){RNImageToPdf.createPDFbyImages({ImagePath:this.state.myarr,name:“PDF_name”})。然后(PDF=>{console.log(“PDF”,PDF);})。catch(err=>console.log(“error catch search:,err));}有人查看它吗?