Created
September 5, 2019 13:22
-
-
Save saosir/e4b963e28b39043c9c4ea212eeb958e8 to your computer and use it in GitHub Desktop.
windows下 word 转 pdf
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
| # -*- coding:utf-8 -*- | |
| import os | |
| import comtypes | |
| from comtypes.client import CreateObject | |
| wdFormatPDF = 17 | |
| in_file = os.path.abspath('f:/xx.docx') | |
| out_file = os.path.abspath('f:/xueweizheng.pdf') | |
| word = CreateObject('Word.Application') | |
| doc = word.Documents.Open(in_file) | |
| doc.SaveAs(out_file, FileFormat=wdFormatPDF) | |
| doc.Close() | |
| word.Quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment