简体   繁体   English

如何使用python中的win32com将Word转换为图像?

[英]How to convert Word to images with win32com in python?

I have googled an example for converting Word to Html. 我已经在Google上搜索了将Word转换为HTML的示例。

import win32com 
from win32com.client import Dispatch, constants  
w = win32com.client.Dispatch('Word.Application') 
w = win32com.client.DispatchEx('Word.Application')

'''skip some code here'''

wc = win32com.client.constants 
w.ActiveDocument.SaveAs( FileName = filenameout, FileFormat = wc.wdFormatHTML )

I tried looking for something like wc.wdFormatPNG as wc.wdFormatHTML in the example but failed.And I wonder does the attribute exist?Or any other better solutions?Suggestions would be appreciated. 我尝试在示例中查找类似wc.wdFormatPNG wc.wdFormatHTML ,但是失败了。我不知道该属性是否存在?或者任何其他更好的解决方案?我们将不胜感激。

You can try to print the Word document to PDF or TIFF file . 您可以尝试将Word文档打印为PDF或TIFF文件 I never did it myself, but if it can be done manually, most probably you can automate it. 我从来没有亲自做过,但是如果可以手动完成,很可能可以将其自动化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM