table a4

S

Spiff

Easy problem:
I want to draw a 3x3 table on a a4 paper (and then print it). The table must
occupy all the paper, all cells must have the same size.
I _don't_ want to specify table cell size explicitly but I would like it to
be done automatically.

A bit more difficult:
Same as before, but I want a word centered in each cell.

I know that with CSS you can specify paper size but I don't know if I can
solve my problem.
Thanks in advance, Gianmaria
 
S

Spiff

I want to draw a 3x3 table on a a4 paper (and then print it). The table
Put up a PDF file.

Do you know if what I asked is impossibile with html and css?
Thanks, S.
 
B

Beauregard T. Shagnasty

Spiff said:
Easy problem:

I suppose.
I want to draw a 3x3 table on a a4 paper (and then print it). The
table must occupy all the paper, all cells must have the same size.
I _don't_ want to specify table cell size explicitly but I would
like it to be done automatically.

What is the URL of your sample?

Have you set the table width to 100% ? And the three columns to 33%?

Are you using a print stylesheet?
A bit more difficult: Same as before, but I want a word centered in
each cell.

Do that the same as you would for the screen media.

Hmm, is this a data table, or are you using tables for layout?
I know that with CSS you can specify paper size but I don't know if
I can solve my problem. Thanks in advance, Gianmaria

I've never found the need to specify paper size.
 
S

Spiff

I want to draw a 3x3 table on a a4 paper (and then print it). The
table must occupy all the paper, all cells must have the same size.[...]

What is the URL of your sample?

Sorry, I don't have any url.
Have you set the table width to 100% ? And the three columns to 33%?

Yes. This is my stylesheet code:

table { border-collapse:collapse; width: 100%; }
tr { width: 33%; text-align: center;}
td { border:1px solid black;}

and my html code

<table>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
<td>row 1, cell 3</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
<td>row 2, cell 3</td>
</tr>
<tr>
<td>row 3, cell 1</td>
<td>row 3, cell 2</td>
<td>row 3, cell 3</td>
</tr>

My code partially works. The table split up the page in 3x3 cells. The table
occupy all the horizontal size of the page, but not the vertical size
(that's why I think I need to specify the size of the page!).
Are you using a print stylesheet?

Uhm.... I only intend to print the page on the printer, so the only
stylesheet I'm using is the above one.
Hmm, is this a data table, or are you using tables for layout?

ahem... I don't know. My problem is that I have 9 object (words, imagine
etc) that I simply want to equally distribuite on a "a4" paper. So is this a
data table or a table for layout?
I've never found the need to specify paper size.

If what I intend to do is possible with html than I think I need to specify
the paper size.
Thanks a lot, Gianmaria
 
R

rf

Spiff said:
Yes. This is my stylesheet code:

table { border-collapse:collapse; width: 100%; }
tr { width: 33%; text-align: center;}
td { border:1px solid black;}

<sigh/>

table {width: 100%; height: 100%;}

td {width: 33%; height: 33%; text-align: center;}



There is no point in specifying a width for a td element.

Why did you not simply *try* specifying height, rather than just talking
about it?
If what I intend to do is possible with html than I think I need to specify
the paper size.

No you don't. The piece of paper is the viewport, just like a screen is the
vieport.
 
S

Spiff

table { border-collapse:collapse; width: 100%; }
<sigh/>

table {width: 100%; height: 100%;}
td {width: 33%; height: 33%; text-align: center;}

Thanks a lot for your reply.
I tried your code but I'm not able to make it works. This is the complete
html code I written.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<style>
table { width: 100%; height: 100%; border-collapse: collapse}
td { width: 33%; height:33%; text-align: center; border: 1px solid black}
</style>
<title>Table</title>
</head>
<body>
<table>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
<td>row 1, cell 3</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
<td>row 2, cell 3</td>
</tr>
<tr>
<td>row 3, cell 1</td>
<td>row 3, cell 2</td>
<td>row 3, cell 3</td>
</tr>

</table>
</body>
There is no point in specifying a width for a td element.

Yes, you're definitly right. Sorry for the stupid thing I wrote.
Why did you not simply *try* specifying height, rather than just talking
about it?

I'm sorry, I only read some css tutorial and try to solve my problem.
[..]I think I need to specify the paper size.

No you don't. The piece of paper is the viewport, just like a screen is
the
vieport.

Ok!
Thanks a lot for your help!
S.
 
P

Philip Ronan

Spiff said:
Thanks a lot for your reply.
I tried your code but I'm not able to make it works. This is the complete
html code I written.

I don't think specifying a "height" of 100% for a table will actually have
much effect unless the table is contained in a block element with a known
height. The height of your <body> element will default to "auto", not to the
size of an A4 sheet of paper.

You could try specifying the size in cm, like this:

table { width:100%; }
td { width:33%; height:8.5cm; text-align:center; border:1px solid black }

But HTML isn't really designed for this sort of thing. Someone suggested you
use a PDF file instead. I think you should follow that advice.

Phil
 
S

Spiff

Thanks for your msg.
You could try specifying the size in cm, like this:

table { width:100%; }
td { width:33%; height:8.5cm; text-align:center; border:1px solid black }

The problem is that if I need to make a different table I have to calculate
each time the height. But thank you anyway.
But HTML isn't really designed for this sort of thing. Someone suggested
you
use a PDF file instead. I think you should follow that advice.

Yes, I'm agree. I tought also to LaTeX, but HTML is the simplest one and I
wanted to be sure that was impossible with that.
AnywayA friend give me this solution that works almost perfectly (there are
some problem with margin). Here it is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it">
<head>
<style>
@media print
{
@page: {margin:0px}

body,html { width:20cm; height:28cm;}

table { width:100%; height:100%; border-collapse: collapse;}

td { width:33%; border: 1px solid black; text-align:center; }

}
</style>
<title>3x3 table in A4 table</title>
</head>
<body>
<table>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
<td>9</td>
</tr>
</tbody>
</table>
</object>
</body>
</html>
 
R

rf

Spiff said:
Thanks for your msg.

Hey people:

This is *not* rocket science.

http://users.bigpond.net.au/rf/printpage.htm

A minimal HTML page that prints a grid on the viewport. It does *not* matter
what the viewport is, a computer screen or a piece of paper or a telephone.
There are no nasty dimensions specified, not cm or inches or furlongs, just
the browser doing what it will do if you allow it to, that is fit the page
to the viewport.

http://users.bigpond.net.au/rf/printpage.jpg

A picture of above URL printed on a piece of A4 paper. Note that it uses the
entire viewport (except for a header and a footer for the URL and stuff).

If you don't want those margins then *change your browser settings* because
that is where they are specified, not in the HTML.

The exact same URL could be imported into, for instance, MS Word and it
would print exactly the same (except for the header/footer).

HTH
 
S

Steve Pugh

Hey people:

This is *not* rocket science.

http://users.bigpond.net.au/rf/printpage.htm

The key point that as far as I can see hasn't been
commented on so far is that the OP's page used a doctype
that triggers Standards mode whilst the example here
doesn't use a doctype and hence triggers Quirks mode.

In Standards mode height: 100% on a table won't do
what's wanted but in Quirks mode it will.

That's why the OP couldn't get this to work earlier.

And to the OP: why use XHTML 1.1 when IE doesn't
support it? Is this for an intranet that doesn't use
IE?

Steve
 
S

Spartanicus

rf said:
A minimal HTML page that prints a grid on the viewport. It does *not* matter
what the viewport is, a computer screen or a piece of paper or a telephone.

Only screens have viewport(s), print media are paged with rendering done
on a canvas.
 
R

rf

Steve said:
The key point that as far as I can see hasn't been
commented on so far is that the OP's page used a doctype
that triggers Standards mode whilst the example here
doesn't use a doctype and hence triggers Quirks mode.

Didn't spot that :-(
In Standards mode height: 100% on a table won't do
what's wanted but in Quirks mode it will.

So? My page *assumes* quirks mode, which both IE an Firefox accept. It is a
minimal page, after all :)
That's why the OP couldn't get this to work earlier.
And to the OP: why use XHTML 1.1 when IE doesn't
support it? Is this for an intranet that doesn't use
IE?

And for this exercise why not use a bloody pencil, or something like MS word
which *always* operates in quirks mode.

If I want to do something like this to a piece of paper I fire up an old
copy of word perfect and switch on "lable" mode :)
 
S

Spiff

The key point that as far as I can see hasn't been
commented on so far is that the OP's page used a doctype
that triggers Standards mode whilst the example here
doesn't use a doctype and hence triggers Quirks mode.
[....]

Sorry, what is "OP"?
Thanks, S.
 
S

Spiff

And to the OP: why use XHTML 1.1 when IE doesn't
support it? Is this for an intranet that doesn't use
IE?

And for this exercise why not use a bloody pencil, or something like MS
word
which *always* operates in quirks mode. [...]

I didn't use Microsoft word because I want generate the page through a
program and I don't know the Word .doc internal format.

Thanks, S.
 
K

Kris

[QUOTE=""Spiff said:
Put up a PDF file.

Do you know if what I asked is impossibile with html and css?[/QUOTE]

PDF was made for print, HTML and CSS are not (..not primarily).
 
S

Spiff

PDF was made for print, HTML and CSS are not (..not primarily).

Do you know if it's easy make the work I need with pdf files? Consider I
need to put unicode character in the page (japanese font).

Thanks, S.
 
D

Dylan Parry

Spiff said:
Do you know if it's easy make the work I need with pdf files? Consider I
need to put unicode character in the page (japanese font).

Have you got Word or some other word processing software? If so you can
create the document in that then use
http://www.cutepdf.com/Products/CutePDF/writer.asp to "print" the
document to a PDF file.

Just download http://www.cutepdf.com/download/CuteWriter.exe and
http://www.cutepdf.com/download/converter.exe then install the two. Then
it's just like printing a document normally -- you go to file > print
and select "cutePDF writer" as the printer and you will be asked what
you want to save the PDF document as. Easy peasy.

Of course, you could shell out a fortune for Acrobat or spend a few
weeks learning LaTeX :D
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top