OnedocLabs / react-print-pdf

Build and generate PDF using React 📄 UI kit for PDFs and print documents. Simple, reusable components and templates to create great invoices, docs, brochures. Use your favorite front-end framework React to build your next PDF.
https://docs.fileforge.com/react-print/welcome/getting-started
Apache License 2.0
2.31k stars 87 forks source link

Runtime error #3

Closed oferitz closed 9 months ago

oferitz commented 9 months ago

Trying to use it as simple as:

const MyDocument = () => {
  return (
    <div>
      <PageTop>
        <span>Top</span>
      </PageTop>
      <div>Content</div>
      <PageBottom>
        <div className="text-gray-400 text-sm">Bottom</div>
      </PageBottom>
      <PageBreak />
      <span>New page</span>
    </div>
  )
}

const App = () => {
  return <MyDocument />
}

And getting:


 @onedoc_react-print.js?v=61065e32:17695 Uncaught (in promise) TypeError: os.platform is not a function
    at node_modules/fast-glob/out/utils/path.js (@onedoc_react-print.js?v=61065e32:17695:34)
    at __require2 (chunk-WGAPYIUP.js?v=61065e32:19:50)
    at node_modules/fast-glob/out/utils/index.js (@onedoc_react-print.js?v=61065e32:20835:17)
    at __require2 (chunk-WGAPYIUP.js?v=61065e32:19:50)
    at node_modules/fast-glob/out/managers/tasks.js (@onedoc_react-print.js?v=61065e32:20850:18)
    at __require2 (chunk-WGAPYIUP.js?v=61065e32:19:50)
    at node_modules/fast-glob/out/index.js (@onedoc_react-print.js?v=61065e32:22736:23)
    at __require2 (chunk-WGAPYIUP.js?v=61065e32:19:50)
    at node_modules/tailwindcss/lib/lib/content.js (@onedoc_react-print.js?v=61065e32:22979:46)
    at __require2 (chunk-WGAPYIUP.js?v=61065e32:19:50)

    Version: 0.1.108
    macOS: 14.3.1
Titou325 commented 9 months ago

Hey @oferitz!

Are you trying to use the document components directly inside your app? Documents should be compiled to HTML and can then be converted by using the compile function.

I am not able to reproduce as-is, let me know if you have a sample repo at hand. You can also check out the example setup at https://github.com/OnedocLabs/dev-local

Have a nice day!

oferitz commented 9 months ago

@Titou325, thanks. You are correct; I missed that you need to compile first. Closing.