From: Noop on
Hi all,

Suppose I have an image that is 400 by 300 pixels wide,
and I want to print that from Javascript such that no matter
what printer the user has, it will be 4 by 3 inches.
Is there a way to achieve such precise printing from
Javascript?

Thanks.
From: Erwin Moller on
Noop schreef:
> Hi all,
>
> Suppose I have an image that is 400 by 300 pixels wide,
> and I want to print that from Javascript such that no matter
> what printer the user has, it will be 4 by 3 inches.
> Is there a way to achieve such precise printing from
> Javascript?
>
> Thanks.

Hi,

As far as I know you can only call window.print()
which will present the print dialog to the client.
(Much the same as if the client did it him/herself.)

If you want control over the actual printing you should use a stylesheet
(@media print).

In the stylesheet for media print you can set sizes and the like very
nicely.

Regards,
Erwin Moller



--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
From: Dr J R Stockton on
In comp.lang.javascript message <e7872ddb-d54c-48fc-83da-38d89887a9ce(a)i2
8g2000yqa.googlegroups.com>, Fri, 23 Jul 2010 05:47:17, Noop
<questioner_x(a)yahoo.com> posted:

>Suppose I have an image that is 400 by 300 pixels wide,
>and I want to print that from Javascript such that no matter
>what printer the user has, it will be 4 by 3 inches.
>Is there a way to achieve such precise printing from
>Javascript?

From your backwardness, I suppose you to be on the wrong side of the
Atlantic. Or Pacific.

Put on the page a question "What % scale factor?", with the response box
preset to 100. The user can then print, measure, calculate the scale
factor, enter it, and print the right size - if you code in use of that
scale factor.

For real exactness, you should allow different scale factors for X & Y.

To save ink, arrange that the test printings are just of the border of
such a picture.


But your request, taken literally, is impossible, since there are
printers for which the widest paper is less than three inches wide.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (RFCs 5536/7)
Do not Mail News to me. Before a reply, quote with ">" or "> " (RFCs 5536/7)