cd ./GroupDocs.Parser-for-Python-via-.NET/Examples
Install the necessary packages:
pip install -r requirements.txt
Run the examples:
python run_all_examples.py
Each example is a separate script in a folder that mirrors this documentation, next to its input files, so you can also run one on its own from its folder, for example cd developer-guide/basic-usage/extract-text-from-documents and then python example-1.py. Set GROUPDOCS_LIC_PATH to your licence file first to run them without the evaluation limits.
Build project from scratch
If you prefer to create a project from scratch, follow these steps:
Step 1: Install GroupDocs.Parser
Install GroupDocs.Parser for Python via .NET using pip:
pip install groupdocs-parser-net
Step 2: Create a Python Script
Create a new Python file (e.g., example.py) and add the following code:
fromgroupdocs.parserimportParser# Create an instance of Parser classwithParser("./sample.docx")asparser:# Extract text from the documenttext_reader=parser.get_text()iftext_readerisNone:print("Text extraction isn't supported for this format")else:# Print the extracted textprint(text_reader.read_to_end())
The following sample file is used in this example: sample.docx
The following sample file is used in this example: sample.docx
Extract Images
fromgroupdocs.parserimportParserwithParser("./sample.pdf")asparser:images=parser.get_images()ifimagesisnotNone:print(f"Found {len(images)} images")fori,imageinenumerate(images,start=1):# The extension includes the dot, e.g. ".jpeg"image.save(f"image_{i}{image.file_type.extension}")
The following sample file is used in this example: sample.pdf
Contribute
If you like to add or improve an example, we encourage you to contribute to the project. All examples in this repository are open-source and can be freely used in your own applications.
To contribute, you can fork the repository, edit the source code and create a pull request. We will review the changes and include them in the repository if found helpful.
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.
On this page
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.