600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > Python实现将DOC文档转换为PDF办法

Python实现将DOC文档转换为PDF办法

时间:2020-09-26 22:51:34

相关推荐

Python实现将DOC文档转换为PDF办法

后端开发|Python教程

Python,DOC,转换,PDF

后端开发-Python教程

本文实例讲述了Python实现将DOC文档转换为PDF的方法。分享给大家供大家参考。具体实现方法如下:

积分墙app源码,查看磁盘使用ubuntu,吸血的爬虫种类,window php,seo图片算法lzw

import sys, osfrom win32com.client import Dispatch, constants, gencachedef usage(): sys.stderr.write ("doc2pdf.py input [output]") sys.exit(2)def doc2pdf(input, output): w = Dispatch("Word.Application") try: doc = w.Documents.Open(input, ReadOnly = 1) doc.ExportAsFixedFormat(output, constants.wdExportFormatPDF, Item = constants.wdExportDocumentWithMarkup, CreateBookmarks = constants.wdExportCreateHeadingBookmarks) return 0 except: return 1 finally: w.Quit(constants.wdDoNotSaveChanges)# Generate all the support we can.def GenerateSupport(): # enable python COM support for Word # this is generated by: makepy.py -i "Microsoft Word 12.0 Object Library" gencache.EnsureModule({00020905-0000-0000-C000-000000000046}, 0, 8, 4)def main(): if (len(sys.argv) == 2): input = sys.argv[1] output = os.path.splitext(input)[0]+.pdf elif (len(sys.argv) == 3): input = sys.argv[1] output = sys.argv[2] else: usage() if (not os.path.isabs(input)): input = os.path.abspath(input) if (not os.path.isabs(output)): output = os.path.abspath(output) try: GenerateSupport() rc = doc2pdf(input, output) return rc except: return -1if __name__==\__main__: rc = main() if rc: sys.exit(rc) sys.exit(0)

微信转发赚钱系统源码,ubuntu进单机模式,java爬虫专用包,php flock,木姐seo招聘lzw

医院管理系统php源码,禁止vscode 更新,三星s7 ubuntu,tomcat监控流程,sqlite 亲和类型(,电脑服务器样怎么用,jsp页面日历插件,web前端框架作业,爬虫能力,php贵阳培训,如何学习seo网站优化,bootstrap开发网站模板,网页随机代码,h5展示模板下载,非主流页面,三级医院管理系统源码,强制结束程序的语句是lzw

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。