How Google Docs prints

Web browsers haven't focused much on printing. The web is so much nicer on the screen than on a flake of dead trees..

Hence, web browsers are not very good at printing. For example, they have the annoying habit of splattering URLs and dates across the footer of a page. (Some versions of Opera are known to be so insistent on including a URL that they grab a random URL from a recently seen page and add it to the footer even when you print an E-mail. There is not unlikely a story about somebody becoming really, really embarassed by that bug on some blog somewhere in the universe..)

So what do you do if you write an online word processor and want your users to be able to print beautifully? Here is what Google Docs does when you click their "Print" button:

  1. Saves your document to the server
  2. Converts it on the server – on the fly – from HTML to PDF
  3. Creates a hidden Adobe Acrobat plugin instance inside the editor tab
  4. Load the newly converted PDF into the plugin
  5. Triggers the Acrobat print dialog

Wow. An impressive hack.

"Oh what a tangled web we weave, When first we practice workarounds"..

Advertisements

9 thoughts on “How Google Docs prints

  1. Originally posted by hallvors:

    Wow. An impressive hack.

    Is there some bug related to that or you wrote about that because this is just interesting?If there is a bug, then I'm all for less automated Google Docs way. They just trigger download dialog with a pdf file when you want to print. You can do anything you want with it then. Even my mom should be able to open it and trigger print action in acrobat.EDIT: Hey, you were talking about "Google Docs" actually. I've tried yesterday and they offered me a file in download dialog…EDIT2: Just checked – "Documents" print the way you presented, "Spreadsheets" just pop up download dialog.

  2. Browsers "have the annoying habit of splattering URLs and dates across the footer of a page." I actually like the printing of this information as it is good to have when printing out something for research purposes. I would prefer if the printing of the URL and date was an option that could be toggled off as most of time I want it off, but it is very handy capability to have when you need it.

  3. d.i.z: well, I looked at it while investigating a bug with Opera's built-in print feature – wondering how Google Docs could avoid it. :)Turin: sure, it's useful – but certainly it's also useful to be able to turn it off, and I actually want a page author to be able to do that. (One of my small home-baked backends somewhere has an "invoice printout" feature – of course it creates PDF files for the single stupid reason that nobody wants to send out an invoice carrying the URL of their secret order admin page across the bottom..). If we had some CSS to control it, users who really cared could override authors again :).

  4. i know the tune, but i forgot the words. i only know the 1xTABLE:point out where i could learn the words, and how to write them, as i said i know the tune! So that means i will get there fast. The tune is all about this page im reading. What i like about all you clever, sarcastics guys is, you all have a great sense of humour. 😥 i want to learn how to program. I know the 1xtable

  5. Kay writes:Thank you sooo much!!Since I am not a computer person, this is the easiest to understand.I was struggling all this time but thanks!!

  6. Анонімний writes:A lot of specialists claim that mortgage loans aid people to live the way they want, just because they are able to feel free to buy needed stuff. Furthermore, banks give consolidation loan for different classes of people.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s