Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Printing HTML pages

Posted on 2001-08-16
8
324 Views
Last Modified: 2012-06-27
Is it possible to add something to an HTML document to force browser to brake this document into physical pages the way I would like to, e.g. specify where physical page should start and end?
0
Comment
Question by:davdonin
8 Comments
 
LVL 2

Author Comment

by:davdonin
ID: 6392753
By saying "physical pages" I mean when the document is printed on a printer.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6392797
I IE only you can use this in the head:

<style>
   .breakhere {page-break-after:always}
</style>

Then where you want the break put in:

<span class="breakhere"> &nbsp;</span>

Does not work very effectively.  It will put in the break, but the
print may break a other places as well.

In Netscrap there is not way to put in a break.

If the format of the printing is critical do not use an HTML page.

Convert it to a printer friendly format like PDF or DOC.

Cd&
0
 
LVL 2

Author Comment

by:davdonin
ID: 6392876
I have IE, but this method does not work for me. Most likely I am doing something wrong as my knowledge of HTML is close to zero.

Here is my document:

<html>
<head>
<style>
   .breakhere {page-break-after:always}
</style>
</head>
<body>
<pre>
  1                                                     Customer No.        440010046                
  2                                             Invoice No.         143673                  
  3                                             Invoice Date        01-July-2001            
  4                                             Page                1/4
  5
  6
  7
  8
  9
 10
<hr>
<span class="breakhere"> &nbsp;</span>
  1                                                     Customer No.        440010046                
  2                                             Invoice No.         143673                  
  3                                             Invoice Date        01-July-2001            
  4                                             Page                2/4
  5                        ACCOUNT STATEMENT                        
  6
  7                                                                        EUR             #              
  8Total Amount now due on this invoice                                7,163.84        4,303.90
  9Payments outstanding on previous invoices including VAT               312.71          187.87
 10Balance Forward Including VAT                                       7,476.55        4,491.77
 11
 12EUR exchange rate 1.6645                                                        
<hr>
<span class="breakhere"> &nbsp;</span>
  1                                                     Customer No.        440010046                
  2                                             Invoice No.         143673                  
  3                                             Invoice Date        01-July-2001            
  4                                             Page                3/4
  5
  6
  7
  8
  9                                                                      
 10
</pre>
</body>
</html>
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 19

Expert Comment

by:webwoman
ID: 6392939
You've got pre tags, your span only covers a space, and (as was mentioned before) it's not going to help much.

You don't control the paper size, orientation, font size (user can override anything you do), etc., etc., etc....

Set it up fine for you, it's wrong for anybody with a different printer, font size, system fonts, settings, etc. Which is probably 99%+ of the world... ;-)

Your BEST option for HTML is to put everything in a fixed size table, apprx. 500-600 px wide, no effects, no fancy font settings, no form fields, no background colors/images, no animations. That prints adequately (not perfectly) from just about everything.

But if it's important that it print a certain way, or if it's long, complex tables of data -- either make it a PDF or don't worry about how it prints.
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 50 total points
ID: 6393582
If you are going to use pre tags do the style this way and get rid of the spans:

<style>
  hr {page-break-after:always}
</style>
0
 

Expert Comment

by:webdude
ID: 6394545
I just stick the style in the table tag like so:

<table border=0 cellpadding=0 cellspacing=0 width=600 style="page-break-after:always">

cheers!
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6396736
Glad we could help.

Cd&
0
 
LVL 1

Expert Comment

by:magnakuz
ID: 6702524
Here is what I use.. It works very well:

<BR clear=all style='page-break-before'>

If you want to force a new page break even if it's the start of a new page you can use:

<BR clear=all style='page-break-before:always'>

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Html Table Looping (part 2) 5 27
html input 8 42
Do alert on select 6 13
Powershell script does not exit 4 26
This article discusses four methods for overlaying images in a container on a web page
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question