How to convert a .pptx to .pdf using Python

前端 未结 5 588
我寻月下人不归
我寻月下人不归 2021-02-05 22:53

I have been looking to convert a .pptx file to a .pdf file through a Python script for several hours but nothing seems to be working.

What I have tried:

5条回答
  •  梦毁少年i
    2021-02-05 23:02

    Have a look at the following snippet. It uses unoconv and it's working ex expected on UBUNTU 20.04.

    # requirements
    # sudo apt install unoconv
    # pip install tqdm
    # pip install glob
    import glob
    import tqdm
    path = ""
    extension = "pptx"
    files = [f for f in glob.glob(path + "/**/*.{}".format(extension), recursive=True)]
    for f in tqdm.tqdm(files):
        command = "unoconv -f pdf \"{}\"".format(f)
        os.system(command)
    

    This snippet can be used for different-2 format conversion.

    Original Snippet

提交回复
热议问题