Solved

Printing HTML pages

Posted on 2001-08-16
8
306 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Find out what you should include to make the best professional email signature for your organization.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now