Created
January 6, 2020 04:23
-
-
Save Tantalus13A98B5F/fe26ed4fe0248024c3b7082d9353e7ed to your computer and use it in GitHub Desktop.
A Python script to convert MSOffice files to PDF. Requires `pywin32` and MSOffice installation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import win32com.client | |
msoTrue, msoFalse = -1, 0 | |
def word2pdf(src, dst): | |
wdExportFormatPDF = 17 | |
app = win32com.client.DispatchEx('Word.Application') | |
doc = app.Documents.Open(src) | |
doc.ExportAsFixedFormat(dst, wdExportFormatPDF) | |
doc.Close() | |
app.Quit() | |
def ppt2pdf(src, dst): | |
ppSaveAsPDF = 32 | |
app = win32com.client.DispatchEx('PowerPoint.Application') | |
ppt = app.Presentations.Open(src, msoTrue, msoFalse, msoFalse) | |
ppt.SaveAs(dst, ppSaveAsPDF) | |
ppt.Close() | |
app.Quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment