GroupDocs.Signature for Python via .NET Linux support is currently limited. Please check the System Requirements page for the latest supported platforms. Full Linux support will be available in upcoming releases.
This guide demonstrates how to use GroupDocs.Signature for Python via .NET in a Docker container, assuming Linux support is available in your version.
Dependencies
When using the GroupDocs Python SDK in a Linux environment, make sure the following packages are installed, as they are required for proper library operation:
libicu β ICU library (must not exceed version 70)
libssl1.1 β OpenSSL library required by .NET Core 3.1
Basic Example
This is the most basic example that shows how to run GroupDocs.Signature for Python via .NET in Docker. The example demonstrates how to sign a PDF file with a text signature using GroupDocs.Signature in a Docker container.
Note
You can download this sample application from here.
Project Structure
The sample application has the following folder structure:
π basic-example/
βββ π output/ # Output directory for signed files
βββ π .dockerignore # Files to exclude from Docker build context
βββ π sample.pdf # Sample input document to sign
βββ π Dockerfile # Docker container definition
βββ π GroupDocs.Signature.PythonViaNET.lic # License file (optional)
βββ π sign_pdf_with_text.py # Main application code
βββ π README.md # Build and run instructions
βββ π requirements.txt # Application dependencies
We’re using a Python 3.11 slim image and installing required .NET dependencies libicu and libssl1.1 manually.
Here are the most essential parts:
# Use Python 3.11 slim base image which is smaller than the default base imageFROM python:3.11-slim# Install prerequisites from a reliable sourceENVSNAPSHOT_DATE=20220328T000000Z
RUNecho"deb [trusted=yes] http://snapshot.debian.org/archive/debian/${SNAPSHOT_DATE} bullseye main"\
> /etc/apt/sources.list.d/debian-archive.list &&\
apt-get -o Acquire::Check-Valid-Until=false update &&\
apt-get install -y --no-install-recommends \
libicu67 \
libssl1.1 &&\
apt-get clean &&\
rm -rf /var/lib/apt/lists/*# Set workdir WORKDIR /app# Install Python dependenciesCOPY requirements.txt ./RUN pip install -r requirements.txt# Copy the rest of the appCOPY . .# Run the appCMD["python","sign_pdf_with_text.py"]
importosimportgroupdocs.signatureasgsimportgroupdocs.signature.optionsasgsodefsign_pdf_with_text_signature():# Get license file absolute pathlicense_path=os.path.abspath("./GroupDocs.Signature.PythonViaNET.lic")ifos.path.exists(license_path):# Create License and set the pathlicense=gs.License()license.set_license(license_path)# Ensure output directory existsos.makedirs("./output",exist_ok=True)# The path to the input PDF filesample_pdf="./sample.pdf"# The path to the output directoryoutput_file_path="./output/signed_sample.pdf"# Sign document with text signaturewithgs.Signature(sample_pdf)assignature:text_sign_options=gso.TextSignOptions("Hello from Docker!")signature.sign(output_file_path,text_sign_options)print(f"\nSource document signed successfully.\nFile saved at {output_file_path}")if__name__=="__main__":sign_pdf_with_text_signature()
In case you experience any other exceptions when running the application please contact us using the GroupDocs Free Support Forum and we’ll be happy to help.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.