[whatwg] Proposal: HTMLCanvasElement.printCallback API

Julian Viereck julian.viereck at googlemail.com
Thu Feb 7 00:38:09 PST 2013

On 1/28/13 6:25 AM, Elliott Sprehn wrote:
> 1) I feel like this should probably be an event. I don't know why 
> we're inventing new callback facilities everywhere.
> canvas.onprintcanvas = function(e) { e.printState ... }

Not sure I get what you're trying to say. Do you want the function to be 
an event, such that you can do

   canvas.addEventListener('printCallback', function(e) { ...} )

or just rename the `canvas.printCallback` to `canvas.onprintcallback`?

A event might be dispatched to multiple listeners. In the scenario with 
the print callback it makes only sense to have one function that defines 
the look of the canvas during printing. Therefore I've choosen to not 
use the event-listener pattern but instead a single callback function.

> 2) What does "send the canvas' content without rasterization to the 
> printer" mean? How are blending and overlapping images handled? Your 
> current description makes it sound like if I did two drawImage() calls 
> it would make my printer print the images on top of each other.
The drawing is done exactly the same as you expect it to show up on the 
screen including blending and overlapping.

Here is an example using the canvas.printCallback API. It draws shapes 
over each other:
- test html page: 
- output: 

Is this clear or does it need more clearification?

Very best,


More information about the whatwg mailing list