How Google Docs prints
Wednesday, 12. November 2008, 12:25:41
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:
- Saves your document to the server
- Converts it on the server - on the fly - from HTML to PDF
- Creates a hidden Adobe Acrobat plugin instance inside the editor tab
- Load the newly converted PDF into the plugin
- Triggers the Acrobat print dialog
Wow. An impressive hack.
"Oh what a tangled web we weave, When first we practice workarounds"..










burnout426 # 12. November 2008, 12:40
Anonymous # 12. November 2008, 14:42
So....if you don't have adobe installed, you can't print?
d.i.z. # 12. November 2008, 20:27
Originally posted by hallvors:
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.
Turin # 14. November 2008, 09:10
hallvors # 14. November 2008, 23:36
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
antwap # 8. December 2008, 21:22
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.