Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to parse PDF document (line:104 col:8 offset=195965): No PDF header found #1646

Open
2 tasks done
pradeepgp0 opened this issue Jun 27, 2024 · 0 comments
Open
2 tasks done

Comments

@pradeepgp0
Copy link

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

  • My report includes a Short, Self Contained, Correct (Compilable) Example.
  • I have attached all PDFs, images, and other files needed to run my SSCCE.

Additional Notes

nothing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant