学校招办网站怎么做,网络网站推广,网页界面设计主要内容有哪些,货物运输东莞网站建设目录将word转换为pdf格式安装pywin32上代码运行结果批量实现word转pdf安装docx2pdf上代码运行结果将word转换为pdf格式
安装pywin32
代码#xff08;Anaconda终端下#xff09;
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsingh…
目录将word转换为pdf格式安装pywin32上代码运行结果批量实现word转pdf安装docx2pdf上代码运行结果将word转换为pdf格式
安装pywin32
代码Anaconda终端下
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn pywin32运行结果
上代码
在pycharm中输入代码
from win32com.client import Dispatch, constants, gencache# 放入要转换的word格式路径
docx_path G:\示例.docx# 放入要导出的pdf格式的路径并且命名
pdf_path G:\示例.pdf# 转换
gencache.EnsureModule({00020905-0000-0000-C000-000000000046}, 0, 8, 4)wd Dispatch(Word.Application)doc wd.Documents.Open(docx_path, ReadOnly1)doc.ExportAsFixedFormat(pdf_path, constants.wdExportFormatPDF, Itemconstants.wdExportDocumentWithMarkup,CreateBookmarksconstants.wdExportCreateHeadingBookmarks)wd.Quit(constants.wdDoNotSaveChanges)运行结果
docx文件 pdf文件 个人感觉pdf版本的真的看起来好舒服呀
批量实现word转pdf https://blog.csdn.net/hanhanwanghaha宝藏女孩 欢迎您的关注 欢迎关注微信公众号宝藏女孩的成长日记 如有转载请注明出处如不注明盗者必究 安装docx2pdf
代码Anaconda终端下
pip install --user -i https://pypi.tuna.tsinghua.edu.cn/simple/ docx2pdf如图所示
上代码
from docx2pdf import convert
import os#放入你想要转换的文件路径
director rG:\eg
FileList map(lambda x: director \\ x, os.listdir(G:\eg))
for file in FileList:convert(file, f{file.split(.)[0]}.pdf)运行结果 这就是全部内容啦希望可以帮到你熬 这边找了一个exe文件打开就直接可以word转换pdf文件 https://download.csdn.net/download/hanhanwanghaha/12810795 要是没有积分下载的话可私我我分享给你嘿嘿嘿