SoFunction
Updated on 2024-11-19

python3 how to convert docx to pdf file

In this paper, we share the example of python3 will be converted to pdf file docx specific code for your reference, the specific content is as follows

Straight to the code.

# -*- encoding:utf-8 -*-
"""
  author:lgh
"""

from  import Dispatch, constants, gencache

def doc2pdf(input, output):
  w = Dispatch('')
  try:
    # Open the file
    doc = (input, ReadOnly=1)
    # Convert files
    (output, ,
                Item=, CreateBookmarks = )
    return True
  except:
    return False
  finally:
    ()

def GenerateSupport():
  ('{00020905-0000-0000-C000-000000000046}', 0, 8, 4)

def main():
  input = r'xxx\'
  output = r'xxx\'
  # GenerateSupport()
  rc = doc2pdf(input, output)
  if rc:
    print('Conversion successful')
  else:
    print('Conversion failed')

if __name__ == '__main__':
  main()

This is the whole content of this article.