Skip to content

Instantly share code, notes, and snippets.

@joeybeninghove
Created October 16, 2010 02:43
Show Gist options
  • Select an option

  • Save joeybeninghove/629329 to your computer and use it in GitHub Desktop.

Select an option

Save joeybeninghove/629329 to your computer and use it in GitHub Desktop.
# 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