Convert To Pdf From The Cmdline

Have you ever been in need of a convenient way to convert a Word document (.doc) into a Portable Document Format (.pdf)?

I do this fairly often, which prompted me to write this script using Google Docs.

It works by uploading the input file to a collection named "GDocs2Pdf" in your Google Docs account, and then requesting a Pdf version for download. If conversion is successful, the filename will have a .pdf extension appended and will be downloaded to the directory containing the input file.

Once installed and placed on your path, simply type example-file.doc to run the script.

While I regularly use this script to convert Word documents to Pdf, other input formats are acceptable. Also, by modifying the --format=pdf argument on line 11, you can request alternative output file formats. Log into your Google Docs account to see which input and output formats are currently supported.


  1. A Google Docs account
  2. A collection named "GDocs2Pdf" in your account
  3. The GoogleCL command line utility installed1,2 on your system
  4. A connection to the internet


  1. Paste the script into a file named ""
  2. Modify the path to the GoogleCL utility on line 7 as appropriate
  3. Place it on your path, for example in your ~/bin directory
  4. Make it executable chmod u+x


Please check for updates to this script.

  # usage: <file>
  [ $# -eq 1 ] || { echo "usage: $(basename $0) <file>"; exit 1; }
  TITLE=$(basename "$1")
  DIR=$(dirname "$1")
  echo $GOOGLECL docs upload --title="$TITLE" --folder="$FOLDER" "$1"
  $GOOGLECL docs upload --title="$TITLE" --folder="$FOLDER" "$1"
  echo $GOOGLECL docs get --format=pdf --title="$TITLE" --folder="$FOLDER" --dest="$DIR"
  $GOOGLECL docs get --format=pdf --title="$TITLE" --folder="$FOLDER" --dest="$DIR"


[1] : GoogleCL webpage. The utility is written in Python. Please see this page for installation instructions.

[2] : Configuration of GoogleCL is required to authorize access to your account. Configuration settings are initialized upon the first invocation of the tool, whether they are supplied as command line arguments or as answers to the interactive prompts. These defaults are used unless overridden using the flagged arguments. To change the defaults, see Configuration Options.

blog comments powered by Disqus



06 May 2011