473,890 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing headers for an HTML only when printing

Hi,
is there any way to write a header in each HTML page when printing them
while leaving the header only on top of the file when viewing it? I
mean, I have a file that looks like this:

TITLE

TABLE1

TABLE2

TABLE3

TABLE4

and each table is being printed on a separate page using CSS
page-break-after. What I want to do is that, when I print it, the
result will be something like:

TITLE

TABLE1

-page break-

TITLE

TABLE 2

-page break-

.... and so on.

Is there any way?
Thanks :)

LuTHieR

Jul 17 '06 #1
4 3326

LuTHieR wrote:
is there any way to write a header in each HTML page when printing them
while leaving the header only on top of the file when viewing it?
Sort of.

You can do this with CSS using the @media print rule
http://www.w3.org/TR/CSS21/media.html#at-media-rule

With this you can mark up sections of your page as "print only" and
"no-print" with a simple class attribute.

..print-only{ display: none; visibility: hidden; }

@media print {
.print-only { display: inherit; visibility: display; }
.no-print { display: none; visibility: hidden; }
}
Now this isn't exactly what you wanted - there's no way in CSS to say
"repeat on every page" (you can do this with XSL:FO and PDF, but not
HTML). So you'll still have to duplicate your "print only" caption on
each pagge manually.

Jul 17 '06 #2

Andy Dingley wrote:
LuTHieR wrote:
is there any way to write a header in each HTML page when printing them
while leaving the header only on top of the file when viewing it?

Sort of.

You can do this with CSS using the @media print rule
http://www.w3.org/TR/CSS21/media.html#at-media-rule

With this you can mark up sections of your page as "print only" and
"no-print" with a simple class attribute.

.print-only{ display: none; visibility: hidden; }

@media print {
.print-only { display: inherit; visibility: display; }
.no-print { display: none; visibility: hidden; }
}
Now this isn't exactly what you wanted - there's no way in CSS to say
"repeat on every page" (you can do this with XSL:FO and PDF, but not
HTML). So you'll still have to duplicate your "print only" caption on
each pagge manually.
Many thanks for the answer, but I still don't know how to use it
exactly, I never used @media and am not really sure of its usage.

Assuming I have something like

<strong>TITLE </strong>
<table>....</table>
<table>....</table>
<table>....</table>

how should I apply the styles in order to make the title print before
every table? I guess it's got to be something like

<span class="print-only">TITLE</span>
<table>....</table>
<span class="print-only">TITLE</span>
<table>....</table>
<span class="print-only">TITLE</span>
<table>....</table>

but I'm not really sure. Could you please explain it a little more?
Thanks again,

LuTHieR

Jul 17 '06 #3

LuTHieR wrote:
how should I apply the styles in order to make the title print before
every table? I guess it's got to be something like

<span class="print-only">TITLE</span>
<table>....</table>
That's pretty much it (although I'd use <h2or something more
meaningul rather than just <span>)

Jul 17 '06 #4

Andy Dingley wrote:
LuTHieR wrote:
how should I apply the styles in order to make the title print before
every table? I guess it's got to be something like

<span class="print-only">TITLE</span>
<table>....</table>

That's pretty much it (although I'd use <h2or something more
meaningul rather than just <span>)
Thanks :)

Jul 27 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
17414
by: Alec | last post by:
Hi, I am trying to print an HTML page from Internet Explorer and it always put the page title and page count at the top of the page. How can I disable printing page title and page count? Thanks.
1
2180
by: adiel | last post by:
Hello everyone. The problem is when printing, the text gets cut half way and prints the other half on to the next page when printing using internet explorer and an asp.net datagrid. I am sure there must be a simple fix to stop the text from getting cut in half like this when using the asp.net datagrid. Any ideas? Thanks before hand, Adiel
4
3366
by: Jack Russell | last post by:
Any bright ideas on how I can calculate how wide a piece of text will be when printing. When writing text to the screen in graphics mode I put it in a invisible text box to get its height and width (as suggested on this group). But obviously I cannot do that with the printer. Thanks
8
12799
by: CJM | last post by:
What is the best way to force a page break when printing from a browser? A page in my application generates a series of tables which are usually less than will fit on a page of A4. Ideally I want to introduce a page break between each table when printing. I'm not sure what options I have available. I know there is some support in CSS but I'm no sure on the details or effectiveness. Thanks in advance...
6
2139
by: J Ames | last post by:
I have an ASP.NET (VB) form that has two drop downs, a horizontal rule and a button. The button invokes a stored procedure and several tables are created on the page with data populated. I want to create a link to print the page, but I don't want the drop downs or the button to print, only the tables. How can this be done? I know how to use a CSS file to disallow the entire page from being printed, but I don't know how to apply this to...
5
14211
by: fjanon | last post by:
Is there a way to remove the default footer/header from the printed page when printing a page from HTML/Javascript in IE 6? I want to use letterhead paper and I have to remove manually the header/footer from the default printer setting. I know that IE has lots of options/features, I spent a good time on MSDN but could not find anything. TIA Fred
0
1038
by: BlueComet | last post by:
Does anyone know of a solution to avoiding right-floated elements (like a pull quote) from getting clipped at the top when printing, when it occurs between page breaks? Increasing the top margin of the browser's page setup works but that would be a user-controlled parameter.
7
9050
by: bbatson | last post by:
Hello, I have a fairly extensive report with 10 or so subreports. I've found that random lines (simply used to separate column headers from data) are at random disappearing when printing to a PDF file. They show up when viewing in Print Preview mode within Access (2007) but for some reason are not always showing up in the PDF report. It's especially weird because the line will be in the same grouping and will show up for some sets of data...
8
6154
by: deegeorge | last post by:
Hi, I am printing a word document. When printing in the Print statement its showing a dialog box Save File as. How can i hide this dialog box.... Reply fast... Deeps
0
9977
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9816
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11218
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10802
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9618
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7161
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6036
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4667
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.