General discussion

Locked

Force image smaller with onbeforeprint

By bigbillh ·
I have been at this awhile, and I haven't been able to get onbeforeprint to make a jpg go to 384x288 from 640x480. When printing, the image takes up a third of the page which forces the text down to a 2nd and sometimes 3rd page. This is fine on screen, but that size isn't needed when printed (just a little overkill). I just don't have enough experience with JS to find the key(s) to get the image size down the way I want it. I have over 200 jpg's that are used for the screen and print so I don'twant to have multiple sizes of the same pictures, it is bad enough I had to do that for the thumbnails. I don't really need anymore. If I could even get a suggestion as to the right direction to head toward it would be a big help.

Thanks

This conversation is currently closed to new comments.

17 total posts (Page 1 of 2)   01 | 02   Next
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Force image smaller with onbeforeprint

by Ann777 In reply to Force image smaller with ...

You might want to lookup Microsoft Knowledgebase article # Q294901...

It has two samples of java coding that might work for you... depending on what you want to do.

I don't think that java will resize the image, but you can set it to printa single area or a single page.

Collapse -

Force image smaller with onbeforeprint

by Ann777 In reply to Force image smaller with ...

To re-size jpeg's, i think you'll need another program... such as Paint Shop Pro.

Collapse -

Force image smaller with onbeforeprint

by bigbillh In reply to Force image smaller with ...

I can remove images and items from a page with onbeforeprint and I can force an image 640x480 picture smaller with:
<IMG height=288 alt="Any Picture" src="picture.jpg" width =384 border=3 > but that makes it that size all the time. What I'm trying to do is remove the items that I don't want printed, and reduce the size of the picture using the "onbeforeprint" event of IE5.0 and above. Sorry if I wasn't clear in my first posting. Thanks for the response.

Collapse -

Force image smaller with onbeforeprint

by bigbillh In reply to Force image smaller with ...

Point value changed by question poster.

Collapse -

Force image smaller with onbeforeprint

by bigbillh In reply to Force image smaller with ...

Point value changed by question poster.

Collapse -

Force image smaller with onbeforeprint

by bigbillh In reply to Force image smaller with ...

Oh Yeah,
Yes, you are right I could change the size with Paint Shop or other picture program. But I don't want to change the size all the time, just when it is bing printed. The only place I have seen ANY type of article on the window.onbeforeprintevent is wsabstract.com but it only covered removing elements and backgrounds and then reloading the page.

Oh well, back to the drawing board.

Collapse -

Force image smaller with onbeforeprint

by bigbillh In reply to Force image smaller with ...

Anyone else now?

Collapse -

Force image smaller with onbeforeprint

by bigbillh In reply to Force image smaller with ...

Point value changed by question poster.

Collapse -

Force image smaller with onbeforeprint

by bigbillh In reply to Force image smaller with ...

Still? All I'm asking for it an idea of how to do this. All the things I have tried didn't work. I thought someone that is more experienced with js would be able to just whip this out without a lot of trouble. Thanks anyway.

Collapse -

Force image smaller with onbeforeprint

by sbkwi In reply to Force image smaller with ...

There is a very simple solution if you if you don't mind using dynamic html and php and your web server executes php pages. Example:

<HTML>
<BODY>

<?php if ($layout == "print") { ?>
<IMG height=288 alt="Any Picture" src="picture.jpg" width =384 border=3 >
<h3>Print Layout</h3>
<?php } else { ?>
<IMG height=480 alt="Any Picture" src="picture.jpg" width =480 border=3 >
<h3>Normal Layout</h3>
<?php }?>

</BODY>
</HTML>

To see how it works create a file named printdemo.php3 containing everything from "<HTML>" to "</HTML>" above. Transfer this file to your web server. Using the URL "http://www.my_server.com/printdemo.php3" you get the 640x480 picture, and the smaller picture using "http://www.my_server.com/printdemo.php3?layout=print".

So when you create your own page(s), use the following pattern:

<?php if ($layout == "print") { ?>
....
content when printed
....
<?php } else { ?>
....
normal content
....
<?php }?>

Put a link like "<a href=printdemo.php3?layout=print>Printer frienly format</a>" somewhere in the page.

Note that the file extension for php pages may vary. Ask your service provider for the correct value (".php3" works with mine).

The big advantage of using php is that it works with any browser and is very easy to learn and use.

Back to Web Development Forum
17 total posts (Page 1 of 2)   01 | 02   Next

Related Discussions

Related Forums