Created
October 16, 2010 02:43
-
-
Save joeybeninghove/629329 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # simple script to convert a Word Doc to a PDF using Google Docs | |
| require 'rubygems' | |
| require 'gdocs4ruby' | |
| service = GDocs4Ruby::Service.new | |
| service.authenticate("username", "password") | |
| doc = GDocs4Ruby::Document.new(service) | |
| doc.title = 'testing' | |
| doc.local_file = 'testing.doc' | |
| doc.save | |
| id = doc.id.gsub('document:', '') | |
| # workaround for bug in GDocs4Ruby::Document : 81 | |
| request = GData4Ruby::Request.new(:get, | |
| 'https://docs.google.com/feeds/download/documents/Export', | |
| nil, | |
| nil, | |
| { 'docId' => id, | |
| 'exportFormat' => 'pdf' }) | |
| response = service.send_request(request) | |
| File.open('testing.pdf', 'wb+') { |f| f.write(response.body) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment