eKoopmans / html2pdf.js

Client-side HTML-to-PDF rendering using pure JS.
MIT License
4.13k stars 1.39k forks source link

Generating PDF functionality doesn't work in Firefox (Safari) #507

Open AndriiRafalskyi opened 2 years ago

AndriiRafalskyi commented 2 years ago

I have "Save as PDF" on my frontend that uses html2pdf library to generate PDF from a React component.

My downloadPDF function looks like:

downloadPdf = (io) => {
        const options = {
            margin: 15,
            pagebreak: { avoid: '.break' },
            html2canvas: {
                scrollX: 0,
                scrollY: 0,
                scale: 2,
                letterRendering: true,
                ignoreElements: (element) => {
                    return element.tagName === 'BUTTON';
                }
            },
            jsPDF: {
                format: 'a2',
                orientation: 'portrait',
                unit: 'pt'
            }
        };

        this.setState({
            isLoading: true
        });

        html2pdf()
        .from(document.querySelector('.review-order-wrapper').innerHTML)
        .set(options)
        .save(`IO#${io}`)
        .then(() => this.setState({
            isLoading: false
        }));
    }

IO - some identifier (number) that is used to make up a file name. In Chrome and Edge everything is ok, but in Firefox (Safari) loading is infinite because .then() is never called and promise is never resolved.

document.querySelector('.review-order-wrapper').innerHTML is a usual html code

CC: @eKoopmans

git-reset--hard commented 1 year ago

Same issue

smisyuk4 commented 11 months ago

i am too