typeError while loading image in pdf.
TypeError: ctx.embedImage is not a function
couldn't show an image on the pdf file.
<Image
style={{ width: 80, backgroundColor: "red" }}
fixed
cache={false}
src={mainLogo+"?rnd="+Math.random()}
/>
mainLogo: full url of image (string).
An error shown on the console but the image fully loaded on network tab.
Uncaught (in promise) TypeError: ctx.embedImage is not a function
at drawImage (index.es.js:1221:1)
at renderImage (index.es.js:1237:1)
at renderNode (index.es.js:2021:1)
at renderChild (index.es.js:2000:1)
at Array.forEach (<anonymous>)
at renderChildren (index.es.js:2003:1)
at renderNode (index.es.js:2022:1)
at renderChild (index.es.js:2000:1)
at Array.forEach (<anonymous>)
at renderChildren (index.es.js:2003:1)
at renderNode (index.es.js:2022:1)
at index.es.js:2106:1
at Array.forEach (<anonymous>)
at render (index.es.js:2105:1)
at _callee$ (index.js:34:1)
at tryCatch (regeneratorRuntime.js:86:1)
at Generator._invoke (regeneratorRuntime.js:66:1)
at Generator.next (regeneratorRuntime.js:117:1)
at asyncGeneratorStep (asyncToGenerator.js:3:1)
at _next (asyncToGenerator.js:25:1)
i tried to pass the image a 'blob' and 'base64 string' and same error occurred. any solution ?
same error here on 3.0.0
same here. I cannot upgrade to 3.0.0 because of this issue
same here
This is due to using override for "@react-pdf/font": "2.2.1", "@react-pdf/pdfkit": "2.1.0" Removing these will fix this issue. But webpack v4 will give this issue #2015 Fix It by upgrading react scripts to v5
This is due to using override for "@react-pdf/font": "2.2.1", "@react-pdf/pdfkit": "2.1.0" Removing these will fix this issue. But webpack v4 will give this issue #2015 Fix It by upgrading react scripts to v5
Removed override and upgraded to v5. Also dealt with necessary polyfill webpack config and still got the same "ctx.embedImage is not a function" error
My dependencies:
"dependencies": {
"@react-pdf/renderer": "^3.0.0",
"assert": "^2.0.0",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"process": "^0.11.10",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.3.0",
"react-scripts": "^5.0.1",
"stream-browserify": "^3.0.0",
"util": "^0.12.5"
},
"devDependencies": {
"react-app-rewired": "^2.2.1"
}
EDIT: Using @react-pdf/renderer v2 fixes it but it's obviously not the ideal solution for me. So if anyone knows how to fix it for v3 let us know!
Does anyone have a fix for this using webpack 4?
I am facing this problem too. "@react-pdf/renderer": "^3.0.0". Image is rendering in another component just fine but throws error in one component. "ctx.embedImage is not a function".
duplicate of https://github.com/diegomura/react-pdf/issues/2089