Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

455
Views
PDF Generation in React feels impossible

This topic seems to be largely elusive in terms of finding solutions. I'm working on a project in which a test is taken and the desired goal is a PDF is generated and is both downloadable and emailed to the test taker. Please note: I understand React a decent amount, but I would consider myself still probably a junior developer. I don't know the ins and outs of troubleshooting a lot of things.

react-pdf seems to be the top solution, but I cannot for the life of me get it to behave in the way it's said to. Primarily, whenever I use <PDFDownloadLink>,

<PDFDownloadLink document={<Document><Page><Text>Test</Text></Page></Document>}>
          {({ blob, url, loading, error }) =>loading ? "Loading document..." : "Download Pdf"}
</PDFDownloadLink>

I get

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

I am able to get <PDFViewer> to work, but that's not a needed functionality.

ReactPDF.render(<Document>, 'filename.pdf') is also supposed to create a download and it's literally from their website that that's the correct implementation, but I get:

Uncaught Error: render is a Node specific API. You're either using this method in a browser, or your bundler is not loading react-pdf from the appropriate web build.

Which I understand, but don't know enough to know what to do instead, and their website (as far as I can tell) doesn't really document HOW to use that, beyond just that it's what to use. I just straight up do not know enough.

HERE'S THE OTHER PROBLEM:

Every time I install react-pdf, I have to add the --legacy-peer-deps flag or I get the "Could not resolve dependency" error. On top of that, even if I use that flag, if I have to install any other package after that, I get a "Could not resolve dependency" error FOR react-pdf. I have to uninstall it, install the other package, and then re-install react-pdf with the same legacy flag. I don't know what the right solution is here but having to deal with that error repeatedly is getting very old.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!