office-export 0.1.0__tar.gz
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.
- office_export-0.1.0/.gitignore +14 -0
- office_export-0.1.0/CHANGELOG.md +13 -0
- office_export-0.1.0/LICENSE +21 -0
- office_export-0.1.0/PKG-INFO +263 -0
- office_export-0.1.0/PLAN.md +854 -0
- office_export-0.1.0/README.md +232 -0
- office_export-0.1.0/THIRD_PARTY_NOTICES.md +21 -0
- office_export-0.1.0/pyproject.toml +78 -0
- office_export-0.1.0/src/office_export/__init__.py +3 -0
- office_export-0.1.0/src/office_export/__main__.py +6 -0
- office_export-0.1.0/src/office_export/cli.py +577 -0
- office_export-0.1.0/src/office_export/core.py +863 -0
- office_export-0.1.0/src/office_export/doctor.py +154 -0
- office_export-0.1.0/src/office_export/errors.py +70 -0
- office_export-0.1.0/src/office_export/naming.py +92 -0
- office_export-0.1.0/src/office_export/office_adapters.py +599 -0
- office_export-0.1.0/src/office_export/publishing.py +103 -0
- office_export-0.1.0/src/office_export/rasterizer.py +264 -0
- office_export-0.1.0/src/office_export/results.py +85 -0
- office_export-0.1.0/src/office_export/selectors.py +97 -0
- office_export-0.1.0/src/office_export/skill.py +150 -0
- office_export-0.1.0/src/office_export/worker.py +532 -0
- office_export-0.1.0/src/office_export/worker_protocol.py +191 -0
- office_export-0.1.0/tests/conftest.py +17 -0
- office_export-0.1.0/tests/test_cli.py +85 -0
- office_export-0.1.0/tests/test_core_pdf.py +84 -0
- office_export-0.1.0/tests/test_metadata.py +30 -0
- office_export-0.1.0/tests/test_naming.py +39 -0
- office_export-0.1.0/tests/test_office_adapters.py +56 -0
- office_export-0.1.0/tests/test_office_integration.py +239 -0
- office_export-0.1.0/tests/test_publishing.py +59 -0
- office_export-0.1.0/tests/test_rasterizer.py +82 -0
- office_export-0.1.0/tests/test_selectors.py +38 -0
- office_export-0.1.0/tests/test_skill.py +48 -0
- office_export-0.1.0/tests/test_worker.py +65 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
- Export Word, Excel, and PowerPoint documents through desktop Microsoft Office on Windows.
|
|
6
|
+
- Produce native PDF output plus PNG and JPEG images rendered through PDFium.
|
|
7
|
+
- Rasterize PDF inputs without requiring Office.
|
|
8
|
+
- Inspect supported documents and report stable JSON results.
|
|
9
|
+
- Select Word pages, PowerPoint slides, Excel sheets, ranges, and charts.
|
|
10
|
+
- Apply safe defaults for macros, external links, data refresh, recalculation, and source writes.
|
|
11
|
+
- Isolate Office automation in a worker subprocess with timeouts and owned-process cleanup.
|
|
12
|
+
- Add sequential batch conversion, capability diagnostics, deterministic output naming, and optional manifests.
|
|
13
|
+
- Add managed `skill install` and `skill remove` commands for coding agents.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 John Paul Ellis
|
|
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.
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: office-export
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Export Microsoft Office documents to PDF and images through desktop Office
|
|
5
|
+
Project-URL: Homepage, https://github.com/pseudosavant/office-export
|
|
6
|
+
Project-URL: Repository, https://github.com/pseudosavant/office-export
|
|
7
|
+
Project-URL: Issues, https://github.com/pseudosavant/office-export/issues
|
|
8
|
+
Project-URL: Releases, https://github.com/pseudosavant/office-export/releases
|
|
9
|
+
Author: John Paul Ellis
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
License-File: THIRD_PARTY_NOTICES.md
|
|
13
|
+
Keywords: cli,excel,jpeg,office,pdf,png,powerpoint,word
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Environment :: Console
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
|
|
25
|
+
Classifier: Topic :: Office/Business :: Office Suites
|
|
26
|
+
Requires-Python: >=3.11
|
|
27
|
+
Requires-Dist: pillow<13,>=11
|
|
28
|
+
Requires-Dist: pypdfium2<6,>=5.13
|
|
29
|
+
Requires-Dist: pywin32>=311; sys_platform == 'win32'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# office-export
|
|
33
|
+
|
|
34
|
+
`office-export` is a Windows-first Python CLI that exports Word, Excel, and PowerPoint documents through the installed desktop Microsoft Office applications. It creates native PDFs and consistent PNG or JPEG images. It can also rasterize PDF inputs without Office.
|
|
35
|
+
|
|
36
|
+
The core promise is faithful local rendering through the same Office applications that users rely on in the desktop UI. The CLI is designed for people, scripts, and coding agents.
|
|
37
|
+
|
|
38
|
+
## Requirements
|
|
39
|
+
|
|
40
|
+
Office document export supports:
|
|
41
|
+
|
|
42
|
+
- Windows 11
|
|
43
|
+
- Microsoft 365 Apps desktop applications
|
|
44
|
+
- Office 2024 and Office LTSC 2024
|
|
45
|
+
- CPython 3.11 or newer
|
|
46
|
+
- `uv` and `uvx`
|
|
47
|
+
|
|
48
|
+
Office LTSC 2021 and older desktop releases are best effort. The CLI probes capabilities instead of rejecting an application only because of its version number.
|
|
49
|
+
|
|
50
|
+
Direct PDF rasterization works on any supported Python platform that has a compatible `pypdfium2` wheel. Word, Excel, and PowerPoint are not required for PDF input.
|
|
51
|
+
|
|
52
|
+
This tool is intended for an interactive Windows user profile. It is not a server-side Office conversion service. First-run setup, modal dialogs, add-ins, Protected View, or an uninitialized Office license can block automation.
|
|
53
|
+
|
|
54
|
+
## Install and run
|
|
55
|
+
|
|
56
|
+
Run the published package without a permanent installation:
|
|
57
|
+
|
|
58
|
+
```powershell
|
|
59
|
+
uvx office-export --version
|
|
60
|
+
uvx office-export doctor
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Run a local checkout during development:
|
|
64
|
+
|
|
65
|
+
```powershell
|
|
66
|
+
$env:UV_LINK_MODE="copy"
|
|
67
|
+
uvx --refresh --from . office-export --version
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Export documents
|
|
71
|
+
|
|
72
|
+
```powershell
|
|
73
|
+
uvx office-export report.docx --to pdf
|
|
74
|
+
uvx office-export report.docx --to png --pages 1,3-5 --dpi 200
|
|
75
|
+
uvx office-export deck.pptx --to jpeg --slides 2-6 --dpi 200
|
|
76
|
+
uvx office-export model.xlsx --to pdf --sheet Summary --sheet "Q4 Charts"
|
|
77
|
+
uvx office-export model.xlsx --to png --range "Summary!A1:H40"
|
|
78
|
+
uvx office-export document.pdf --to jpeg --pages 1,3-5 --dpi 300
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Use `--output PATH` to override the destination. Use `--force` to replace only the output files planned for the current conversion.
|
|
82
|
+
|
|
83
|
+
### Default output names
|
|
84
|
+
|
|
85
|
+
- PDF is written beside the input as `<name>.pdf`.
|
|
86
|
+
- PNG files are written to `<name> - PNG export`.
|
|
87
|
+
- JPEG files are written to `<name> - JPEG export`.
|
|
88
|
+
|
|
89
|
+
Image names retain their logical source identity:
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
report-page-001.png
|
|
93
|
+
deck-slide-003.jpg
|
|
94
|
+
model-sheet-summary-page-001.png
|
|
95
|
+
model-sheet-summary-chart-revenue.png
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Image output always uses a directory by default. An explicit image filename is accepted when the selection produces exactly one image.
|
|
99
|
+
|
|
100
|
+
## Word
|
|
101
|
+
|
|
102
|
+
```powershell
|
|
103
|
+
uvx office-export report.docx --to pdf --bookmarks headings
|
|
104
|
+
uvx office-export report.docx --to pdf --pages 2-5 --include-markup
|
|
105
|
+
uvx office-export report.docx --to png --pages 1,4,7
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Word PDF bookmarks can come from headings, explicit Word bookmarks, or neither. The default is `headings`. The tool updates each table of contents in memory before export without saving the source. Use `--no-update-toc` to preserve the currently displayed values and pagination.
|
|
109
|
+
|
|
110
|
+
Contiguous page selection uses Word's native fixed-format range. Noncontiguous Word pages are supported for image output by rasterizing selected pages from a complete temporary PDF. Noncontiguous Word PDF output is rejected because combining PDFs can damage tags, links, destinations, metadata, and bookmarks.
|
|
111
|
+
|
|
112
|
+
## PowerPoint
|
|
113
|
+
|
|
114
|
+
```powershell
|
|
115
|
+
uvx office-export deck.pptx --to pdf --slides 1,3-5
|
|
116
|
+
uvx office-export deck.pptx --to png --output-type notes
|
|
117
|
+
uvx office-export deck.pptx --to pdf --output-type handout6
|
|
118
|
+
uvx office-export deck.pptx --to png --image-engine office
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The default PDFium image engine renders the Office-created PDF. It provides consistent DPI, encoding, annotation, selection, notes, and handout behavior. The optional Office image engine calls PowerPoint's native slide export. It supports slide output only.
|
|
122
|
+
|
|
123
|
+
Inspection reports both one-based slide positions and stable PowerPoint slide IDs.
|
|
124
|
+
|
|
125
|
+
## Excel
|
|
126
|
+
|
|
127
|
+
```powershell
|
|
128
|
+
uvx office-export model.xlsx --to pdf --sheet Summary --sheet "Q4 Charts"
|
|
129
|
+
uvx office-export model.xlsx --to png --range "Summary!A1:H40"
|
|
130
|
+
uvx office-export model.xlsx --to png --charts all
|
|
131
|
+
uvx office-export model.xlsx --to jpeg --chart "Dashboard!Margin" --jpeg-quality 95
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Repeated `--sheet` values accept exact names or one-based positions. A range uses `SHEET!ADDRESS` syntax. Excel chart selection creates one tightly bounded native chart image. JPEG charts are converted from Excel's temporary PNG so quality and background handling stay deterministic.
|
|
135
|
+
|
|
136
|
+
`--dpi` does not apply to native chart export. Chart dimensions come from the workbook. Excel can lose internal workbook links during native PDF conversion. External links emitted by Excel remain subject to Excel's own behavior.
|
|
137
|
+
|
|
138
|
+
The following options intentionally change how workbook content is evaluated:
|
|
139
|
+
|
|
140
|
+
- `--recalculate auto|full`
|
|
141
|
+
- `--update-links`
|
|
142
|
+
- `--refresh-data`
|
|
143
|
+
|
|
144
|
+
They are disabled by default.
|
|
145
|
+
|
|
146
|
+
## PDF input
|
|
147
|
+
|
|
148
|
+
```powershell
|
|
149
|
+
uvx office-export document.pdf --to png
|
|
150
|
+
uvx office-export document.pdf --to jpeg --pages 1,3-5 --dpi 300
|
|
151
|
+
uvx office-export document.pdf --to png --exclude-annotations
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
PDF input supports PNG and JPEG output in version 0.1.0. PDF-to-PDF rewriting is not supported. Physical page selectors are one-based. `inspect` also reports page labels when the PDF contains them.
|
|
155
|
+
|
|
156
|
+
Visible annotations and standard form appearances are rendered by default. `--exclude-annotations` also excludes form widget appearances. Dynamic XFA content produces a warning. Password-protected, encrypted, or permission-restricted PDFs are rejected.
|
|
157
|
+
|
|
158
|
+
Defaults:
|
|
159
|
+
|
|
160
|
+
- 150 DPI
|
|
161
|
+
- JPEG quality 92
|
|
162
|
+
- White JPEG background
|
|
163
|
+
- 50 megapixels per page
|
|
164
|
+
|
|
165
|
+
Use `--max-megapixels` only after reviewing the memory cost of the requested page size and DPI.
|
|
166
|
+
|
|
167
|
+
## Inspect and diagnose
|
|
168
|
+
|
|
169
|
+
```powershell
|
|
170
|
+
uvx office-export inspect report.docx --json
|
|
171
|
+
uvx office-export inspect deck.pptx --json
|
|
172
|
+
uvx office-export inspect model.xlsx --json
|
|
173
|
+
uvx office-export inspect document.pdf --json
|
|
174
|
+
uvx office-export doctor --json
|
|
175
|
+
uvx office-export doctor --smoke-word report.docx --smoke-excel model.xlsx --smoke-powerpoint deck.pptx --json
|
|
176
|
+
uvx office-export formats --json
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
`doctor` reports each Office application separately from PDFium. It also reports the Office version, bitness, active printer when available, Print Spooler state, installed printers, dependency versions, and temporary-directory access.
|
|
180
|
+
|
|
181
|
+
Smoke exports are opt-in. Supply one or more known local fixtures with `--smoke-word`, `--smoke-excel`, or `--smoke-powerpoint`.
|
|
182
|
+
|
|
183
|
+
## JSON and manifests
|
|
184
|
+
|
|
185
|
+
Add `--json` to print a stable result object to stdout. Diagnostics stay on stderr. A successful conversion includes:
|
|
186
|
+
|
|
187
|
+
- Tool and schema versions
|
|
188
|
+
- Source size and SHA-256 hash
|
|
189
|
+
- Office application and version
|
|
190
|
+
- Active printer when relevant
|
|
191
|
+
- Effective options and warnings
|
|
192
|
+
- PDFium and Pillow versions
|
|
193
|
+
- Output paths, sizes, and SHA-256 hashes
|
|
194
|
+
- Logical source-to-output mappings
|
|
195
|
+
- Duration
|
|
196
|
+
|
|
197
|
+
Use `--manifest PATH` to persist the same result. Failed conversions also write a structured failure manifest when the requested manifest path is safe and writable. No sidecar manifest is created by default.
|
|
198
|
+
|
|
199
|
+
## Batch conversion
|
|
200
|
+
|
|
201
|
+
```powershell
|
|
202
|
+
uvx office-export batch .\incoming --to pdf
|
|
203
|
+
uvx office-export batch .\incoming --to png --recursive --continue-on-error --json
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Version 0.1.0 processes files sequentially and accepts only `--jobs 1`. Each Office source gets a fresh worker process and an isolated temporary directory.
|
|
207
|
+
|
|
208
|
+
## Agent skill
|
|
209
|
+
|
|
210
|
+
Install the bundled managed skill:
|
|
211
|
+
|
|
212
|
+
```powershell
|
|
213
|
+
uvx office-export skill install
|
|
214
|
+
uvx office-export skill install --skills-dir C:\custom\skills
|
|
215
|
+
uvx office-export skill remove
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
The default target is `~/.agents/skills/office-export/SKILL.md`. Installation is idempotent and updates stale managed content. Installation and removal refuse unmanaged content unless `--force` is explicitly supplied.
|
|
219
|
+
|
|
220
|
+
The skill teaches agents to run diagnostics, inspect before selecting, export with JSON, review representative images, report exact paths and warnings, and preserve safe defaults.
|
|
221
|
+
|
|
222
|
+
## Safety model
|
|
223
|
+
|
|
224
|
+
- Sources open read-only.
|
|
225
|
+
- VBA macros are force-disabled.
|
|
226
|
+
- AutoOpen and Auto_Open macros are not executed.
|
|
227
|
+
- External links do not update by default.
|
|
228
|
+
- Data connections do not refresh by default.
|
|
229
|
+
- Workbooks do not recalculate by default.
|
|
230
|
+
- Source changes are never saved.
|
|
231
|
+
- Passwords, Protected View, IRM, sensitivity restrictions, and PDF permissions are not bypassed.
|
|
232
|
+
- Final outputs are published only after conversion validation.
|
|
233
|
+
- A timeout can terminate only an Office process proven to have been created by the isolated worker.
|
|
234
|
+
- A pre-existing user Office process is never quit or terminated.
|
|
235
|
+
|
|
236
|
+
Office automation is not a security sandbox. Do not use it to open untrusted documents outside the protections of your Windows and Office environment.
|
|
237
|
+
|
|
238
|
+
## Development
|
|
239
|
+
|
|
240
|
+
```powershell
|
|
241
|
+
$env:UV_LINK_MODE="copy"
|
|
242
|
+
uv sync --all-groups
|
|
243
|
+
uv run ruff check .
|
|
244
|
+
uv run ruff format --check .
|
|
245
|
+
uv run pytest
|
|
246
|
+
uv run pytest -m office
|
|
247
|
+
uv build
|
|
248
|
+
uv run twine check dist/*
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
The default test run is cross-platform and excludes tests that require licensed desktop Office. Run the `office` marker in an interactive Windows session before release.
|
|
252
|
+
|
|
253
|
+
## Known native limitations
|
|
254
|
+
|
|
255
|
+
- Office rendering can vary with Office updates, installed fonts, document compatibility settings, and printer metrics.
|
|
256
|
+
- Excel internal workbook links can be lost in native PDF output.
|
|
257
|
+
- PowerPoint-native images can differ slightly from PDFium images.
|
|
258
|
+
- Dynamic XFA forms may not match a full PDF viewer.
|
|
259
|
+
- Modal Office dialogs and add-ins can still interfere with automation.
|
|
260
|
+
|
|
261
|
+
## License
|
|
262
|
+
|
|
263
|
+
MIT. See [LICENSE](LICENSE) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|