Solved

Printing HTML pages

Posted on 2001-08-16
8
295 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
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)

708 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

18 Experts available now in Live!

Get 1:1 Help Now