将Python Visio转换为pdf [英] Python Visio to pdf
本文介绍了将Python Visio转换为pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将一堆Visio文件转换为python中的pdf.我已经将此 .doc引用为使用python的pdf 并编写了以下代码:>
I'm trying to convert a bunch of Visio files to pdf in python. I have referenced this .doc to pdf using python and written the following code:
import comtypes.client as coms
format=17
visio = coms.CreateObject('Visio.Application')
doc = visio.Documents.Open('map.vsd')
doc.SaveAs('map.pdf', FileFormat=format)
给我一个TypeError: call takes exactly 2 arguments (3 given)
我一直在谷歌搜索,找不到有关如何使用python在Visio中打印为pdf的参考.
I've been Googling and can't find the reference on how to print to pdf in Visio using python.
推荐答案
您应使用ExportAsFixedFormat
代替SaveAs
.您可以在此处.此函数可以与win32和comtypes一起使用.
You should use ExportAsFixedFormat
instead SaveAs
. Documentation for this function you can find here. This function can be used with a win32 and a comtypes.
win32com示例
import win32com.client
visio = win32com.client.Dispatch("Visio.Application")
doc = visio.Documents.Open('map.vsd')
doc.ExportAsFixedFormat( 1, 'map.pdf', 1, 0 )
类型示例
import comtypes.client as coms
visio = coms.CreateObject('Visio.Application')
doc = visio.Documents.Open('map.vsd')
doc.ExportAsFixedFormat( 1, 'map.pdf', 1, 0 )
这篇关于将Python Visio转换为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文