PowerPoint to PDF Converter
This is a Python script that converts PowerPoint files (.ppt, .pptx) to PDF format. It uses the comtypes library to interact with Microsoft PowerPoint.
Prerequisites
- Python 3.6 or above
Dependancies
- comtypes library
Usage
Run the script with the following arguments i.e pptxtopdf --input_dir "C:\Users\Example\Downloads\input":
--input_file: Path to the folder containing the PowerPoint files to convert.--input_dir: Path to the folder containing the PowerPoint files to convert.--output_dir: [Optional] Path to the folder where the converted PDF files will be saved. If not provided, it defaults to the same directory as the input file or directory.
Example from command line
pptxtopdf --input_dir ./input --output_dir ./output
This command will convert all the PowerPoint files in the ./input folder and save the converted PDF files in the ./output folder.
Example in script
from pptxtopdf import convert
input_dir = r"C:\Users\Example\ExampleDirectory"
output_dir = r"C:\Users\Example\ExampleDirectory"
convert(input_dir, output_dir)
Functionality
The script performs the following steps:
- Validates the input folder path and checks if it exists.
- Creates the output folder if it does not already exist.
- Lists all the files in the input folder.
- Iterates over each file and checks if it has a PowerPoint extension.
- Creates a PowerPoint application object using comtypes.
- Opens the PowerPoint slides.
- Retrieves the base file name.
- Constructs the output file path with the PDF extension.
- Checks if the output file already exists and skips the conversion if it does.
- Saves the slides as a PDF file.
- Closes the slide deck.
- Quits PowerPoint.
- Keeps track of the successful conversions and errors.
- Prints a summary of the conversion process at the end.
Note: The script runs without a user interface (WithWindow=False) to perform the conversions silently.
Error Handling
If any error occurs during the conversion process, the script will catch the exception and print an error message specifying the file that caused the error.
License
This script is released under the MIT License. Feel free to modify and use it according to your needs.
Metadata
Release files for pptxtopdf 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pptxtopdf-0.0.2.tar.gz | 4.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pptxtopdf-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.9 kB
Release files / pptxtopdf-0.0.2.tar.gz
| Download URL | pptxtopdf-0.0.2.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6463703de7a3ee221879819ea829d9bf11812188debdad9a80eccc4c6273f2f6
|
|
BLAKE2b-256 checksum How to use checksums |
904699f4ad0ba9d69b5e700676344d62ded49ff16cead01edca9e6860911981c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Release files / pptxtopdf-0.0.2-py3-none-any.whl
| Download URL | pptxtopdf-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d0cb06785d018891126e4070a563bf0eea0993235019b003700f26b9cde047bf
|
|
BLAKE2b-256 checksum How to use checksums |
b1539a321e51f9d1acb0932b416092b908e0c5702292e0c9eac44e0fb1084b60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Security for pptxtopdf 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.