Skip navigation.

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

burnout426 12. November 2008, 12:40

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 12. November 2008, 14:42

Anonymous writes:

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

d.i.z. 12. November 2008, 20:27

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 14. November 2008, 09:10

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.

hallvors 14. November 2008, 23:36

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

antwap 8. December 2008, 21:22

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

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies