How to convert a .pptx to .pdf using Python -
i have been looking convert .pptx file .pdf file through python script several hours nothing seems working.
what have tried: have tried 1) this script calls windows32.client, , 2) unoconv, none of them seem working me.
problems encountered: using script first option throws error (com_error: (-2147352567, 'exception occurred.', (0, none, none, none, 0, -2147024894), none)
), whereas in second option python can't seem recognize unoconv
after installing using pip.
i saw recommended pandoc, can't understand how use python.
versions using: python 2.7.9, windows 8.1
i found answer of this post , answer this question.
import comtypes.client def ppttopdf(inputfilename, outputfilename, formattype = 32): powerpoint = comtypes.client.createobject("powerpoint.application") powerpoint.visible = 1 if outputfilename[-3:] != 'pdf': outputfilename = outputfilename + ".pdf" deck = powerpoint.presentations.open(inputfilename) deck.saveas(outputfilename, formattype) # formattype = 32 ppt pdf deck.close() powerpoint.quit()
Comments
Post a Comment