Print movieclip - html5

Hi, I’m converting a flash game to html5 using openfl. Is there a way to print (send to a real printer) a Movieclip on stage?
Thanks

Are you using flash.printing.PrintJob currently?

I see a window.print () in HTML5, to print the current page. I think it would be necessary to open a new page, then to call print from there, or tell the user to print it themselves.

We can save PNG and JPEG images, currently, if saving an image is preferable to printing.

With a little work, perhaps it would be possible to combine techniques for HTML5 print layout (like https://www.smashingmagazine.com/2011/11/how-to-set-up-a-print-style-sheet/ and http://stackoverflow.com/questions/9852190/js-window-open-then-print) with the AS3 PrintJob API (http://stackoverflow.com/questions/1422259/as3-using-printjob-to-print-a-movieclip)

I’m targeting html5, so I can’t use flash.printing.PrintJob
I will see the links you post.
Thanks for your help.

With this code I could print a Movieclip. It works on Chrome but not in IE.
Do you know how to make this code work on IE?

#if html5
var buffer:ArrayBuffer = byteArray;
var blob:Blob = new Blob ([ buffer ], { type: “image/jpeg” });
var myWindow = untyped window.open(’’, ‘’, ‘width=500,height=500’);

var image = new Image();
image.src = URL.createObjectURL(blob);
myWindow.document.body.appendChild(image);

// have to put a delay to work (don’t know why)
var timer:Timer = new Timer(500, 1);
timer.addEventListener(TimerEvent.TIMER, function(e:TimerEvent):Void{
myWindow.focus();
myWindow.print();
});

timer.start();

Thanks

I’ve added an initial commit here:

I would appreciate your help in refining and improving this code. Initially (so long as I respond to a mouse down event, so that the browser does not block the request) it appears to be working, but I am sure there are multiple things (such as pageWidth, paperHeight and other unimplemented properties) which may be improved.

Similarly, we may want to test the page break logic more, and may want to use the “bitmap” setting to determine whether we super-sample the generated PNG, for higher fidelity while printing (export at a higher resolution, and shrink with CSS, so the printed page looks better, closer to 300dpi instead of 72)