Open pradeepgp0 opened 1 month ago
I need to read the pdf file which is present in react repo root directory which is under public folder, "sample.pdf"
const formUrl = '/sample.pdf'; const formPdfBytes = await fetch(formUrl).then(res => res.arrayBuffer()); const pdfBufferData = await PDFDocument.load(formPdfBytes); console.log('arrayBuffer', formPdfBytes.byteLength); console.log('pdfBuffer', pdfBufferData);
I am getting the below exception, the arrayBufffer
Failed to parse PDF document (line:104 col:8 offset=195965): No PDF header found
It should load the PDFDocument.load(pdfBytes)
By running the above code in react project .js file,,,,,,
^1.17.1
Browser, Other
nothing
What were you trying to do?
I need to read the pdf file which is present in react repo root directory which is under public folder, "sample.pdf"
How did you attempt to do it?
const formUrl = '/sample.pdf'; const formPdfBytes = await fetch(formUrl).then(res => res.arrayBuffer()); const pdfBufferData = await PDFDocument.load(formPdfBytes); console.log('arrayBuffer', formPdfBytes.byteLength); console.log('pdfBuffer', pdfBufferData);
What actually happened?
I am getting the below exception, the arrayBufffer
Failed to parse PDF document (line:104 col:8 offset=195965): No PDF header found
What did you expect to happen?
It should load the PDFDocument.load(pdfBytes)
How can we reproduce the issue?
By running the above code in react project .js file,,,,,,
Version
^1.17.1
What environment are you running pdf-lib in?
Browser, Other
Checklist
Additional Notes
nothing