aspose-words-docling 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aspose_words_docling/__about__.py +3 -0
- aspose_words_docling/__init__.py +14 -0
- aspose_words_docling/aspose_words_converter.py +47 -0
- aspose_words_docling/py.typed +0 -0
- aspose_words_docling-0.1.1.dist-info/METADATA +124 -0
- aspose_words_docling-0.1.1.dist-info/RECORD +8 -0
- aspose_words_docling-0.1.1.dist-info/WHEEL +4 -0
- aspose_words_docling-0.1.1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026-Aspose Pty Ltd
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
from .aspose_words_converter import (
|
|
5
|
+
AsposeWordsConverter, LicenseManager
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
from .__about__ import __version__
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"__version__",
|
|
12
|
+
"AsposeWordsConverter",
|
|
13
|
+
"LicenseManager"
|
|
14
|
+
]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Copyright (c) 2001-2026 Aspose Pty Ltd.
|
|
2
|
+
|
|
3
|
+
from io import BytesIO
|
|
4
|
+
import json, os, logging
|
|
5
|
+
from docling_core.types.doc.document import DoclingDocument
|
|
6
|
+
|
|
7
|
+
import aspose.words as aw
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AsposeWordsConverter:
|
|
11
|
+
def convert(self, file: str) -> DoclingDocument:
|
|
12
|
+
license_manager = LicenseManager()
|
|
13
|
+
license_manager.apply_license()
|
|
14
|
+
|
|
15
|
+
aspose_doc = aw.Document(file)
|
|
16
|
+
aspose_doc.update_list_labels()
|
|
17
|
+
buffer = BytesIO()
|
|
18
|
+
save_options = aw.saving.DoclingSaveOptions()
|
|
19
|
+
aspose_doc.save(buffer, save_options)
|
|
20
|
+
doc_dict = json.loads(buffer.getvalue())
|
|
21
|
+
origin = doc_dict.get("origin")
|
|
22
|
+
if origin is not None:
|
|
23
|
+
mimetype = origin.get("mimetype")
|
|
24
|
+
# Docling doesn't support such mime types.
|
|
25
|
+
if (mimetype == "application/rtf" or mimetype == "multipart/related"):
|
|
26
|
+
origin["mimetype"] = "text/plain"
|
|
27
|
+
|
|
28
|
+
docling_doc = DoclingDocument.model_validate(doc_dict)
|
|
29
|
+
return docling_doc
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
""" To activate your Aspose License, set the corresponding environment variable.
|
|
33
|
+
Refer to the OS-specific instructions below:
|
|
34
|
+
Unix-based (Linux/macOS):
|
|
35
|
+
export ASPOSE_WORDS_LICENSE_PATH="/path/to/license/aspose.words.lic"
|
|
36
|
+
Windows-based:
|
|
37
|
+
set ASPOSE_WORDS_LICENSE_PATH=c:\\path\\to\\license\\aspose.words.lic """
|
|
38
|
+
class LicenseManager:
|
|
39
|
+
def apply_license(self, license_path: str = None):
|
|
40
|
+
if license_path is None:
|
|
41
|
+
license_path = os.getenv("ASPOSE_WORDS_LICENSE_PATH")
|
|
42
|
+
if license_path is not None and os.path.exists(license_path):
|
|
43
|
+
logging.info(f"Applying Aspose.Words license from: {license_path}")
|
|
44
|
+
license = aw.License()
|
|
45
|
+
license.set_license(license_path)
|
|
46
|
+
else:
|
|
47
|
+
logging.warning("No valid Aspose.Words license found. Running in Evaluation mode. Please set the ASPOSE_WORDS_LICENSE_PATH environment variable.")
|
|
File without changes
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aspose-words-docling
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Aspose.Words plugin for Docling
|
|
5
|
+
Project-URL: Documentation, https://github.com/aspose-words/Aspose.Words-for-Docling#readme
|
|
6
|
+
Project-URL: Repository, https://github.com/aspose-words/Aspose.Words-for-Docling
|
|
7
|
+
Project-URL: Examples, https://github.com/aspose-words/Aspose.Words-for-Docling/blob/main/packages/aspose-words-docling/tests/test_aspose_backend.py
|
|
8
|
+
Project-URL: Free Support, https://forum.aspose.com/c/words/8
|
|
9
|
+
Author-email: Aspose <support@aspose.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: aspose,conversion,doc,docling,epub,mhtml,odt,pdf,plugin,rtf,word
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Requires-Python: >=3.13
|
|
17
|
+
Requires-Dist: aspose-words>=26.1.0
|
|
18
|
+
Requires-Dist: docling>=2.60.0
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# Aspose.Words for Docling
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
## Overview
|
|
27
|
+
**Aspose.Words for Docling** is a free plugin for [Docling](https://github.com/docling-project/docling) based on [Aspose.Words for Python via .Net](https://products.aspose.com/words/python-net/) commercial library.
|
|
28
|
+
The plugin is designed for parsing multiple document formats and converting them into Docling Documents suitable for AI processing.
|
|
29
|
+
**Aspose.Words** plugin allows you to convert formats as `.docx`, `.pdf`, `.doc`, `.rtf`, `.html`, `.mhtml`, `.mobi`, `.azw3`, `.epub`, `.odt`, `.txt`, `.md` and `.xml`.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- Convert `.docx`, `.pdf`, `.doc`, `.rtf`, `.html`, `.mhtml`, `.mobi`, `.azw3`, `.epub`, `.odt`, `.txt`, `.md` and `.xml` to [DoclingDocument](https://docling-project.github.io/docling/concepts/docling_document/).
|
|
35
|
+
- Support all document components, including paragraphs, tables, images, headers, and footers.
|
|
36
|
+
|
|
37
|
+
## Requirements
|
|
38
|
+
|
|
39
|
+
- [Docling](https://github.com/docling-project/docling) version 2.60.0 or higher.
|
|
40
|
+
- [Aspose.Words for Python via .Net](https://products.aspose.com/words/python-net/). This library is a [commercial product](https://purchase.aspose.com/buy/words/python).
|
|
41
|
+
You'll need to obtain a valid license for Aspose.Words. The package will install this dependency, but you're responsible for complying with Aspose's licensing terms.
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install aspose-words-docling
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Python API
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from aspose_words_docling import AsposeWordsConverter
|
|
53
|
+
|
|
54
|
+
aspose_converter = AsposeWordsConverter()
|
|
55
|
+
doc = aspose_converter.convert("test.doc")
|
|
56
|
+
|
|
57
|
+
md = doc.export_to_markdown()
|
|
58
|
+
print(md)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## Set License
|
|
63
|
+
|
|
64
|
+
### Environment Variables
|
|
65
|
+
To activate your Aspose.Words for Python license, set the corresponding environment variable.
|
|
66
|
+
Refer to the OS-specific instructions below:
|
|
67
|
+
|
|
68
|
+
**Unix-based (Linux/macOS):**
|
|
69
|
+
```
|
|
70
|
+
export ASPOSE_WORDS_LICENSE_PATH="/path/to/license/aspose.words.lic"
|
|
71
|
+
```
|
|
72
|
+
**Windows-based:**
|
|
73
|
+
```
|
|
74
|
+
set ASPOSE_WORDS_LICENSE_PATH=c:\path\to\license\aspose.words.lic
|
|
75
|
+
```
|
|
76
|
+
**Python API:**
|
|
77
|
+
```
|
|
78
|
+
from aspose_words_docling import LicenseManager
|
|
79
|
+
|
|
80
|
+
LicenseManager().apply_license("/path/to/license/aspose.words.lic")
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Running Tests
|
|
84
|
+
|
|
85
|
+
To run unit tests for **Aspose.Words for Docling**, follow these steps:
|
|
86
|
+
|
|
87
|
+
### 1. Navigate to the package directory
|
|
88
|
+
|
|
89
|
+
From the root of the repository, change into the package directory:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
cd /packages/aspose-words-docling/tests
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 2. Install test dependencies
|
|
96
|
+
|
|
97
|
+
Make sure `pytest` is installed:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
pip install pytest
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 3. Run tests using `pytest`
|
|
104
|
+
|
|
105
|
+
To run all tests:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pytest
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
This package is licensed under the MIT License. However, it depends on Aspose.Words for Python via .Net library, which is proprietary, closed-source library.
|
|
114
|
+
|
|
115
|
+
⚠️ You must obtain valid license for Aspose.Words for Python via .Net library. This repository does not include or distribute any proprietary components.
|
|
116
|
+
|
|
117
|
+
## Trademarks
|
|
118
|
+
|
|
119
|
+
This project may contain trademarks or logos for projects, products, or services. Authorized use of IBM
|
|
120
|
+
trademarks or logos is subject to and must follow
|
|
121
|
+
[IBM's Trademarks](https://www.ibm.com/legal/copyright-trademark).
|
|
122
|
+
[IBM Logo and Brand Guidelines](https://www.ibm.com/design/language/files/IBM_Logo_3rdParties_300822.pdf).
|
|
123
|
+
Use of IBM trademarks or logos in modified versions of this project must not cause confusion or imply IBM sponsorship.
|
|
124
|
+
Any use of third-party trademarks or logos are subject to those third-party's policies.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
aspose_words_docling/__about__.py,sha256=NhRcI7y5OmKaA0sJgpxnJUPbYXJb_guZ5lWGli61jSc,102
|
|
2
|
+
aspose_words_docling/__init__.py,sha256=n3efTQA80zJbH9kfZvZuyFCbuiL9B8MjNB-BED0TJBY,292
|
|
3
|
+
aspose_words_docling/aspose_words_converter.py,sha256=rxs_SooKK5DhaYfLbBIybqUBmYjw-qNrUySEhCQPqT4,1956
|
|
4
|
+
aspose_words_docling/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
aspose_words_docling-0.1.1.dist-info/METADATA,sha256=8leJS-a9FZE_8zQkdczC0uE8p-mMObyNM2ZFd9x7pDo,4482
|
|
6
|
+
aspose_words_docling-0.1.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
7
|
+
aspose_words_docling-0.1.1.dist-info/licenses/LICENSE,sha256=QSZCFYZxbZBYb9MYRIvjLaleXR3Gt6G5q7Ml_YX9Zhw,1097
|
|
8
|
+
aspose_words_docling-0.1.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Aspose Pty Ltd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|