Precise printing from Javascript?

N

Noop

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.
 
E

Erwin Moller

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
 
D

Dr J R Stockton

In comp.lang.javascript message <e7872ddb-d54c-48fc-83da-38d89887a9ce@i2
8g2000yqa.googlegroups.com>, Fri, 23 Jul 2010 05:47:17, Noop
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top