> Impressive!!!
Thanks :)
> Instead of the event I use callback style for now. The first argument gets
> the rendering context and the second argument is an object, that contains
> additional data.
>
> What does the print engine pass as the second argument?
>
> You shouldn't really need to use a second argument to carry around data for
> rendering. You can use a JS closure for that.
The second argument might look like this:
sndArgument = {
DPI: 200,
preview: false
};
It's intended to expose more print related information to the user.
> -- Is there a way to figure out the DPI resolution of the printout in C++?
>
> Yes, cairo_surface_get_fallback_resolution. You should add a wrapper to
> gfxContext to return it.
cairo_surface_get_fallback_resolution requires a cairo surface. Therefore I've
added a new `GetFallbackResolution` on the gfxASurface class.
Calling this function always return 300 by 300 pixels per inch. That's
independent of the print quality I set on my printer or wether I choose "Save
as PDF". The cairo documentation states
"This function returns the previous fallback resolution set by
cairo_surface_set_fallback_resolution(), or default fallback resolution if
never set."
Therefore I'm wondering if this is really related to the actual DPI of the
printer or just picks up some default value.
> -- How can one figure out the actual size of the canvas when printed to
> paper? I guess I can get some size-information from the CanvasFrame, but is
> that the actual/resulting size on paper?
>
> When printing, CSS units are rendered as physical units if the zoom factor is
> 100%. Each CSS px is 1/96 of an inch. Changing the zoom factor will change
> this of course.
>
> What do you need this for?
Imagine you print a canvas that contains some computed image data. If you know
the actual size of the canvas on the paper and the DPI resolution, one can
compute what dimension the image data has to be in order to look good on the
printout (e.g. if you don't compute a high enough resolution, the user will see
pixels in the printout).
Even in the case that the DPI of the printer might not be determinable, using
300DPI as the default value and multiply it by the size would still give a good
guess what the image data size has to be.
> >> In addition, there need to be a way to scratch an element onto an entire
> >> print page. E.g. a canvas should take up the entire page if the margin is
> >> set to zero. Can that be done using something similar to
> >> style="width:100%;height:100%"?
> >
> > Yes.
>
> Rob, what was your idea to use for this?
>
> Easiest way is probably to make the canvas position:absolute; top:0; left:0;
> width:100%; height:100%. Of course you'll need to zero out margins as well.
Using "position: relative" works like expected and scales the canvas to fit on
a page each.
I've played around with some CSS units (code in [1], resulting PDF in [2]). The
"mm"-size used for the ctx.font has nothing to do with the actual printout
size. This feels consistent to me and therefore right, as it renders to the
same size/way the DOM canvas does, but it can confuse people that expect to get
really 5mm on the printout.
What's the way it should be?
Julian
[1]: https://gist.github.com/2267257
[2]: http://n.ethz.ch/~jviereck/drop/Preview_print_test_page.pdf
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout