Can I make an HTML document be one page?

I am creating a document from HTML. Is there a way to get an HTML page to be one rendered as one print page for a long time?

I made most of the page with the <table> and <div> tags.

+7
html printing document
source share
7 answers

Not really, but you can use a print stylesheet:

 <link rel="stylesheet" type="text/css" media="print" href="print.css" /> 

To set font sizes, paddings, etc. for physical units such as "pt" (which should never be used in a screen style sheet), so that it becomes more or less an A4 page when displayed in a typical browser with typical fonts with the following wind. Nothing is guaranteed, but you can optimize the overall case.

In print, you don’t need to worry so much about font size settings or dpi settings, but you still can’t control the margins used by the browser, or the actual page size (US letter is less than A4), so leave a good amount of room for maneuver and test on the main browsers.

+9
source share

Not. You cannot control the user's zoom level, printer settings, paper size (does he use A4 paper in Europe or legal in the USA?) And all the other things that affect printer output using HTML.

The best you can do with HTML is to make a very simple “printable” page and keep the content short. In addition, you can create a PDF file that allows you to control how it is printed.

+7
source share

You can use CSS to style the page and set it to a specific height / width ... There is a good tutorial here .

+2
source share

Use PDF. You can force many things, such as font size, font type, and many other parameters, but any browser can decide what they care and use what they want, and thus violate your prerequisites or decisions. HTML is not (repeat after me: NOT) presentation language.

In many cases, it will work mainly, but nothing will happen.

+2
source share

No, but you can make it look smoother using a dedicated CSS file for print media, as suggested above.

Then you could, for example, at least prevent the spread of the table on more than 2 pages using "page-break-before: always;" .

And finally, you can also use "display: none;" for elements that are not needed, like advertising, navigation bars, etc., to keep the page itself shorter (short enough for one page, I hope).

No warranties.

+2
source share

Of course. You have several options:

  • Convert your page to a large image.
  • Convert your page to PDF.
  • Annoy all your users with a fixed-sized page that scrolls left and right because it is too wide and extremely difficult to transport information.
+1
source share

There is no way, because you could not know the type of printer or paper size during the rendering of HTML.

My only suggestion was to set the printer properties to scale the content so that it matches one page while printing. A.

0
source share

All Articles