Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fit to page printing

Status
Not open for further replies.

Bamarama

Programmer
Dec 29, 2006
49
US
I am not sure if this is the proper forum to ask this. If not, please direct me to the right place.

I have made a printer friendly page for music that I write. It shows the song name, key, and the body of the music that contains chords and stuff.

I have added a print button, that brings up a user interface for print options. This is normal.

What I want it to do however, is fit the song body/lyrics to one page upon printing. Some songs print more than one page.

I tried adjusting the font, but that really didn't work.

Is there a way to do this? or is there a way to do a character count, and let the font be determined by the count?

Any ideas would be appreciated.


TIA

Jeff
 
Here's the problem.
Your screen resolution is dots per inch.
Your printed page is 8.5 inches by 11 inches.
How many dots are in an inch?

Well at 800x600 it would be different than 1024x768 and different than 1280X104 etc.

That would mean that 100 characters will be a different size in each of those scenarios as well.

I think that you are going to have to use a couple of div tags and some javascript to do it.

Create a layer with the first div tag and set the height and width to absolute values.
Then add a second layer on top. Put your content in the second layer.
Then using javascript get the size of the second layer and compare that to the size of the first layer.

If layer1.height > layer2.height then you know that everything fits on the page.

If layer1.height < layer2.height then you need to adjust your content size.

You will have to define what font you are using as well.

So let's say that arial 10 pt text fills an 11 inch page of paper when the screen resolution is 1024X 768 and layer1 is 700 pixels long.

When you put your content on layer 2 at 10pt Arial it turns out to be 900 pixels long. you will need to use javascript again to reduce the font size to

(10 * (700/900)) pt

It's not going to be an easy thing for you to do.

To build may have to be the slow laborious task of years. To destroy can simply be the thoughtless act of a single day.
 
This is probably better asked in forum215 and using a print stylesheet.



Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top