Solved

Printing HTML pages

Posted on 2001-08-16
8
343 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
[X]
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
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
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.…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

622 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