This example project demonstrates how to use the Nutrient DWS Python Client for document processing operations.
assets/- Contains sample files for processing (PDF, DOCX, PNG)src/- Contains Python source filesdirect_method.py- Examples using direct method callsworkflow.py- Examples using the workflow builder patternframework_openai_agents.py- OpenAI Agents SDK integration sketchframework_langchain.py- LangChain/LangGraph integration sketchframework_crewai.py- CrewAI integration sketch
output/- Directory where processed files will be saved.env.example- Example environment variables file
- Python 3.10 or higher
- pip
-
Clone the repository:
git clone https://github.com/pspdfkit-labs/nutrient-dws-client-python.git cd nutrient-dws-client-python -
Build the package from source:
python -m build
-
Navigate to the examples directory:
cd examples -
Set up and activate the virtual environment:
# Set up the virtual environment and install dependencies python setup_venv.py # Activate the virtual environment # On macOS/Linux: source example_venv/bin/activate # On Windows: example_venv\Scripts\activate
-
Create a
.envfile from the example:cp .env.example .env
-
Edit the
.envfile and add your Nutrient DWS Processor API key. You can sign up for a free API key by visiting Nutrient:NUTRIENT_API_KEY=your_api_key_here
-
Clone the repository:
git clone https://github.com/pspdfkit-labs/nutrient-dws-client-python.git cd nutrient-dws-client-python -
Install the main package in development mode:
pip install -e . -
Navigate to the examples directory:
cd examples -
Install dependencies for the example project:
pip install -r requirements.txt
-
Create a
.envfile from the example:cp .env.example .env
-
Edit the
.envfile and add your Nutrient DWS Processor API key. You can sign up for a free API key by visiting Nutrient:NUTRIENT_API_KEY=your_api_key_here
To run the direct method examples:
python src/direct_method.pyThis will:
- Convert a DOCX file to PDF
- Extract text from the PDF
- Add a watermark to the PDF
- Merge multiple documents
To run the workflow examples:
python src/workflow.pyThis will:
- Perform a basic document conversion workflow
- Create a document merging with watermark workflow
- Extract text with JSON output
- Execute a complex multi-step workflow
These examples are intentionally minimal and focus on framework wiring:
Install optional framework dependencies first:
pip install openai-agents langchain langchain-openai langgraph crewaipython src/framework_openai_agents.py
python src/framework_langchain.py
python src/framework_crewai.pySyntax-check only:
python -m py_compile src/framework_openai_agents.py
python -m py_compile src/framework_langchain.py
python -m py_compile src/framework_crewai.pyAll processed files will be saved to the output/ directory. You can examine these files to see the results of the document processing operations.
For more information about the Nutrient DWS Python Client, refer to:
- README.md - Main documentation
- METHODS.md - Direct methods documentation
- WORKFLOW.md - Workflow system documentation