react-to-pdf icon indicating copy to clipboard operation
react-to-pdf copied to clipboard

Error: addImage does not support files of type 'UNKNOWN', please ensure that a plugin for 'UNKNOWN' support is added.

Open ShaniaKC opened this issue 1 year ago • 8 comments

Hello, First, thank you for the package!

I encountered this error : "Error: addImage does not support files of type 'UNKNOWN', please ensure that a plugin for 'UNKNOWN' support is added" while using the package today, It started before I made any changes to my code,( was working before ).

I'm using the generatePDF function like so generatePDF(editorWrapperRef, { filename: "page.pdf", overrides: {}, });

Stack Trace [Error] Unhandled Promise Rejection: Error: addImage does not support files of type 'UNKNOWN', please ensure that a plugin for 'UNKNOWN' support is added. P2 (react-to-pdf.js:3496:200) (anonymous function) (react-to-pdf.js:3486) convert (react-to-pdf.js:8660) (anonymous function) (react-to-pdf.js:8719)

ShaniaKC avatar Aug 12 '24 21:08 ShaniaKC

can you provide the part of the code where you did the implementation of the PdfToReact hook

chendjou237 avatar Sep 04 '24 13:09 chendjou237

Having the same problem here const contentRef = useRef<HTMLDivElement>(null); useImperativeHandle(ref, () => ({ print: () => {}, download: () => generatePDF(contentRef, { filename: "pdf.pdf", method: 'save' }), }));

sidahmedabdelillah avatar Dec 29 '24 12:12 sidahmedabdelillah

I've received a Sentry event with this error but haven't been able to reproduce myself. The user who encountered it was on Safari 16.6.1. I've tried with Safari 18.2 and that worked fine.

eirikur-nc avatar Jan 07 '25 19:01 eirikur-nc

Perhaps related to https://github.com/parallax/jsPDF/issues/3692

eirikur-nc avatar Jan 07 '25 20:01 eirikur-nc

I also encountered the same problem

gougebiegou42 avatar May 12 '25 09:05 gougebiegou42

this worked for me -

const { toPDF, targetRef } = usePDF({ filename: "invoice.pdf", overrides: { canvas: { scale: 2, imageTimeout: 15000, }, }, });

vishal30982 avatar May 20 '25 16:05 vishal30982

This error occurs when you set the element's width to more than 793px.

Rajib8926 avatar Jun 14 '25 19:06 Rajib8926

I eventually did it from scratch by using jsPDF and dom-to-image. I am not having any errors now. Also now I have more control over styling and layout.

vishal30982 avatar Jun 24 '25 16:06 vishal30982