react-native-pdf-lib
react-native-pdf-lib copied to clipboard
App crashes when modifying PDF
i'm getting this below error while trying to modify pdf.
ERROR TypeError: null is not an object (evaluating '_PDFLib.default.modifyPDF')
the error is produced when i call write() as shown in the below code snippet
PDFDocument
.modify(filePath)
.modifyPage(page1)
.write() // Returns a promise that resolves with the PDF's path
.then(path => {
console.log('PDF modified at: ' + path);
});
Could you provide a reproduction?
@AnasAlamin Please follow https://github.com/Hopding/react-native-pdf-lib/pull/80
i tried to provide an expo snack but unfortunately i couldn't, so let me just explain what i did to reproduce the issue. i'm basically picking a pdf file using "react-native-document-picker" and afrer getting the uri of the file i'm using it inside --->
PDFDocument
.modify(<PDF uri>)
.modifyPages(page1, page2)
.addPage(page3)
.write() // Returns a promise that resolves with the PDF's path
.then(path => {
console.log('PDF modified at: ' + path);
});
``
@AnasAlamin , document-picker will give you a URI beginning with file:// - this library does not work with that format, this is why you're getting an error.
Same issue, I try to fix that by https://github.com/Hopding/react-native-pdf-lib/pull/80 but it's not work
