views:

774

answers:

1

I tried to create a simple HTML page as below

<html>
    <a href="javascript:window.print();">Print this page</a>
    <div>
     something 
     something
    </div>
</html>

After clicking the "Print this page", the pop-up print dialog is quite simple. There is no preview in the dialog.

In Google Calendar, user can print calendar. In "calendar print preview" window, clicking "Print" will pop up print dialog. The print dialog has a preview of the calendar view to be printed. I'm wondering how to call out such print dialog with Javascript.

In my knowledge, Javascript/DOM has only one API "window.print" about printing. Is there any other way to customize print?

+1  A: 

The print preview that Google Calendar uses are created as an image on the server and then shown to the user.

Here is a related question: JavaScript print preview

If you are OK with a solution that only works in IE, this question might help you out: How can Print Preview be called from Javascript?

I think this is the way to go, for a cross-browser solution:

http://www.alistapart.com/articles/printtopreview/

Espo
Thanks for you tip.I found that Google Calendar preview in browser web is achieved by returning a PNG file from server, while Preview in Print Dialog is achieved by returning a PDF file from server. The preview is actually rendered by acrobat plugin. It brings no surprise that the "Print Tips" button leads to adobe website.
Morgan Cheng