Me
Categories
Literary

Entries in Export (1)

Thursday
Jan272011

Exporting a Google Sites to PDF

Google Sites does not provide a way to export a page within a Google Site as a PDF. However, you can use the Google Sites API coupled with wkhtmltopdf to export a Site as PDF. Here is how:

Step 1) Obtain/compile/install wkhtmltopdf on your system. Instructions can be found here.

Step 2) Obtain a Authentication Token from Google: 

# curl https://www.google.com/accounts/ClientLogin -d Email=user@domain.tld -d Passwd=mysecretpassword -d accountType=HOSTED_OR_GOOGLE  -d source=cURL-Example -d service=jotspot

This will return something that looks as follows:

 

SID=DQAAAHYBADCv2pSv7nflacDNwz3zEDUGtrSvNSfddi77b35sEaH.................................
LSID=EUBBBIaBADCl-kNxvRVmcQghpt3cqSMfEooKR9flL...............................
Auth=EUBBIacAAADK-kNxvRVmcQghpt3cqSMfEo..........................................

Step 3) Export a Google Sites page as PDF using wkhtmltopdf:

wkhtmltopdf --custom-header "Authorization" "GoogleLogin auth=AuthKey" https://sites.google.com/site/sitename/page-title?tmpl=/system/app/templates/print/  output.pdf