miscoded

the web is a hack

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"..

Unfortunately opera: is the new chrome:HTML5 and invalid documents - the great misunderstanding

Comments

Michael A. Puls IIburnout426 Wednesday, November 12, 2008 12:40:30 PM

That's similar to what I do when I print in Opera. I install CutePDF Writer and print to PDF. Then, I load the pdf file in a pdf reader, select what I want and print.

Anonymous Wednesday, November 12, 2008 2:42:39 PM

Anonymous writes: So....if you don't have adobe installed, you can't print?

Rafald.i.z. Wednesday, November 12, 2008 8:27:10 PM

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.

Turin Friday, November 14, 2008 9:10:59 AM

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.

Hallvord R. M. Steenhallvors Friday, November 14, 2008 11:36:38 PM

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. smile

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 smile.

Anthony John Lourensantwap Monday, December 8, 2008 9:22:41 PM

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. cry i want to learn how to program. I know the 1xtable

Anonymous Thursday, October 14, 2010 2:00:59 PM

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!!

Anonymous Saturday, December 25, 2010 2:56:37 PM

Anonymous writes: BBcode and HTML is turned off for anonymous user comments.

Anonymous Sunday, August 7, 2011 6:13:17 PM

Анонімний 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.

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.