Printer friendly ASP.Net

Discussion in 'ASP .Net' started by karlman, Sep 26, 2007.

  1. karlman

    karlman Guest

    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
     
    karlman, Sep 26, 2007
    #1
    1. Advertising

  2. karlman wrote:
    > 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.

    --
    Göran Andersson
    _____
    http://www.guffa.com
     
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Sep 26, 2007
    #2
    1. Advertising

  3. 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

    --
    David R. Longnecker
    http://blog.tiredstudent.com

    > 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
    > Kar
     
    David R. Longnecker, Sep 26, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Klucker

    implementing a Printer Friendly .aspx Page

    John Klucker, Aug 15, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    405
    John Timney \(Microsoft MVP\)
    Aug 15, 2003
  2. Valera Simonov

    how to make asp:textbox printer-friendly?

    Valera Simonov, Oct 17, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    422
    Natty Gur
    Oct 19, 2003
  3. Ray
    Replies:
    2
    Views:
    1,135
  4. Yog
    Replies:
    0
    Views:
    464
  5. Mike
    Replies:
    1
    Views:
    1,122
    Andrew Morton
    Feb 11, 2009
Loading...

Share This Page