문제

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)

gives me a TypeError: call takes exactly 2 arguments (3 given)

I've been Googling and can't find the reference on how to print to pdf in Visio using python.

도움이 되었습니까?

해결책

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 example

import win32com.client
visio = win32com.client.Dispatch("Visio.Application")
doc = visio.Documents.Open('map.vsd')
doc.ExportAsFixedFormat( 1, 'map.pdf', 1, 0 )

comtypes example

import comtypes.client as coms
visio = coms.CreateObject('Visio.Application')
doc = visio.Documents.Open('map.vsd')
doc.ExportAsFixedFormat( 1, 'map.pdf', 1, 0 )
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top