jasonday / printThis

jQuery printing plugin; print specific elements on a page

Home Page:https://jasonday.github.io/printThis/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0

hoba-dafidi opened this issue · comments

Hello,
Thank you for your great effort developing this plugin.
Here is my print function:

function printResult() {
        $('.mainterminalreport').printThis({
            debug: true,
            printDelay: 15000,
            canvas: true
        });
    }

When I click the Print button, I get this error in my console.
Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0

This bug points here:
this.getContext('2d').drawImage($src[0], 0, 0);

What should I do to resolve this?

Canvas is a bit tricky, as the way printThis works is by copying over elements from the parent page to an iframe. My guess is that some key piece is not being copied into the iframe, creating your error.