Welcome to the Developer Guide for GroupDocs.Conversion for Python via .NET. This section provides practical code examples designed to help you quickly integrate and use the GroupDocs.Conversion API in your projects.
Prerequisites
Before proceeding, please review the following topics:
Each code example in this guide is provided as a standalone script that you can copy directly into a .py file. You’ll find the instructions for running code examples below.
Sample Files
Alongside each code example, you will find source and output files that you can download for reference. These output files demonstrate the actual results you can achieve with GroupDocs.Conversion when using a valid license.
Source files are provided as the input files used in each example.
Output files are generated after conversion and are available for download without evaluation watermarks. A valid license was applied during the conversion process by setting the license path through the environment variable GROUPDOCS_LIC_PATH.
How to Run a Code Example
This topic explains how to run a code example from the Developer Guide section. We will demonstrate the process using the Load File From Local Disk example, but the steps are the same for any example you choose.
Step 1: Create a folder
Create a folder by typing mkdir load-file-from-local-disk in your terminal and navigate into it with cd load-file-from-local-disk.
Step 2: Create and activate a virtual environment
We recommend using a virtual environment to manage dependencies in Python applications. Learn more about virtual environments in the Create and Use Virtual Environments documentation topic.
Create a file named convert_to_pdf.py and copy in the code example:
fromgroupdocs.conversionimportConverterfromgroupdocs.conversion.options.convertimportPdfConvertOptionsdefconvert_to_pdf():# Specify source file locationconverter=Converter("./business-plan.docx")# Specify output file location and convert optionsoutput_path="./business-plan.pdf"pdf_options=PdfConvertOptions()# Convert and save to output pathconverter.convert(output_path,pdf_options)if__name__=="__main__":convert_to_pdf()
Step 6: Copy the input file
Download the input file business-plan.docx and copy it into the folder.
Step 7: Run the example code
In your terminal, run the following command:
pyconvert_to_pdf.py
python3convert_to_pdf.py
Check for the output file business-plan.pdf in the current directory.
Troubleshooting
If you encounter any issues while running the examples: