react-native-pdf-lib icon indicating copy to clipboard operation
react-native-pdf-lib copied to clipboard

App crashes when modifying PDF

Open AnasAlamin opened this issue 3 years ago • 5 comments

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);
   });

AnasAlamin avatar Nov 05 '21 12:11 AnasAlamin

Could you provide a reproduction?

thekevinbrown avatar Nov 08 '21 00:11 thekevinbrown

@AnasAlamin Please follow https://github.com/Hopding/react-native-pdf-lib/pull/80

vertiPranav avatar Nov 10 '21 07:11 vertiPranav

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 avatar Nov 10 '21 09:11 AnasAlamin

@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.

Shogobg avatar Jun 21 '22 15:06 Shogobg

Same issue, I try to fix that by https://github.com/Hopding/react-native-pdf-lib/pull/80 but it's not work Screenshot 2022-12-28 at 10 04 27

dungpasoftware avatar Dec 28 '22 03:12 dungpasoftware