Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import sys
  2. import os
  3. import webbrowser
  4. import comtypes.client
  5.  
  6. wdFormatPDF = 17
  7.  
  8. in_file = "G:\CSE DRIVE\ProjectNavy\Test Page\doctopdf\hello.docx"
  9. out_file = "G:\CSE DRIVE\ProjectNavy\Test Page\doctopdf\output.pdf"
  10.  
  11. word = comtypes.client.CreateObject('Word.Application')
  12. doc = word.Documents.Open(in_file)
  13. doc.SaveAs(out_file, FileFormat=wdFormatPDF)
  14. doc.Close()
  15. word.Quit()
  16. webbrowser.open_new(r'G:\CSE DRIVE\ProjectNavy\Test Page\doctopdf\output.pdf')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement