Printer friendly ASP.Net

K

karlman

I am in need of printing a detailed form from an ASP.Net page. I am
using ASP.Net 2.0 with VB.Net.

My intent is to create an ASP.Net page that only contains the
information I want printed which includes tables, text, and pictures.
I seem to be able to form the page I want well enough but printing is
another matter.

How can I control the margins so I can print closer to the edge? I
also want to prevent the header and footer from printing? I imagine it
would take some client side scripting.

Are there other methods of printing precise forms from a web page?

Thanks
Karl
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

karlman said:
I am in need of printing a detailed form from an ASP.Net page. I am
using ASP.Net 2.0 with VB.Net.

My intent is to create an ASP.Net page that only contains the
information I want printed which includes tables, text, and pictures.
I seem to be able to form the page I want well enough but printing is
another matter.

You can use the @media command i css to create css classes separately
for screen and print.

Example:

body { margin: 0; background: #fff; font-size: 10pt; }

@media screen {
body { padding: 20px; }
}

@media print {
body { padding: 0; }
}
How can I control the margins so I can print closer to the edge? I
also want to prevent the header and footer from printing? I imagine it
would take some client side scripting.

You can reduce the margin and padding specifically for print, as in my
example, but the browser also adds margin outside that area, as well as
the header and footer. The user can reduce that margin and remove the
header and footer in the browser settings, but you can't affect them
using either css or Javascript.
Are there other methods of printing precise forms from a web page?

You could use a PDF component to draw the contents of the page in a PDF
document that you send to the client, which the user then can print. I
used this approach for a customer when they needed to print 3" x 5"
labels on a label printer.
 
D

David R. Longnecker

Karl-
Are there other methods of printing precise forms from a web page?

Exact typography is really difficult, in my opinion, on the web due to resolutions,
differences in fonts, printers, and other uncontrollable elements. PDF is
about the only way to get it EXACTLY like you like.

The approach I took for one site that had various printable components (but
that they wanted rearranged when printed) was to enclose everything in DIV
tags (each "information section") and then programatically pull them back
using JavaScript in a new "Print Page" window.

I blogged the implementation back in January at http://tiredblogger.wordpress.com/2...rint-pages-without-custom-templates/#more-272.
The example points to Microsoft CMS, but any rendered content would work
the same.

For simple style manipulation, you can use CSS's built in media types (http://www.w3.org/TR/REC-CSS2/media.html)
and control fonts, spacing, etc. of elements.

HTH.

-dl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top