diegomura / react-pdf

📄 Create PDF files using React
https://react-pdf.org
MIT License
14.41k stars 1.14k forks source link

PDFDownloadLink does not create href in the Download button #2634

Open vikasdinavahi opened 4 months ago

vikasdinavahi commented 4 months ago

My code works like charm in the dev box, but after deploying it to the prod box, I see a "TypeError: a is not a function", Not sure what this means and need help. Attached the error image. using "@react-pdf/renderer": "^3.3.4", and in "resolutions": { "@react-pdf/layout": "3.6.2", "@react-pdf/pdfkit": "3.0.2", "@react-pdf/image": "2.2.1" }, I am doing this. Component:

import { PDFDownloadLink, Document,View, Text, Page } from '@react-pdf/renderer'; <Document> <Page> <View> <Text>test doc</Text> </View> </Page> </Document>

PDFDownloadLink in another component: <PDFDownloadLink document={} fileName="somename.pdf"> {({ blob, url, loading, error }) => loading ? 'Loading document...' : 'Download now!' }

vikasdinavahi commented 4 months ago

I removed the versions under resolutions(as I am using Yarn) and reinstalled the react-pdf and it is working in my dev box. Will update after it is deployed with actual code.

PowderKegs98 commented 4 months ago

I am also facing similar issue. Seeing the error TypeError: s is not a function whenever I click on the PDF download button in my application. And the PDF is not getting downloaded.

I am using @react-pdf/renderer 2.3.0. This is how it is in my package-lock.json:

"@react-pdf/renderer": {
      "version": "2.3.0",
      "resolved": "https://....",
      "integrity": "sha......",
      "requires": {
        "@babel/runtime": "^7.16.4",
        "@react-pdf/font": "^2.2.1",
        "@react-pdf/layout": "^3.1.2",
        "@react-pdf/pdfkit": "^2.4.0",
        "@react-pdf/primitives": "^3.0.0",
        "@react-pdf/render": "^3.2.0",
        "@react-pdf/types": "^2.1.0",
        "blob-stream": "^0.1.3",
        "queue": "^6.0.1",
        "react-reconciler": "^0.23.0",
        "scheduler": "^0.17.0"
}

Previously it is pulling the versions 2.4.2 and 3.4.1 for @react-pdf/font and @react-pdf/render respectively. And it was working fine.

When I updated the package-lock.json file last week, it pulled versions 2.4.4 and 3.4.3 for font and render respectively. After this, I am seeing the above-mentioned issue. In my case also the href is not getting created in the download button.

I did not declare any resolutions or overrides for @react-pdf/renderer in my package.json file. I only have the following: "@react-pdf/renderer": "^2.0.21"

vikasdinavahi commented 4 months ago

Well, it worked for me after I updated the packages. Do one thing re install the pdf version again and see if same is getting updated in your lock file.

vakkiee commented 3 months ago

It's working fine on Mac OS, but not on Windows OS.

"dependencies": {
    "@react-pdf/renderer": "^3.4.1",
const blob = await pdf(<MyDocument />).toBlob();
    const url = URL.createObjectURL(blob);
<PDFDownloadLink document={<MyDocument />} fileName={fileName}>
            PDF        
        </PDFDownloadLink>