Friday, March 7, 2008

Adding Page Numbers to Google Documents

Google finally realized that the headers and footers from Google Docs have almost no real use, as you can't add dynamic information like page numbers or the current date. Until Google adds these options in the interface, you can edit the document's HTML code to use them. To add a header that displays "Page (current page number) of (total number of pages)" , click on "Edit HTML" and add this code at the beginning of the document:

<div style="text-align: right;" class="google_header">Page <span class="google_pagenumber">1</span> of <span class="google_pagecount">1</span></div>

When you save the document as a PDF, the header will look like this:


For footers, you should add this at the bottom of the document, in HTML view:

<div style="text-align: right;" class="google_footer" id="google_footer">Page <span class="google_pagenumber">1</span> of <span class="google_pagecount">1</span></div>

It's a good idea to go back to the rich text editor quickly if you don't want to see the horrible code generated by Google Docs. The "dynamic" headers and footers are visible only if you export the document to PDF, for example to print it.

No comments:

Post a Comment