[whatwg] Proposal: HTMLCanvasElement.printCallback API

Elliott Sprehn esprehn at gmail.com
Thu Feb 7 10:47:22 PST 2013


On Thu, Feb 7, 2013 at 12:38 AM, Julian Viereck <
julian.viereck at googlemail.com> wrote:

> 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`?
>
>
It should be an event. There are legitimate reasons for multiple listeners,
for instance I might have a listener on body that adds watermarks and a
listener on the canvas that does just the drawing.

Not using events also limits my ability to globally hook the facility. For
instance I'd like to do:

$(document).printcanvas(function(e) {
  if (drawingFunctions[e.target.id])
    drawingFunctions[e.target.id](e.target);
});

I also still don't understand why this is specific to canvas. Why can't I
do the same thing for <img> ? Cocoa lets me hook NSView drawRect: and draw
whatever I want at print time.


>  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: https://bug745025.bugzilla.**
> mozilla.org/attachment.cgi?id=**625810<https://bug745025.bugzilla.mozilla.org/attachment.cgi?id=625810>
> - output: https://docs.google.com/file/**d/**0B4VOqqwjYRMLS05JNVZpZWt3MG8/
> **edit?usp=sharing<https://docs.google.com/file/d/0B4VOqqwjYRMLS05JNVZpZWt3MG8/edit?usp=sharing>
>
> Is this clear or does it need more clearification?
>

Ah, you don't mean sent to the physical printer without rasterization then,
you mean it's just spooled to the printer driver which may rasterize it to
send it to the device. That seems to run into operating system and
implementation limitations. I don't know if the spec should require that
behavior.

- E



More information about the whatwg mailing list