Thanks fantasai :-), for the answer.

On 28.06.2012 08:16, fantasai wrote:
so for a 600px image you want printed at 600dpi, size your image as 1in, rather than as 600px, and it should print properly.

Well, it's not as simple as one image, it's a Javascript library that generates the output. The JS lib must get "4920px" as width from DOM/style APIs, and that must print as 21cm width in 600 dpi. That would solve it, and I *should* be able to set this via CSS rules.

In CSS, the ratio of px to cm is fixed

Well, that's the problem, then. It's inherently wrong.

Roc wrote an excellent, clear page about how it works in Mozilla:
http://robert.ocallahan.org/2007/02/units-patch-landed_07.html

Based on that, what I'd need to do is:

1. Set device resolution to 600 dpi (or 1200 dpi)
2. Set device pixels per CSS pixels to 1:1
3. Make sure the page is rendered with these settings, including the
   DOM "load" event.

It seems that 1. and 2. already have prefs, namely pref("layout.css.dpi", 600) and pref("layout.css.devPixelsPerPx", 1.0);, but they are ignored for print, print assumes a hardcoded 72dpi (on non-Windows), see <http://mxr.mozilla.org/comm-central/source/mozilla/gfx/src/nsDeviceContext.cpp#281>, but even if that were reasonable settings for most pages, I fail to see why I can't override it, at least in prefs, but better yet in the page via CSS rules.

As-is, the print output is more than 10 times less the resolution than the printer normally does, making the output completely unusable and useless, because I can't read anything.

Of course, I can hack the JS lib (OpenLayers for map rendering in my case), but it's a big lib and that's a major undertaking, as it's using images in a grid, SVG, canvas etc., and I'd have to teach it to use more than one output pixel for each CSS pixel. I can try, but...

I think this is a general problem in Mozilla. If I could just tell Mozilla to do the 3 things above, it would be solved cleanly for all pages.

Ben
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout

Reply via email to