Open Deepak-147 opened 7 months ago
Unable to create the pdf from the image
import { createPdf } from 'react-native-images-to-pdf'; import RNFS from 'react-native-fs'; const DIR_LOC = RNFS.DocumentDirectory + "/myFolder/" const options = { pages: [ { imagePath: DIR_LOC + "xxx.jpg" }], // File exists at this location outputPath: DIR_LOC + "file.pdf" }; createPdf(options) .then((path) => console.log(PDF created successfully: ${path})) .catch((error) => console.log(Failed to create PDF: ${error}) );
npx react-native info output:
npx react-native info
System: OS: macOS 14.2.1 CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz Memory: 85.68 MB / 16.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 18.19.0 path: ~/.nvm/versions/node/v18.19.0/bin/node Yarn: Not Found npm: version: 7.15.1 path: ~/Personal/Work/Projects/Mobility/Nexus/Nexus/MobileTemplate/node_modules/.bin/npm Watchman: version: 2023.09.25.00 path: /usr/local/bin/watchman Managers: CocoaPods: version: 1.12.1 path: /usr/local/bin/pod SDKs: iOS SDK: Platforms: - DriverKit 23.2 - iOS 17.2 - macOS 14.2 - tvOS 17.2 - visionOS 1.0 - watchOS 10.2 Android SDK: Not Found IDEs: Android Studio: 2022.3 AI-223.8836.35.2231.10406996 Xcode: version: 15.2/15C500b path: /usr/bin/xcodebuild Languages: Java: version: 11.0.20 path: /usr/bin/javac Ruby: version: 2.6.10 path: /usr/bin/ruby npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.73.2 wanted: 0.73.2 react-native-macos: Not Found npmGlobalPackages: "*react-native*": Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: true newArchEnabled: false
library version: 0.2.1
iOS: 17.3 Device: iPhone XR
pass the base64 data into imagePath instead of the path and it will work. Format here: https://github.com/Canciller/react-native-images-to-pdf?tab=readme-ov-file#valid-imagepath
Summary
Unable to create the pdf from the image
Steps to reproduce
Environment info
npx react-native info
output:library version: 0.2.1
iOS: 17.3 Device: iPhone XR