Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Report decent printing in the web

As a web systems programmer, I'd like to generate some reports and be able to send it to the printer directly from my user's browser, wich is in the client side, not needing to generate PDFs or something like this.

I would like to be able to:

  • Print user friendly paging, something like "Page 1 of 3"
  • Print some things in the bottom of every page, like "Generated in 2009-02-20"
  • not printing the URL

Is all this possible? Javascript? CSS? What are the best practices here?

like image 640
Ricardo Acras Avatar asked May 14 '09 22:05

Ricardo Acras


People also ask

How do I print a report in HTML?

Right-click the report in the connection tree and choose Print Report As -> PDF/HTML/Excel/Archive.


3 Answers

All those things are controlled exclusively through browser preferences. If you want to be able to specify that, then you probably should be looking at PDF instead of HTML.

like image 189
Quentin Avatar answered Nov 15 '22 00:11

Quentin


You're out of luck using the browser there... I think it is impossible to not print in the corners the URL, Date/Time Accessed etc.

However, Page 1 or 3 etc is generally always printed somewhere (bottom right corner I believe in FireFox)

Printing a 'Generated in 2009-02-20' is easy enough, however printing it at the bottom of every page will be difficult. Most browsers, IIRC, display the date and time accessed in a corner (though not in that format, in a more readily human readable format).

Anything you want to appear in print but not in the normal screen view, will need to be shown using a print stylesheet.

For what you want here (complete control of the printing output), I'd recommend generating a PDF. Perhaps if this is an internal tool, you might be able to program a plugin for Firefox that may print your pdfs automatically, but I'm not that familiar with the capabilities of Firefox plugins so you'd need to experiment.

like image 44
alex Avatar answered Nov 14 '22 23:11

alex


Support from different browsers is surely lacking, but css has a media type called print, to use it, just define a section in your css file or tag like this:

@media print{
/* normal style declarations
 but you probably want to hide menus 
 and other navigation, also use black on white,  etc.
 */
}
@media screen{
/* your current stylesheet */
}

This List Apart article covers the basics.

And here's an entry point to the wc3 specification.

like image 39
krusty.ar Avatar answered Nov 14 '22 23:11

krusty.ar