0

I've been asked to create a web based application that, on several parts, needs to offer a 'print' button to the user and, once clicked, send a document to the printer.

However, the information printed should be as reliable as possible on format - ideally, it should be almost identical on any printer/computer/os and not contain any header/footer inserted by the browser (like the url info Internet Explorer is configured to print by default).

I've been thinking about creating a PDF file in the server and do some research on whether I can create a hidden div/object/something to load that PDF file and then use javascript to make it receive the 'print' instruction once loaded.

Anyway, I thought about asking you guys for ideas. How would you do this? Do you know of a better way?

Thanks in advance for any comments!

Francisco

Francisco Zarabozo
  • 3,676
  • 2
  • 28
  • 54
  • 1
    This topic seems to be what you are looking for: http://stackoverflow.com/questions/1960939/disabling-browser-print-options-headers-footers-margins-from-page?rq=1 – Magnus Lindgren Apr 22 '13 at 07:09
  • @MagnusLindgren: Thank you, that's a useful post. However, it's not exactly what I'm looking for. That guy wanted to be able to do this by using only CSS. Me, I'm looking for the most reliable way to print with a certain format, even if that means using something like PDF, or maybe a Java Applet I might not be aware of. – Francisco Zarabozo Apr 22 '13 at 07:25

1 Answers1

1

If you need the exact same format on all browsers I would recomment pdf. For example the header with the URL is added by the browser when printing and you can only disable it within a browser, not with media query.

I use wkhtmltopdf to generate pdf.

Rok Burgar
  • 949
  • 5
  • 7
  • Thank you, looks like an interesting tool. If it works as it claims, it can be very easy to format documents using just CSS. I'll try it out soon. – Francisco Zarabozo Apr 22 '13 at 15:30