Last active
January 1, 2016 01:09
-
-
Save shonenada/8071513 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
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