betteroffice-pptx 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.
Files changed (101) hide show
  1. betteroffice_pptx-0.0.1/Cargo.toml +53 -0
  2. betteroffice_pptx-0.0.1/LICENSE +201 -0
  3. betteroffice_pptx-0.0.1/NOTICE +2 -0
  4. betteroffice_pptx-0.0.1/PKG-INFO +346 -0
  5. betteroffice_pptx-0.0.1/README.md +311 -0
  6. betteroffice_pptx-0.0.1/THIRD-PARTY-NOTICES.md +9 -0
  7. betteroffice_pptx-0.0.1/bindings/Cargo.lock +1096 -0
  8. betteroffice_pptx-0.0.1/bindings/Cargo.toml +7 -0
  9. betteroffice_pptx-0.0.1/bindings/python-common/Cargo.toml +13 -0
  10. betteroffice_pptx-0.0.1/bindings/python-common/src/lib.rs +26 -0
  11. betteroffice_pptx-0.0.1/bindings/python-pptx/Cargo.toml +20 -0
  12. betteroffice_pptx-0.0.1/bindings/python-pptx/LICENSE +201 -0
  13. betteroffice_pptx-0.0.1/bindings/python-pptx/NOTICE +2 -0
  14. betteroffice_pptx-0.0.1/bindings/python-pptx/README.md +311 -0
  15. betteroffice_pptx-0.0.1/bindings/python-pptx/THIRD-PARTY-NOTICES.md +9 -0
  16. betteroffice_pptx-0.0.1/bindings/python-pptx/package.json +8 -0
  17. betteroffice_pptx-0.0.1/bindings/python-pptx/src/lib.rs +1633 -0
  18. betteroffice_pptx-0.0.1/bindings/python-pptx/tests/conftest.py +31 -0
  19. betteroffice_pptx-0.0.1/bindings/python-pptx/tests/test_presentation.py +805 -0
  20. betteroffice_pptx-0.0.1/crates/betteroffice-pptx/Cargo.toml +17 -0
  21. betteroffice_pptx-0.0.1/crates/betteroffice-pptx/README.md +58 -0
  22. betteroffice_pptx-0.0.1/crates/betteroffice-pptx/src/error.rs +47 -0
  23. betteroffice_pptx-0.0.1/crates/betteroffice-pptx/src/lib.rs +16 -0
  24. betteroffice_pptx-0.0.1/crates/betteroffice-pptx/src/presentation.rs +315 -0
  25. betteroffice_pptx-0.0.1/crates/betteroffice-pptx/src/types.rs +21 -0
  26. betteroffice_pptx-0.0.1/crates/betteroffice-pptx/tests/facade.rs +110 -0
  27. betteroffice_pptx-0.0.1/crates/ooxml-drawingml/Cargo.toml +23 -0
  28. betteroffice_pptx-0.0.1/crates/ooxml-drawingml/README.md +14 -0
  29. betteroffice_pptx-0.0.1/crates/ooxml-drawingml/src/chart/geometry.rs +5405 -0
  30. betteroffice_pptx-0.0.1/crates/ooxml-drawingml/src/chart/mod.rs +13 -0
  31. betteroffice_pptx-0.0.1/crates/ooxml-drawingml/src/chart/model.rs +254 -0
  32. betteroffice_pptx-0.0.1/crates/ooxml-drawingml/src/chart/parse.rs +1408 -0
  33. betteroffice_pptx-0.0.1/crates/ooxml-drawingml/src/color.rs +295 -0
  34. betteroffice_pptx-0.0.1/crates/ooxml-drawingml/src/geometry.rs +563 -0
  35. betteroffice_pptx-0.0.1/crates/ooxml-drawingml/src/lib.rs +15 -0
  36. betteroffice_pptx-0.0.1/crates/ooxml-drawingml/src/picture.rs +85 -0
  37. betteroffice_pptx-0.0.1/crates/ooxml-drawingml/src/shape.rs +133 -0
  38. betteroffice_pptx-0.0.1/crates/ooxml-drawingml/src/theme.rs +254 -0
  39. betteroffice_pptx-0.0.1/crates/ooxml-opc/Cargo.toml +29 -0
  40. betteroffice_pptx-0.0.1/crates/ooxml-opc/README.md +27 -0
  41. betteroffice_pptx-0.0.1/crates/ooxml-opc/src/lib.rs +266 -0
  42. betteroffice_pptx-0.0.1/crates/ooxml-opc/src/sanitize.rs +640 -0
  43. betteroffice_pptx-0.0.1/crates/ooxml-text/Cargo.toml +24 -0
  44. betteroffice_pptx-0.0.1/crates/ooxml-text/README.md +30 -0
  45. betteroffice_pptx-0.0.1/crates/ooxml-text/src/bidi.rs +101 -0
  46. betteroffice_pptx-0.0.1/crates/ooxml-text/src/font_store.rs +469 -0
  47. betteroffice_pptx-0.0.1/crates/ooxml-text/src/lib.rs +59 -0
  48. betteroffice_pptx-0.0.1/crates/ooxml-text/src/line_break.rs +69 -0
  49. betteroffice_pptx-0.0.1/crates/ooxml-text/src/measure/floats.rs +138 -0
  50. betteroffice_pptx-0.0.1/crates/ooxml-text/src/measure/input.rs +536 -0
  51. betteroffice_pptx-0.0.1/crates/ooxml-text/src/measure/line_filler.rs +1082 -0
  52. betteroffice_pptx-0.0.1/crates/ooxml-text/src/measure/list_marker.rs +120 -0
  53. betteroffice_pptx-0.0.1/crates/ooxml-text/src/measure/mod.rs +578 -0
  54. betteroffice_pptx-0.0.1/crates/ooxml-text/src/measure/prepare.rs +1024 -0
  55. betteroffice_pptx-0.0.1/crates/ooxml-text/src/measure/tabs.rs +161 -0
  56. betteroffice_pptx-0.0.1/crates/ooxml-text/src/outline.rs +309 -0
  57. betteroffice_pptx-0.0.1/crates/ooxml-text/src/shape.rs +214 -0
  58. betteroffice_pptx-0.0.1/crates/ooxml-text/src/word_metrics.rs +370 -0
  59. betteroffice_pptx-0.0.1/crates/ooxml-text/tests/docx_text.rs +878 -0
  60. betteroffice_pptx-0.0.1/crates/ooxml-text/tests/fixtures/line-spacing-baseline.docx +0 -0
  61. betteroffice_pptx-0.0.1/crates/ooxml-text/tests/fonts/LICENSE-OFL.txt +102 -0
  62. betteroffice_pptx-0.0.1/crates/ooxml-text/tests/fonts/LiberationSans-Regular.ttf +0 -0
  63. betteroffice_pptx-0.0.1/crates/ooxml-text/tests/measure.rs +2107 -0
  64. betteroffice_pptx-0.0.1/crates/pptx-edit/Cargo.toml +33 -0
  65. betteroffice_pptx-0.0.1/crates/pptx-edit/README.md +20 -0
  66. betteroffice_pptx-0.0.1/crates/pptx-edit/src/deck.rs +1280 -0
  67. betteroffice_pptx-0.0.1/crates/pptx-edit/src/lib.rs +344 -0
  68. betteroffice_pptx-0.0.1/crates/pptx-edit/src/model.rs +315 -0
  69. betteroffice_pptx-0.0.1/crates/pptx-edit/src/save.rs +436 -0
  70. betteroffice_pptx-0.0.1/crates/pptx-edit/src/story.rs +561 -0
  71. betteroffice_pptx-0.0.1/crates/pptx-edit/src/undo.rs +84 -0
  72. betteroffice_pptx-0.0.1/crates/pptx-edit/src/wasm.rs +554 -0
  73. betteroffice_pptx-0.0.1/crates/pptx-edit/tests/convergence.rs +358 -0
  74. betteroffice_pptx-0.0.1/crates/pptx-edit/tests/fixtures/deck-schema-v1.update.bin +0 -0
  75. betteroffice_pptx-0.0.1/crates/pptx-edit/tests/save.rs +465 -0
  76. betteroffice_pptx-0.0.1/crates/pptx-edit/tests/schema_migration.rs +179 -0
  77. betteroffice_pptx-0.0.1/crates/pptx-edit/tests/shape_ops.rs +330 -0
  78. betteroffice_pptx-0.0.1/crates/pptx-edit/tests/write_fidelity.rs +623 -0
  79. betteroffice_pptx-0.0.1/crates/pptx-parse/Cargo.toml +22 -0
  80. betteroffice_pptx-0.0.1/crates/pptx-parse/README.md +17 -0
  81. betteroffice_pptx-0.0.1/crates/pptx-parse/src/chart.rs +217 -0
  82. betteroffice_pptx-0.0.1/crates/pptx-parse/src/drawing.rs +1173 -0
  83. betteroffice_pptx-0.0.1/crates/pptx-parse/src/error.rs +23 -0
  84. betteroffice_pptx-0.0.1/crates/pptx-parse/src/lib.rs +21 -0
  85. betteroffice_pptx-0.0.1/crates/pptx-parse/src/model.rs +355 -0
  86. betteroffice_pptx-0.0.1/crates/pptx-parse/src/package.rs +775 -0
  87. betteroffice_pptx-0.0.1/crates/pptx-parse/src/relationships.rs +142 -0
  88. betteroffice_pptx-0.0.1/crates/pptx-parse/src/theme.rs +114 -0
  89. betteroffice_pptx-0.0.1/crates/pptx-parse/src/write.rs +1851 -0
  90. betteroffice_pptx-0.0.1/crates/pptx-parse/src/xml.rs +566 -0
  91. betteroffice_pptx-0.0.1/crates/pptx-parse/tests/fixtures/chart-deck.pptx +0 -0
  92. betteroffice_pptx-0.0.1/crates/pptx-render/Cargo.toml +24 -0
  93. betteroffice_pptx-0.0.1/crates/pptx-render/README.md +15 -0
  94. betteroffice_pptx-0.0.1/crates/pptx-render/src/chart.rs +778 -0
  95. betteroffice_pptx-0.0.1/crates/pptx-render/src/display_list.rs +299 -0
  96. betteroffice_pptx-0.0.1/crates/pptx-render/src/layout.rs +2557 -0
  97. betteroffice_pptx-0.0.1/crates/pptx-render/src/lib.rs +501 -0
  98. betteroffice_pptx-0.0.1/pyproject.toml +58 -0
  99. betteroffice_pptx-0.0.1/python/betteroffice_pptx/__init__.py +453 -0
  100. betteroffice_pptx-0.0.1/python/betteroffice_pptx/_betteroffice_pptx.pyi +384 -0
  101. betteroffice_pptx-0.0.1/python/betteroffice_pptx/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,2 @@
1
+ BetterOffice
2
+ Copyright 2026 Elia Hilse, The OpenOOXML Project
@@ -0,0 +1,346 @@
1
+ Metadata-Version: 2.4
2
+ Name: betteroffice-pptx
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, and lay out PPTX presentations. Rust engine, no PowerPoint and no LibreOffice.
23
+ Keywords: pptx,powerpoint,presentation,ooxml,presentationml,slides,python-pptx,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-pptx/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-pptx
36
+
37
+ Read, edit, and lay out PPTX presentations from Python. `python-pptx` reads a
38
+ deck and writes one back; this also *lays slides out* — line breaking, text
39
+ metrics, a display list — and merges edits across replicas, because the Rust
40
+ [BetterOffice](https://betteroffice.dev) PPTX core is compiled into the wheel:
41
+ no PowerPoint, no LibreOffice subprocess, no COM.
42
+
43
+ ```bash
44
+ pip install betteroffice-pptx
45
+ ```
46
+
47
+ The distribution is hyphenated, the module is not: `import betteroffice_pptx`.
48
+
49
+ ## Read a deck
50
+
51
+ ```python
52
+ from betteroffice_pptx import Presentation
53
+
54
+ deck = Presentation.open_path("quarterly.pptx")
55
+
56
+ for slide in deck:
57
+ print(slide.index, slide.name, repr(slide.text))
58
+
59
+ shape = next((s for slide in deck for s in slide.shapes), None)
60
+ if shape is not None:
61
+ print(shape.kind, shape.geometry, shape.x, shape.y, shape.width, shape.height)
62
+ ```
63
+
64
+ Geometry is in English Metric Units — 914400 to the inch. The module exports
65
+ `EMU_PER_INCH`, `EMU_PER_CENTIMETER`, and `EMU_PER_POINT` so you rarely have to
66
+ type the constant.
67
+
68
+ `snapshot()` returns the whole deck as plain data in one call; `slide(key)`
69
+ returns one slide by index or by ID. Both are values, not live views — read
70
+ them again after an edit.
71
+
72
+ ## Edit shapes and slides
73
+
74
+ ```python
75
+ from betteroffice_pptx import EMU_PER_INCH as INCH
76
+
77
+ deck = Presentation.open(open("deck.pptx", "rb").read())
78
+ slide_id = deck.slide_ids[0]
79
+
80
+ edit = deck.add_text_box(
81
+ slide_id, x=INCH, y=INCH, width=4 * INCH, height=INCH,
82
+ text="Revenue", bold=True, font_size=32.0,
83
+ )
84
+ deck.move_shape(slide_id, edit.shape_id, 2 * INCH, INCH)
85
+ deck.resize_shape(slide_id, edit.shape_id, 5 * INCH, 2 * INCH)
86
+
87
+ box = deck.add_shape(slide_id, "roundRect", x=INCH, y=3 * INCH,
88
+ width=2 * INCH, height=INCH, fill="#2563eb")
89
+ deck.set_shape_stroke(slide_id, box.shape_id, color="#111827", width_pt=2.0)
90
+ deck.set_shape_adjust(slide_id, box.shape_id, {"adj": 0.25})
91
+ ```
92
+
93
+ Every mutating call returns a receipt naming what it touched: `ShapeEdit` has
94
+ the new shape's ID and z-order index, `TransformEdit` carries the rect before
95
+ and after, and `AdjustEdit` shows the values after the engine clamped them into
96
+ their guide's legal range.
97
+
98
+ An unsupported preset geometry, a non-positive size, or an unknown adjustment
99
+ guide raises `ValueError` instead of writing a shape PowerPoint would reject.
100
+
101
+ ## Edit text
102
+
103
+ Text lives in *stories* — one editable flow per text-bearing shape. Offsets are
104
+ UTF-16 code units, and every paragraph ends with a pilcrow occupying one of
105
+ them.
106
+
107
+ ```python
108
+ story = next(
109
+ (s for slide in deck for shape in slide.shapes for s in shape.stories), None
110
+ )
111
+ if story is not None:
112
+ print(story.text, story.length)
113
+
114
+ deck.insert_text(story.id, 0, "Q3 ", bold=True)
115
+ deck.format_text(story.id, 0, 3, color="#dc2626")
116
+ deck.insert_paragraph_break(story.id, 3)
117
+ removed = deck.delete_text(story.id, 0, 3)
118
+ print(removed.text) # 'Q3 '
119
+ ```
120
+
121
+ A shape with no text has no story, so a deck of pictures alone yields none.
122
+ `deck.story(id)` looks one up directly and raises `KeyError` if it is gone.
123
+
124
+ `format_text` patches only the arguments you pass, and a range spanning several
125
+ paragraphs styles each of them as a single undoable edit. `delete_text` is the
126
+ strict one: a range crossing a paragraph boundary raises `RangeError` rather
127
+ than silently swallowing the break.
128
+
129
+ ## Lay a slide out
130
+
131
+ **No font is compiled into the wheel**, so laying out a slide that has text
132
+ needs at least one registered face. Before that, `render_slide` raises:
133
+
134
+ ```python
135
+ deck.render_slide(0)
136
+ # RenderError: no font has been registered for slide text
137
+ ```
138
+
139
+ Register the faces the deck uses — one call per family, weight, and slant — and
140
+ it lays out:
141
+
142
+ ```python
143
+ from pathlib import Path
144
+
145
+ deck.register_font("Inter", Path("Inter-Regular.ttf").read_bytes())
146
+ deck.register_font("Inter", Path("Inter-Bold.ttf").read_bytes(), bold=True)
147
+
148
+ layout = deck.render_slide(0)
149
+ print(layout.width, layout.height, len(layout)) # 1280.0 720.0 42
150
+ layout.write("slide-0.json")
151
+ scene = layout.to_dict()
152
+ ```
153
+
154
+ Once at least one face exists nothing raises again: a family the deck names but
155
+ you never registered resolves to the same family at regular weight, and failing
156
+ that to the first face you registered at all. One registration therefore renders
157
+ every slide — in that one typeface, at its metrics. Register the real faces when
158
+ line breaking has to match what PowerPoint would do.
159
+
160
+ `render_slide` returns the display list — the same drawing contract the browser
161
+ editor paints, as JSON. There is no PPTX rasterizer yet, so this is a scene
162
+ description rather than pixels; feed it to your own canvas or renderer.
163
+
164
+ ## Collaboration
165
+
166
+ `open_collaborative` gives this replica a unique client ID, which peers need in
167
+ order to converge:
168
+
169
+ ```python
170
+ left = Presentation.open_collaborative(data)
171
+ right = Presentation.open_collaborative(data)
172
+
173
+ left.add_text_box(0, x=INCH, y=INCH, width=4 * INCH, height=INCH, text="Q3")
174
+ right.apply_update(left.diff(right.state_vector())) # right now agrees
175
+
176
+ joiner = Presentation.open_collaborative(data)
177
+ joiner.apply_update(left.state_as_update()) # catch up from nothing
178
+ ```
179
+
180
+ A deck from `open` or `open_path` is *not* a replica: it has no client ID of its
181
+ own, so two of them would author under the same identity and never converge.
182
+ `state_vector`, `state_as_update`, `diff`, and `apply_update` raise
183
+ `NotCollaborativeError` on such a deck rather than diverging silently, and
184
+ `is_collaborative` says which kind you are holding:
185
+
186
+ ```python
187
+ deck = Presentation.open(data)
188
+ deck.is_collaborative # False
189
+ deck.state_vector() # NotCollaborativeError
190
+ ```
191
+
192
+ The binding generates a client ID when it is omitted and exposes it through the
193
+ read-only `client_id` property. Explicit IDs must be unique among connected
194
+ peers, because Yrs cannot detect duplicates once two replicas have started
195
+ authoring. Byte inputs accept `bytes`, `bytearray`, and `memoryview`, and an
196
+ oversized payload is refused before it is copied.
197
+
198
+ ## Undo, redo, and attribution
199
+
200
+ ```python
201
+ deck.author = "ana"
202
+ edit = deck.add_text_box(0, x=INCH, y=INCH, width=INCH, height=INCH, text="Q3")
203
+ deck.move_shape(0, edit.shape_id, 0, 0)
204
+ deck.add_undo_barrier() # the next edit starts a new undo step
205
+ deck.undo()
206
+ deck.redo()
207
+ ```
208
+
209
+ Undo covers this replica's own local edits. Updates applied from a peer are not
210
+ in local history, so undo will not revert someone else's work. Consecutive edits
211
+ inside half a second coalesce into one step; `add_undo_barrier()` splits them.
212
+
213
+ Setting `origin` to `"agent"`, `"remote"`, or `"system"` tags edits for
214
+ attribution — and takes them out of the local undo stack, which is the point:
215
+ an agent's write is not something the user undoes by accident.
216
+
217
+ ## Writing
218
+
219
+ `save()` and `save_path()` serialize the deck with every accepted edit
220
+ applied. Slides you did not touch keep their exact source part bytes; edited
221
+ slides are patched at the XML level, so unmodeled markup survives:
222
+
223
+ ```python
224
+ deck = Presentation.open(data)
225
+ deck.insert_slide(1)
226
+ deck.is_edited # True
227
+ deck.save_path("copy.pptx") # edits included
228
+
229
+ reopened = Presentation.open_path("copy.pptx")
230
+ reopened.slide_count # one more than the source
231
+ ```
232
+
233
+ `is_edited` reports whether the engine has accepted an edit since the deck was
234
+ opened. Only an edit the engine *accepted* sets it: an edit that raised leaves
235
+ the flag untouched.
236
+
237
+ ## Compared with python-pptx
238
+
239
+ | | `python-pptx` | `betteroffice-pptx` |
240
+ | --- | --- | --- |
241
+ | Read shapes and text | yes | yes |
242
+ | Write shapes and text back to a file | yes | yes — see *Writing* |
243
+ | Lay slides out (line breaking, text metrics) | no | yes, display list |
244
+ | Collaborative editing (CRDT) | no | yes, Yrs |
245
+ | Undo/redo | no | yes |
246
+ | Engine | pure Python | Rust, compiled |
247
+
248
+ `python-pptx` is a far broader library and covers plenty this does not —
249
+ charts, tables, and templating in particular. If you need slides laid out, or
250
+ edits that merge across replicas, that is the gap this fills.
251
+
252
+ ## API
253
+
254
+ | | |
255
+ | --- | --- |
256
+ | `Presentation.open(data)` / `open_path(path)` | open from bytes or a path |
257
+ | `Presentation.open_collaborative(data)` | open a Yrs replica |
258
+ | `deck.snapshot()` | the whole deck as plain data |
259
+ | `deck[key]` / `deck.slide(key)` | a `Slide` by index or ID |
260
+ | `deck.slide_ids` / `slide_count` / `layouts` | deck metadata |
261
+ | `deck.width_emu` / `height_emu` | slide size in EMU |
262
+ | `deck.author` / `deck.origin` | who an edit is attributed to, and how |
263
+ | `deck.story(id)` | one text flow |
264
+ | `deck.media()` | embedded images and other binary parts |
265
+ | `insert_slide` / `delete_slide` / `move_slide` | slide order |
266
+ | `add_text_box` / `add_shape` / `remove_shape` | shape lifecycle |
267
+ | `move_shape` / `resize_shape` | shape geometry |
268
+ | `set_shape_fill` / `set_shape_stroke` / `set_shape_adjust` | shape styling |
269
+ | `insert_text` / `delete_text` / `format_text` | text editing |
270
+ | `insert_paragraph_break` | split a paragraph |
271
+ | `register_font` / `render_slide` | layout |
272
+ | `diff` / `apply_update` / `state_vector` / `state_as_update` | Yrs replicas |
273
+ | `deck.is_collaborative` / `deck.client_id` | whether this deck may exchange updates, and as whom |
274
+ | `deck.is_edited` | whether the engine has accepted an edit since open |
275
+ | `undo` / `redo` / `add_undo_barrier` / `can_undo` / `can_redo` | history |
276
+ | `deck.save()` / `save_path(path)` | serialize to PPTX — see *Writing* |
277
+
278
+ Errors raise `PptxError` or a more specific subclass: `ParseError`,
279
+ `RangeError`, `RenderError`, `InvalidUpdateError`, `CollaborativeStateError`,
280
+ `NotCollaborativeError`.
281
+ An unknown slide, shape, or story ID raises `KeyError`; a bad argument — an
282
+ unsupported geometry, an out-of-range client ID, an unknown parse limit —
283
+ raises `ValueError`.
284
+
285
+ Parser bounds can be tightened for untrusted input:
286
+
287
+ ```python
288
+ Presentation.open(untrusted, limits={"max_shapes": 5_000, "max_runs": 50_000})
289
+ ```
290
+
291
+ An unknown limit name raises `ValueError` rather than being ignored.
292
+
293
+ ## Threads
294
+
295
+ **A `Presentation` is pinned to the thread that opened it, and must also be
296
+ released there.** The engine's undo manager is not `Send`, so the class is
297
+ declared `unsendable`, and pyo3 enforces that in two ways worth knowing about:
298
+
299
+ - **Touching one from another thread raises `pyo3_runtime.PanicException`.**
300
+ That is a direct `BaseException` subclass, so `except Exception` does *not*
301
+ catch it — a worker that guards its work with `except Exception` will die
302
+ anyway.
303
+ - **Releasing one on another thread leaks it.** pyo3 skips the Rust destructor
304
+ and writes an *unraisable* `RuntimeError` instead (visible only through
305
+ `sys.unraisablehook`), stranding roughly 1.5 MB per deck. Nothing is raised
306
+ into your code.
307
+
308
+ The leak is easy to hit by accident, because the release does not have to be an
309
+ explicit `del`:
310
+
311
+ ```python
312
+ with ThreadPoolExecutor() as pool:
313
+ decks = [f.result() for f in [pool.submit(load, p) for p in paths]]
314
+ # every deck was opened on a worker and is now dropped on the main thread
315
+ ```
316
+
317
+ The cyclic garbage collector counts too. If a `Presentation` is caught in a
318
+ reference cycle — a traceback that reaches it, an object graph that points back
319
+ at itself — the collector frees it wherever it happens to run, which may be any
320
+ thread. Giving each worker its own `Presentation` therefore is *not* enough on
321
+ its own; the deck must also become garbage on its owning thread. Open, use, and
322
+ drop each deck inside one thread, and break any cycle holding it before that
323
+ thread finishes.
324
+
325
+ Engine calls hold the GIL for their duration, unlike `betteroffice-xlsx`. Only
326
+ the file I/O releases it: `open_path`'s read, and the writes in `save_path`,
327
+ `Media.write` and `DisplayList.write`.
328
+
329
+ ## Status
330
+
331
+ `0.0.x`, and the API may change before `0.1.0`. `save` writes edits back at the
332
+ XML level and copies untouched parts through byte for byte; the container is
333
+ rebuilt, so output is not byte-identical to the source — see *Writing*.
334
+
335
+ Wheels are built for Linux (x86_64, aarch64), macOS (arm64, x86_64), and Windows
336
+ (x86_64) against the stable ABI for CPython 3.9 and up.
337
+
338
+ ## Links
339
+
340
+ - [BetterOffice](https://betteroffice.dev) — the project
341
+ - [Documentation](https://docs.betteroffice.dev/docs/python)
342
+ - [Source](https://github.com/openooxml/betteroffice) — `bindings/python-pptx`
343
+ - [betteroffice-pptx on crates.io](https://crates.io/crates/betteroffice-pptx) — the engine this wraps
344
+
345
+ Apache-2.0.
346
+