Exporting html report for printing

Posted on 2006-04-25
Last Modified: 2008-02-01
I have an HTML report that users want to be able to print out. I want to make sure it is properly formatted for printing so i'm exporting it out to MS Word first. The issue i have is that any images that exist in the HTML version are lost on the export and my page breaks are also lost.
I would do it without the export to MS Word routine but then the reports have the url on the header and footer and it looks really messy. Any ideas anyone?
Question by:johnnymc1
    LVL 5

    Expert Comment

    What you can do is create a CSS style for your page that uses ' media="print" ', this will allow you to create a style layout for your page that will only be applied when the page is printed (thusly you can set new font size, spacing, image placement).  See the following links for some easy how-to steps:


    Author Comment

    will this allow me to remove the URL that appears at the top and bottom of the page though?
    LVL 2

    Expert Comment

    you can remove the url in your browsers print settings/page setup in both internet explorer and firefox
    LVL 2

    Accepted Solution

    You can also look at MeadCo's ScriptX.

    They have both a full version and free version that allows you to remove the hdr and footer that the browser supplies. That way you wont have to change everyone's browser settings.

    I use the free version and it serves my purposes.

    LVL 15

    Expert Comment

    ScriptX, as suggested by beermequick is good.

    Also, you can try exporting as a PDF with

    PDF, I guess, would have more granular control on printing right?
    LVL 2

    Expert Comment

    iText is very nice too.  

    You can get some very nice looking reports via the API, but it can be quite cumbersome to use if your report is extensive.

    If these reports are for upper management, I would make the extra effort using iText as the result is far more eye applealing,  But if its form some bean counter that is going to put it on a pile of 10 million other papers, then the ScriptX will be much easier on you.

    Here is a code snippet I use for scriptx

    // This goes in a javascript file

    var PORTRAIT = true;
    var LANDSCAPE = false;

    function printDocument(buttonDivId, orientation){
        var elem = document.getElementById(buttonDivId); = "none";  

        var h = factory.printing.header;
        var f = factory.printing.footer;  
        var tm = factory.printing.topMargin;
        var bm = factory.printing.bottomMargin;
        factory.printing.header = "";
        factory.printing.footer = "&b&bPage &p of &P";
        factory.printing.portrait = orientation;      
        factory.printing.topMargin = 0.5;
        factory.printing.bottomMargin = 0;
        factory.printing.header = h;
        factory.printing.footer = f;  
        factory.printing.topMargin = tm;
        factory.printing.bottomMargin = bm;
           = "block";

    in my webpage....I put a button
    <div ID="printButton">
      <table WIDTH="660" BORDER="0" ALIGN="CENTER">
          <td align="LEFT">
            <input TYPE="Button"


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: Create Mobile App Prototypes with Adobe XD

    This is a project-based course: we go through all the steps of creating a prototype from start to finish, using all the tools and features currently available in Adobe XD. You can complete the course in less than a day, plus all project files and fonts are included.

    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 …
    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
    Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

    794 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