betteroffice-docx 0.0.1__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.
- betteroffice_docx-0.0.1/Cargo.toml +53 -0
- betteroffice_docx-0.0.1/LICENSE +201 -0
- betteroffice_docx-0.0.1/NOTICE +2 -0
- betteroffice_docx-0.0.1/PKG-INFO +242 -0
- betteroffice_docx-0.0.1/README.md +207 -0
- betteroffice_docx-0.0.1/THIRD-PARTY-NOTICES.md +9 -0
- betteroffice_docx-0.0.1/bindings/Cargo.lock +1358 -0
- betteroffice_docx-0.0.1/bindings/Cargo.toml +7 -0
- betteroffice_docx-0.0.1/bindings/python-common/Cargo.toml +13 -0
- betteroffice_docx-0.0.1/bindings/python-common/src/lib.rs +26 -0
- betteroffice_docx-0.0.1/bindings/python-docx/Cargo.toml +20 -0
- betteroffice_docx-0.0.1/bindings/python-docx/LICENSE +201 -0
- betteroffice_docx-0.0.1/bindings/python-docx/NOTICE +2 -0
- betteroffice_docx-0.0.1/bindings/python-docx/README.md +207 -0
- betteroffice_docx-0.0.1/bindings/python-docx/THIRD-PARTY-NOTICES.md +9 -0
- betteroffice_docx-0.0.1/bindings/python-docx/package.json +8 -0
- betteroffice_docx-0.0.1/bindings/python-docx/src/lib.rs +1227 -0
- betteroffice_docx-0.0.1/bindings/python-docx/tests/conftest.py +126 -0
- betteroffice_docx-0.0.1/bindings/python-docx/tests/test_document.py +259 -0
- betteroffice_docx-0.0.1/bindings/python-docx/tests/test_render.py +236 -0
- betteroffice_docx-0.0.1/crates/betteroffice-docx/Cargo.toml +30 -0
- betteroffice_docx-0.0.1/crates/betteroffice-docx/README.md +128 -0
- betteroffice_docx-0.0.1/crates/betteroffice-docx/src/document.rs +376 -0
- betteroffice_docx-0.0.1/crates/betteroffice-docx/src/error.rs +106 -0
- betteroffice_docx-0.0.1/crates/betteroffice-docx/src/lib.rs +29 -0
- betteroffice_docx-0.0.1/crates/betteroffice-docx/src/render.rs +175 -0
- betteroffice_docx-0.0.1/crates/betteroffice-docx/src/types.rs +70 -0
- betteroffice_docx-0.0.1/crates/betteroffice-docx/tests/document.rs +103 -0
- betteroffice_docx-0.0.1/crates/betteroffice-docx/tests/render.rs +445 -0
- betteroffice_docx-0.0.1/crates/docx-edit/.gitignore +3 -0
- betteroffice_docx-0.0.1/crates/docx-edit/Cargo.toml +42 -0
- betteroffice_docx-0.0.1/crates/docx-edit/README.md +21 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/bridge/mod.rs +4172 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/bridge/shapes.rs +835 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/canonical.rs +848 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/ctx.rs +86 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/engine.rs +3205 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/format.rs +443 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/frame_delta/typed_page.rs +1949 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/frame_delta.rs +1705 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/lib.rs +1107 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/op.rs +335 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/ops/embed.rs +348 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/ops/mod.rs +214 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/ops/paragraph.rs +925 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/ops/resolve.rs +415 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/ops/table.rs +2685 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/ops/text.rs +481 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/presence.rs +285 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/queries.rs +848 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/raw.rs +406 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/read_state.rs +641 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/seed.rs +3160 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/undo.rs +240 -0
- betteroffice_docx-0.0.1/crates/docx-edit/src/wasm.rs +3514 -0
- betteroffice_docx-0.0.1/crates/docx-edit/tests/op_corpus.rs +1408 -0
- betteroffice_docx-0.0.1/crates/docx-edit/tests/resolve_corpus.rs +475 -0
- betteroffice_docx-0.0.1/crates/docx-layout/.gitignore +4 -0
- betteroffice_docx-0.0.1/crates/docx-layout/Cargo.toml +37 -0
- betteroffice_docx-0.0.1/crates/docx-layout/README.md +20 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/break_policy.rs +159 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/canonical.rs +171 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/cell_layout.rs +174 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/column_balancing.rs +437 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/display_list.rs +10621 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/floating_objects.rs +605 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/footnotes.rs +1150 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/header_footer.rs +523 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/hf_bands.rs +551 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/hit.rs +1526 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/hooks.rs +455 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/keep_together.rs +349 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/lib.rs +740 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/measure_blocks.rs +1258 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/page_flow.rs +613 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/paragraph_spacing.rs +56 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/place.rs +1541 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/prescan.rs +95 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/regions.rs +876 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/resolve_lines.rs +78 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/section_breaks.rs +1928 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/session.rs +460 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/table_grid.rs +689 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/table_row_break.rs +373 -0
- betteroffice_docx-0.0.1/crates/docx-layout/src/types.rs +2084 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/chart_snapshots.rs +2346 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/display_list.rs +2617 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/column-break-in-multi-column.displaylist.json +65 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/column-break-in-multi-column.golden.json +62 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/column-break-in-multi-column.input.json +98 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/continuous-section-column-change.displaylist.json +165 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/continuous-section-column-change.golden.json +141 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/continuous-section-column-change.input.json +262 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/explicit-and-attribute-page-breaks.displaylist.json +118 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/explicit-and-attribute-page-breaks.golden.json +102 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/explicit-and-attribute-page-breaks.input.json +129 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/floating-image-with-text-wrap.displaylist.json +136 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/floating-image-with-text-wrap.golden.json +50 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/floating-image-with-text-wrap.input.json +120 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/footnotes-force-content-up.displaylist.json +182 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/footnotes-force-content-up.golden.json +156 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/footnotes-force-content-up.input.json +284 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/hf/hf-default-both.displaylist.json +316 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/hf/hf-default-both.expect.json +28 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/hf/hf-default-both.input.json +626 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/hf/hf-even-odd.displaylist.json +574 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/hf/hf-even-odd.expect.json +40 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/hf/hf-even-odd.input.json +1234 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/hf/hf-title-page.displaylist.json +333 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/hf/hf-title-page.expect.json +28 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/hf/hf-title-page.input.json +747 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/keep-lines-paragraph.displaylist.json +131 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/keep-lines-paragraph.golden.json +71 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/keep-lines-paragraph.input.json +115 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/keep-with-next-chain.displaylist.json +199 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/keep-with-next-chain.golden.json +169 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/keep-with-next-chain.input.json +316 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/mixed-run-line-segments.displaylist.json +75 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/mixed-run-line-segments.golden.json +40 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/mixed-run-line-segments.input.json +84 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/multi-page-paragraph-overflow.displaylist.json +216 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/multi-page-paragraph-overflow.golden.json +183 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/multi-page-paragraph-overflow.input.json +530 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/multi-section-next-page-geometry.displaylist.json +80 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/multi-section-next-page-geometry.golden.json +67 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/multi-section-next-page-geometry.input.json +113 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/next-column-section-break.displaylist.json +143 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/next-column-section-break.golden.json +125 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/next-column-section-break.input.json +200 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/single-page-multi-paragraph.displaylist.json +76 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/single-page-multi-paragraph.golden.json +68 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/single-page-multi-paragraph.input.json +184 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/table-splits-with-repeated-header.displaylist.json +1697 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/table-splits-with-repeated-header.golden.json +102 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/table-splits-with-repeated-header.input.json +668 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/vertically-merged-cell-continuation.displaylist.json +1563 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/vertically-merged-cell-continuation.golden.json +69 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/fixtures/vertically-merged-cell-continuation.input.json +610 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/glyph_run.rs +599 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/goldens.rs +89 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/hf_bands.rs +261 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/measure_surface.rs +36 -0
- betteroffice_docx-0.0.1/crates/docx-layout/tests/synthetic_metrics.rs +481 -0
- betteroffice_docx-0.0.1/crates/docx-parse/Cargo.toml +33 -0
- betteroffice_docx-0.0.1/crates/docx-parse/README.md +19 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/block.rs +932 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/borders.rs +158 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/canonical.rs +309 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/chart.rs +411 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/comments.rs +446 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/document.rs +368 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/drawingml.rs +786 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/fonts.rs +160 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/formatting.rs +1475 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/header_footer.rs +335 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/image.rs +909 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/inline.rs +2425 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/lib.rs +331 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/media.rs +189 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/notes.rs +342 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/numbering.rs +840 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/paragraph.rs +1690 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/relationships.rs +481 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/s2.rs +256 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/s3.rs +251 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/s4.rs +287 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/s5.rs +410 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/s6.rs +373 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/s7.rs +79 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/s8.rs +432 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/s9.rs +741 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/scalars.rs +215 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/section.rs +451 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/context.rs +64 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/foundation.rs +387 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/mod.rs +55 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/numbering.rs +313 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/paragraph.rs +897 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/parts.rs +725 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/raw.rs +122 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/run.rs +1156 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/s10.rs +508 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/s11.rs +259 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/s12.rs +369 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/s13.rs +1661 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/sdt.rs +63 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/section.rs +503 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/table.rs +539 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/watermark.rs +418 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/serializer/xml_writer.rs +234 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/settings.rs +292 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/shape.rs +1633 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/smart_art.rs +751 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/styles.rs +507 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/table.rs +880 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/tabs.rs +246 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/text_box.rs +456 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/theme.rs +280 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/vml.rs +846 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/wrap.rs +35 -0
- betteroffice_docx-0.0.1/crates/docx-parse/src/xml.rs +1004 -0
- betteroffice_docx-0.0.1/crates/docx-raster/Cargo.toml +27 -0
- betteroffice_docx-0.0.1/crates/docx-raster/README.md +53 -0
- betteroffice_docx-0.0.1/crates/docx-raster/src/font.rs +797 -0
- betteroffice_docx-0.0.1/crates/docx-raster/src/lib.rs +2646 -0
- betteroffice_docx-0.0.1/crates/docx-raster/tests/assets/Carlito-Regular.ttf +0 -0
- betteroffice_docx-0.0.1/crates/docx-raster/tests/assets/OFL.txt +94 -0
- betteroffice_docx-0.0.1/crates/docx-raster/tests/budgets.rs +688 -0
- betteroffice_docx-0.0.1/crates/docx-raster/tests/contracts.rs +587 -0
- betteroffice_docx-0.0.1/crates/docx-raster/tests/golden/decorations.png +0 -0
- betteroffice_docx-0.0.1/crates/docx-raster/tests/golden/glyph-run.png +0 -0
- betteroffice_docx-0.0.1/crates/docx-raster/tests/golden/image.png +0 -0
- betteroffice_docx-0.0.1/crates/docx-raster/tests/golden/shape.png +0 -0
- betteroffice_docx-0.0.1/crates/docx-raster/tests/golden/table.png +0 -0
- betteroffice_docx-0.0.1/crates/docx-raster/tests/golden/text.png +0 -0
- betteroffice_docx-0.0.1/crates/docx-raster/tests/golden.rs +330 -0
- betteroffice_docx-0.0.1/crates/ooxml-drawingml/Cargo.toml +23 -0
- betteroffice_docx-0.0.1/crates/ooxml-drawingml/README.md +14 -0
- betteroffice_docx-0.0.1/crates/ooxml-drawingml/src/chart/geometry.rs +5405 -0
- betteroffice_docx-0.0.1/crates/ooxml-drawingml/src/chart/mod.rs +13 -0
- betteroffice_docx-0.0.1/crates/ooxml-drawingml/src/chart/model.rs +254 -0
- betteroffice_docx-0.0.1/crates/ooxml-drawingml/src/chart/parse.rs +1408 -0
- betteroffice_docx-0.0.1/crates/ooxml-drawingml/src/color.rs +295 -0
- betteroffice_docx-0.0.1/crates/ooxml-drawingml/src/geometry.rs +563 -0
- betteroffice_docx-0.0.1/crates/ooxml-drawingml/src/lib.rs +15 -0
- betteroffice_docx-0.0.1/crates/ooxml-drawingml/src/picture.rs +85 -0
- betteroffice_docx-0.0.1/crates/ooxml-drawingml/src/shape.rs +133 -0
- betteroffice_docx-0.0.1/crates/ooxml-drawingml/src/theme.rs +254 -0
- betteroffice_docx-0.0.1/crates/ooxml-opc/Cargo.toml +29 -0
- betteroffice_docx-0.0.1/crates/ooxml-opc/README.md +27 -0
- betteroffice_docx-0.0.1/crates/ooxml-opc/src/lib.rs +266 -0
- betteroffice_docx-0.0.1/crates/ooxml-opc/src/sanitize.rs +640 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/Cargo.toml +24 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/README.md +30 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/src/bidi.rs +101 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/src/font_store.rs +469 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/src/lib.rs +59 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/src/line_break.rs +69 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/src/measure/floats.rs +138 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/src/measure/input.rs +536 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/src/measure/line_filler.rs +1082 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/src/measure/list_marker.rs +120 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/src/measure/mod.rs +578 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/src/measure/prepare.rs +1024 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/src/measure/tabs.rs +161 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/src/outline.rs +309 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/src/shape.rs +214 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/src/word_metrics.rs +370 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/tests/docx_text.rs +878 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/tests/fixtures/line-spacing-baseline.docx +0 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/tests/fonts/LICENSE-OFL.txt +102 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/tests/fonts/LiberationSans-Regular.ttf +0 -0
- betteroffice_docx-0.0.1/crates/ooxml-text/tests/measure.rs +2107 -0
- betteroffice_docx-0.0.1/pyproject.toml +59 -0
- betteroffice_docx-0.0.1/python/betteroffice_docx/__init__.py +271 -0
- betteroffice_docx-0.0.1/python/betteroffice_docx/_betteroffice_docx.pyi +232 -0
- betteroffice_docx-0.0.1/python/betteroffice_docx/py.typed +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[workspace]
|
|
2
|
+
members = ["crates/*"]
|
|
3
|
+
resolver = "3"
|
|
4
|
+
|
|
5
|
+
[workspace.package]
|
|
6
|
+
version = "0.0.4"
|
|
7
|
+
edition = "2024"
|
|
8
|
+
license = "Apache-2.0"
|
|
9
|
+
homepage = "https://betteroffice.dev"
|
|
10
|
+
repository = "https://github.com/openooxml/betteroffice"
|
|
11
|
+
|
|
12
|
+
[workspace.dependencies]
|
|
13
|
+
betteroffice-xlsx = { path = "crates/betteroffice-xlsx", version = "0.0.4", default-features = false }
|
|
14
|
+
ooxml-opc = { package = "betteroffice-opc", path = "crates/ooxml-opc", version = "0.0.4" }
|
|
15
|
+
xlsx-model = { package = "betteroffice-xlsx-model", path = "crates/xlsx-model", version = "0.0.4" }
|
|
16
|
+
xlsx-parse = { package = "betteroffice-xlsx-parse", path = "crates/xlsx-parse", version = "0.0.4" }
|
|
17
|
+
xlsx-calc = { package = "betteroffice-xlsx-calc", path = "crates/xlsx-calc", version = "0.0.4" }
|
|
18
|
+
xlsx-ops = { package = "betteroffice-xlsx-ops", path = "crates/xlsx-ops", version = "0.0.4" }
|
|
19
|
+
xlsx-render = { package = "betteroffice-xlsx-render", path = "crates/xlsx-render", version = "0.0.4" }
|
|
20
|
+
xlsx-raster = { package = "betteroffice-xlsx-raster", path = "crates/xlsx-raster", version = "0.0.4" }
|
|
21
|
+
ooxml-text = { package = "betteroffice-ooxml-text", path = "crates/ooxml-text", version = "0.0.4" }
|
|
22
|
+
ooxml-drawingml = { package = "betteroffice-drawingml", path = "crates/ooxml-drawingml", version = "0.0.4" }
|
|
23
|
+
docx-parse = { package = "betteroffice-docx-parse", path = "crates/docx-parse", version = "0.0.4" }
|
|
24
|
+
docx-layout = { package = "betteroffice-docx-layout", path = "crates/docx-layout", version = "0.0.4" }
|
|
25
|
+
docx-raster = { package = "betteroffice-docx-raster", path = "crates/docx-raster", version = "0.0.4" }
|
|
26
|
+
docx-edit = { package = "betteroffice-docx-edit", path = "crates/docx-edit", version = "0.0.4" }
|
|
27
|
+
betteroffice-docx = { path = "crates/betteroffice-docx", version = "0.0.4" }
|
|
28
|
+
pptx-parse = { package = "betteroffice-pptx-parse", path = "crates/pptx-parse", version = "0.0.4" }
|
|
29
|
+
pptx-edit = { package = "betteroffice-pptx-edit", path = "crates/pptx-edit", version = "0.0.4" }
|
|
30
|
+
pptx-render = { package = "betteroffice-pptx-render", path = "crates/pptx-render", version = "0.0.4" }
|
|
31
|
+
betteroffice-pptx = { path = "crates/betteroffice-pptx", version = "0.0.4" }
|
|
32
|
+
|
|
33
|
+
[profile.release]
|
|
34
|
+
opt-level = "s"
|
|
35
|
+
lto = true
|
|
36
|
+
|
|
37
|
+
[profile.release.package.betteroffice-docx-layout]
|
|
38
|
+
opt-level = 3
|
|
39
|
+
|
|
40
|
+
[profile.release.package.betteroffice-docx-parse]
|
|
41
|
+
opt-level = 3
|
|
42
|
+
|
|
43
|
+
# The per-keystroke hot path lives in docx-edit (engine session, frame
|
|
44
|
+
# encoding), ooxml-text (shaping/measurement), and yrs (text CRDT ops); the
|
|
45
|
+
# size-optimized workspace default measurably slows all three.
|
|
46
|
+
[profile.release.package.betteroffice-docx-edit]
|
|
47
|
+
opt-level = 3
|
|
48
|
+
|
|
49
|
+
[profile.release.package.betteroffice-ooxml-text]
|
|
50
|
+
opt-level = 3
|
|
51
|
+
|
|
52
|
+
[profile.release.package.yrs]
|
|
53
|
+
opt-level = 3
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Elia Hilse, The OpenOOXML Project
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: betteroffice-docx
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Classifier: Development Status :: 3 - Alpha
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Rust
|
|
16
|
+
Classifier: Topic :: Office/Business :: Office Suites
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
License-File: NOTICE
|
|
21
|
+
License-File: THIRD-PARTY-NOTICES.md
|
|
22
|
+
Summary: Read, edit, lay out, and render DOCX documents. Rust engine, no Word and no LibreOffice.
|
|
23
|
+
Keywords: docx,word,document,ooxml,wordprocessingml,layout,pagination,python-docx,rust
|
|
24
|
+
Home-Page: https://betteroffice.dev
|
|
25
|
+
Author: OpenOOXML
|
|
26
|
+
License-Expression: Apache-2.0
|
|
27
|
+
Requires-Python: >=3.9
|
|
28
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
29
|
+
Project-URL: Changelog, https://github.com/openooxml/betteroffice/blob/main/bindings/python-docx/CHANGELOG.md
|
|
30
|
+
Project-URL: Documentation, https://docs.betteroffice.dev/docs/python
|
|
31
|
+
Project-URL: Homepage, https://betteroffice.dev
|
|
32
|
+
Project-URL: Issues, https://github.com/openooxml/betteroffice/issues
|
|
33
|
+
Project-URL: Source, https://github.com/openooxml/betteroffice
|
|
34
|
+
|
|
35
|
+
# betteroffice-docx
|
|
36
|
+
|
|
37
|
+
Read, edit, lay out, and rasterize DOCX documents from Python. `python-docx`
|
|
38
|
+
reads a document and writes one back; this also *paginates* it β page boxes, a
|
|
39
|
+
display list, PNG pages β because the Rust
|
|
40
|
+
[BetterOffice](https://betteroffice.dev) DOCX core is compiled into the wheel:
|
|
41
|
+
no Word, no LibreOffice subprocess, no COM.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install betteroffice-docx
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The distribution is hyphenated, the module is not: `import betteroffice_docx`.
|
|
48
|
+
|
|
49
|
+
## Read a document
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from betteroffice_docx import Document
|
|
53
|
+
|
|
54
|
+
document = Document.open_path("report.docx")
|
|
55
|
+
|
|
56
|
+
print(document.structure()) # Structure(body_paragraphs=42, body_tables=3, sections=2)
|
|
57
|
+
for paragraph in document:
|
|
58
|
+
print(paragraph.id, paragraph.style, repr(paragraph.text))
|
|
59
|
+
|
|
60
|
+
for table in document.tables():
|
|
61
|
+
for row in table.rows:
|
|
62
|
+
print([cell.text for cell in row.cells])
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`paragraphs()` walks the body in document order and descends into table cells
|
|
66
|
+
and content controls, so a cell paragraph is reachable both ways.
|
|
67
|
+
`document[key]` and `document.paragraph(key)` take either a `w14:paraId` or a
|
|
68
|
+
body index. Everything a read returns is a value, not a live view β read again
|
|
69
|
+
after an edit.
|
|
70
|
+
|
|
71
|
+
Page geometry is in twips β 1440 to the inch. The module exports
|
|
72
|
+
`TWIPS_PER_INCH` and `TWIPS_PER_POINT`.
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
section = document.sections()[0]
|
|
76
|
+
print(section.page_width, section.page_height, section.margin_left)
|
|
77
|
+
print(document.headers()[0].text)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Edit text
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
edit = document.replace_text("11111111", "Edited from Python")
|
|
84
|
+
print(edit.para_id, edit.start, edit.end)
|
|
85
|
+
|
|
86
|
+
document.save_path("report-edited.docx")
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`replace_text` rewrites one paragraph and keeps its style, alignment, and the
|
|
90
|
+
run formatting it already had. The engine rebuilds the paragraph from a single
|
|
91
|
+
run, so a paragraph that mixes runs β half bold, a hyperlink, a field β raises
|
|
92
|
+
`UnsupportedEditError` rather than flattening the formatting you did not ask it
|
|
93
|
+
to touch. An unknown `w14:paraId` raises `KeyError`.
|
|
94
|
+
|
|
95
|
+
Only paragraphs Word stamped with a `w14:paraId` can be addressed:
|
|
96
|
+
`document.paragraph_ids` reports `None` for the rest.
|
|
97
|
+
|
|
98
|
+
## Write
|
|
99
|
+
|
|
100
|
+
Unlike the PPTX binding, edits reach the file: `save()` serializes the edited
|
|
101
|
+
model, and reopening the result gives the edited text back.
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
document = Document.open(data)
|
|
105
|
+
document.replace_text(document.paragraph_ids[0], "New first line")
|
|
106
|
+
reopened = Document.open(document.save())
|
|
107
|
+
reopened.paragraph(0).text # 'New first line'
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Saving is deterministic. The engine has no clock, so timestamps come from
|
|
111
|
+
`document.timestamp` β the epoch until you set one β and the same input plus the
|
|
112
|
+
same edits produce the same bytes. `save(now=..., update_modified_date=True,
|
|
113
|
+
modified_by=...)` overrides that for one call.
|
|
114
|
+
|
|
115
|
+
The container is rebuilt rather than patched, so output is not byte-identical to
|
|
116
|
+
the source even with no edits; the parts the model retained survive unchanged.
|
|
117
|
+
|
|
118
|
+
## Lay a document out
|
|
119
|
+
|
|
120
|
+
Layout is a two-stage contract. Something else measures text β the browser, or
|
|
121
|
+
`ooxml-text` β and the engine paginates the measured blocks and compiles them
|
|
122
|
+
into a display list:
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
layout = document.layout({"measured": measured_blocks, "options": {...}})
|
|
126
|
+
print(len(layout), layout.pages)
|
|
127
|
+
layout.write("layout.json")
|
|
128
|
+
|
|
129
|
+
pages = layout.display_list
|
|
130
|
+
print(len(pages), pages.primitives)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
`layout()` takes the envelope as a `dict` or as a JSON string, and returns the
|
|
134
|
+
page boxes (`layout.json`, `layout.to_dict()`) beside the display list that
|
|
135
|
+
paints them.
|
|
136
|
+
|
|
137
|
+
## Rasterize
|
|
138
|
+
|
|
139
|
+
**No font is compiled into the wheel**, so a page with text needs at least one
|
|
140
|
+
registered face:
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
from pathlib import Path
|
|
144
|
+
|
|
145
|
+
document.register_font("Carlito", Path("Carlito-Regular.ttf").read_bytes())
|
|
146
|
+
document.register_font("Carlito", Path("Carlito-Bold.ttf").read_bytes(), bold=True)
|
|
147
|
+
|
|
148
|
+
png = document.render_png(layout.display_list, 0)
|
|
149
|
+
png.write("page-0.png")
|
|
150
|
+
print(len(png), png.skipped_images)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Text whose family has no chain raises `RenderError` naming the chain it wanted
|
|
154
|
+
β ``missing font chain for `calibri|0|0` `` β so a missing face is loud rather
|
|
155
|
+
than silently blank.
|
|
156
|
+
|
|
157
|
+
Images are the opposite: an image reference the backend cannot resolve is
|
|
158
|
+
skipped and counted in `png.skipped_images` instead of failing the page. Word
|
|
159
|
+
hands out relationship ids per part, so `rId9` in the body and `rId9` in a
|
|
160
|
+
header are different images and registration is scoped:
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
document.register_image("rId9", body_png)
|
|
164
|
+
document.register_image("rId9", header_png, scope="header_footer", part="rId7")
|
|
165
|
+
document.register_image("rId4", note_png, scope="footnotes")
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Images the display list already carries as `data:` URLs need no registration.
|
|
169
|
+
A page past `MAX_PIXMAP_DIM` per side or `MAX_PIXMAP_PIXELS` in area is refused
|
|
170
|
+
before any surface is allocated.
|
|
171
|
+
|
|
172
|
+
## Compared with python-docx
|
|
173
|
+
|
|
174
|
+
| | `python-docx` | `betteroffice-docx` |
|
|
175
|
+
| --- | --- | --- |
|
|
176
|
+
| Read paragraphs, tables, sections | yes | yes |
|
|
177
|
+
| Write text back to a file | yes | yes, single-run paragraphs |
|
|
178
|
+
| Build a document from scratch | yes | no β it edits what you open |
|
|
179
|
+
| Paginate (page boxes, display list) | no | yes |
|
|
180
|
+
| Rasterize pages to PNG | no | yes |
|
|
181
|
+
| Engine | pure Python | Rust, compiled |
|
|
182
|
+
|
|
183
|
+
`python-docx` is a far broader authoring library. If what you need is
|
|
184
|
+
pagination, page images, or an engine that reads what Word actually wrote, that
|
|
185
|
+
is the gap this fills.
|
|
186
|
+
|
|
187
|
+
## API
|
|
188
|
+
|
|
189
|
+
| | |
|
|
190
|
+
| --- | --- |
|
|
191
|
+
| `Document.open(data)` / `open_path(path)` | open from bytes or a path |
|
|
192
|
+
| `document.structure()` | paragraph, table, section, and note counts |
|
|
193
|
+
| `document.paragraphs()` / `tables()` / `sections()` | body content |
|
|
194
|
+
| `document.headers()` / `footers()` | header and footer stories |
|
|
195
|
+
| `document[key]` / `document.paragraph(key)` | one paragraph by ID or index |
|
|
196
|
+
| `document.paragraph_ids` / `text` | body IDs, and the whole text |
|
|
197
|
+
| `document.warnings` / `template_variables` | what the parser found |
|
|
198
|
+
| `document.replace_text(para_id, text)` | rewrite one paragraph |
|
|
199
|
+
| `document.author` / `origin` / `timestamp` | how an edit is attributed and stamped |
|
|
200
|
+
| `document.layout(input)` | paginate a measured envelope |
|
|
201
|
+
| `document.register_font` / `register_image` | raster resources |
|
|
202
|
+
| `document.render_png(display_list, page)` | rasterize one page |
|
|
203
|
+
| `document.save()` / `save_path(path)` | serialize to DOCX |
|
|
204
|
+
|
|
205
|
+
Errors raise `DocxError` or a more specific subclass: `ParseError`,
|
|
206
|
+
`EditError`, `UnsupportedEditError`, `LayoutError`, `RenderError`. An unknown
|
|
207
|
+
paragraph ID raises `KeyError`, an out-of-range index `IndexError`, and a bad
|
|
208
|
+
argument β an unknown parse limit, an unknown image scope, malformed font bytes
|
|
209
|
+
β `ValueError`.
|
|
210
|
+
|
|
211
|
+
Parser bounds can be tightened for untrusted input:
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
Document.open(untrusted, limits={"max_paragraphs": 5_000, "max_tables": 500})
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
An unknown limit name raises `ValueError` rather than being ignored.
|
|
218
|
+
|
|
219
|
+
## Threads
|
|
220
|
+
|
|
221
|
+
A `Document` is not pinned to a thread: the engine's document type is `Send` and
|
|
222
|
+
`Sync`, so opening on one thread and dropping on another is fine. Parsing,
|
|
223
|
+
layout, rasterization, and saving release the GIL for their duration, so several
|
|
224
|
+
documents genuinely proceed in parallel.
|
|
225
|
+
|
|
226
|
+
## Status
|
|
227
|
+
|
|
228
|
+
`0.0.x`, and the API may change before `0.1.0`. Editing covers paragraph text on
|
|
229
|
+
plain single-run paragraphs; richer edits land on the Rust facade first.
|
|
230
|
+
|
|
231
|
+
Wheels are built for Linux (x86_64, aarch64), macOS (arm64, x86_64), and Windows
|
|
232
|
+
(x86_64) against the stable ABI for CPython 3.9 and up.
|
|
233
|
+
|
|
234
|
+
## Links
|
|
235
|
+
|
|
236
|
+
- [BetterOffice](https://betteroffice.dev) β the project
|
|
237
|
+
- [Documentation](https://docs.betteroffice.dev/docs/python)
|
|
238
|
+
- [Source](https://github.com/openooxml/betteroffice) β `bindings/python-docx`
|
|
239
|
+
- [betteroffice-docx on crates.io](https://crates.io/crates/betteroffice-docx) β the engine this wraps
|
|
240
|
+
|
|
241
|
+
Apache-2.0.
|
|
242
|
+
|