TyForHelpDude
TyForHelpDude

Reputation: 5001

react-pdf, `Save in File`function throws exception

When button clicked reactPdf.render called and it throws the exception pic as below;

Expected Behaviour: Download a file name "example.pdf"

import ReactPDF from "@react-pdf/renderer";

    const GenerateBarcode = () => {
        ReactPDF.render(<p>Some Jsx Elements</p>, `${__dirname}/example.pdf`);
      };
    
      return (
        <div>
          <button
                                      className="btn btn-primary "
                                      type="button"
                                      onClick={GenerateBarcode}
                                    >
                                     Generator PDF
                                    </button>
    ...

enter image description here

Upvotes: 0

Views: 322

Answers (1)

sonkatamas
sonkatamas

Reputation: 621

solution: https://github.com/diegomura/react-pdf/issues/283#issuecomment-412233870 Basically you are using a node lib in the web environment as the comment states.

Upvotes: 2

Related Questions