Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 378
  • Last Modified:

Exporting html report for printing

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?
0
johnnymc1
Asked:
johnnymc1
1 Solution
 
GENTPCommented:
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:

http://webdesign.about.com/cs/css/a/aa042103a.htm

http://www.webdesignschoolreview.com/css-printing.html


0
 
johnnymc1Author Commented:
will this allow me to remove the URL that appears at the top and bottom of the page though?
0
 
martyngatesCommented:
you can remove the url in your browsers print settings/page setup in both internet explorer and firefox
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
beermequikCommented:
You can also look at MeadCo's ScriptX.

http://www.meadroid.com/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.

0
 
deepaknetCommented:
ScriptX, as suggested by beermequick is good.

Also, you can try exporting as a PDF with http://itextsharp.sourceforge.net/ 

PDF, I guess, would have more granular control on printing right?
0
 
beermequikCommented:
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);
    elem.style.display = "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.Print(false);      
   
    factory.printing.header = h;
    factory.printing.footer = f;  
    factory.printing.topMargin = tm;
    factory.printing.bottomMargin = bm;
       
    elem.style.display = "block";
}

in my webpage....I put a button
<div ID="printButton">
  <table WIDTH="660" BORDER="0" ALIGN="CENTER">
    <tr>
      <td align="LEFT">
        <input TYPE="Button"
                  VALUE="Print"
                  Style="font-size:12px"
                  onclick="printDocument('printButton',PORTRAIT)">
      </td>
    </tr>
  </table>
</div>

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now