Skip to content

Instantly share code, notes, and snippets.

@shonenada
Last active January 1, 2016 01:09
Show Gist options
  • Save shonenada/8071513 to your computer and use it in GitHub Desktop.
Save shonenada/8071513 to your computer and use it in GitHub Desktop.
import os
import sys
import comtypes.client
def main():
in_file = os.path.abspath(sys.argv[1])
out_file = os.path.abspath("%s.pdf" % sys.argv[1])
try:
word_application = comtypes.client.CreateObject('Word.Application')
word_file = word_application.Documents.Open(in_file)
word_file.SaveAs(out_file, FileFormat=17)
except Exception, e:
print e
finally:
word_file.Close()
word_application.Quit()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment