exactdoc 0.3.0b1__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 (51) hide show
  1. exactdoc-0.3.0b1/LICENSE +201 -0
  2. exactdoc-0.3.0b1/MANIFEST.in +12 -0
  3. exactdoc-0.3.0b1/PKG-INFO +242 -0
  4. exactdoc-0.3.0b1/README.md +195 -0
  5. exactdoc-0.3.0b1/exactdoc/__init__.py +55 -0
  6. exactdoc-0.3.0b1/exactdoc/_base14_widths.py +244 -0
  7. exactdoc-0.3.0b1/exactdoc/_clone_widths.py +311 -0
  8. exactdoc-0.3.0b1/exactdoc/_docx_speed.py +148 -0
  9. exactdoc-0.3.0b1/exactdoc/_pagelines_pool.py +126 -0
  10. exactdoc-0.3.0b1/exactdoc/_pagelines_worker.py +23 -0
  11. exactdoc-0.3.0b1/exactdoc/backend.py +535 -0
  12. exactdoc-0.3.0b1/exactdoc/batch.py +258 -0
  13. exactdoc-0.3.0b1/exactdoc/cli.py +622 -0
  14. exactdoc-0.3.0b1/exactdoc/convert.py +348 -0
  15. exactdoc-0.3.0b1/exactdoc/diagnose.py +200 -0
  16. exactdoc-0.3.0b1/exactdoc/dialect.py +1384 -0
  17. exactdoc-0.3.0b1/exactdoc/docxout.py +6996 -0
  18. exactdoc-0.3.0b1/exactdoc/errors.py +298 -0
  19. exactdoc-0.3.0b1/exactdoc/fonts.py +1090 -0
  20. exactdoc-0.3.0b1/exactdoc/furniture.py +259 -0
  21. exactdoc-0.3.0b1/exactdoc/gdocs.py +358 -0
  22. exactdoc-0.3.0b1/exactdoc/gdocs_metrics.py +90 -0
  23. exactdoc-0.3.0b1/exactdoc/hyphen.py +213 -0
  24. exactdoc-0.3.0b1/exactdoc/infer.py +11806 -0
  25. exactdoc-0.3.0b1/exactdoc/input.py +251 -0
  26. exactdoc-0.3.0b1/exactdoc/io.py +250 -0
  27. exactdoc-0.3.0b1/exactdoc/ladder.py +750 -0
  28. exactdoc-0.3.0b1/exactdoc/layout.py +473 -0
  29. exactdoc-0.3.0b1/exactdoc/lists.py +429 -0
  30. exactdoc-0.3.0b1/exactdoc/metrics.py +357 -0
  31. exactdoc-0.3.0b1/exactdoc/model.py +378 -0
  32. exactdoc-0.3.0b1/exactdoc/notes.py +669 -0
  33. exactdoc-0.3.0b1/exactdoc/options.py +443 -0
  34. exactdoc-0.3.0b1/exactdoc/pagefit.py +457 -0
  35. exactdoc-0.3.0b1/exactdoc/parse.py +359 -0
  36. exactdoc-0.3.0b1/exactdoc/parse_pdfium.py +5161 -0
  37. exactdoc-0.3.0b1/exactdoc/refine.py +1148 -0
  38. exactdoc-0.3.0b1/exactdoc/result.py +135 -0
  39. exactdoc-0.3.0b1/exactdoc/scan.py +219 -0
  40. exactdoc-0.3.0b1/exactdoc/structures.py +579 -0
  41. exactdoc-0.3.0b1/exactdoc/targets.py +100 -0
  42. exactdoc-0.3.0b1/exactdoc/tracking.py +248 -0
  43. exactdoc-0.3.0b1/exactdoc/verify.py +558 -0
  44. exactdoc-0.3.0b1/exactdoc.egg-info/PKG-INFO +242 -0
  45. exactdoc-0.3.0b1/exactdoc.egg-info/SOURCES.txt +49 -0
  46. exactdoc-0.3.0b1/exactdoc.egg-info/dependency_links.txt +1 -0
  47. exactdoc-0.3.0b1/exactdoc.egg-info/entry_points.txt +3 -0
  48. exactdoc-0.3.0b1/exactdoc.egg-info/requires.txt +17 -0
  49. exactdoc-0.3.0b1/exactdoc.egg-info/top_level.txt +1 -0
  50. exactdoc-0.3.0b1/pyproject.toml +80 -0
  51. exactdoc-0.3.0b1/setup.cfg +4 -0
@@ -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 Ebin Babu Thomas
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,12 @@
1
+ # What goes into the source distribution (sdist) uploaded to PyPI.
2
+ #
3
+ # The sdist is the wheel's source plus what a packager needs to rebuild it:
4
+ # exactdoc/, pyproject.toml, README.md and LICENSE, which setuptools includes
5
+ # on its own. Everything else stays in the repository.
6
+ #
7
+ # tests/ is pruned explicitly because setuptools adds tests/test*.py by
8
+ # default, and those files cannot run from an sdist: they need testkit/, the
9
+ # frozen corpus and the golden IR, none of which belong in a package download.
10
+ # scripts/check_dist.py enforces this list on every build (CI and release).
11
+ prune tests
12
+ global-exclude *.py[cod] __pycache__
@@ -0,0 +1,242 @@
1
+ Metadata-Version: 2.4
2
+ Name: exactdoc
3
+ Version: 0.3.0b1
4
+ Summary: High-fidelity PDF to DOCX that survives Google Docs, with a render-back diff that proves it
5
+ Author: Ebin Babu Thomas
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/ebt55/exactdoc
8
+ Project-URL: Documentation, https://github.com/ebt55/exactdoc/blob/main/docs/usage.md
9
+ Project-URL: Changelog, https://github.com/ebt55/exactdoc/blob/main/CHANGELOG.md
10
+ Project-URL: Source, https://github.com/ebt55/exactdoc
11
+ Project-URL: Issues, https://github.com/ebt55/exactdoc/issues
12
+ Keywords: pdf,docx,pdf-to-docx,pdf-to-word,google-docs,document-conversion,ooxml,layout-analysis,pdfium,whitepaper,research-paper
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: End Users/Desktop
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Operating System :: MacOS
18
+ Classifier: Operating System :: POSIX :: Linux
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Programming Language :: Python :: 3.14
27
+ Classifier: Topic :: Text Processing :: Markup
28
+ Classifier: Topic :: Office/Business :: Office Suites
29
+ Requires-Python: >=3.9
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: pypdfium2>=4.25
33
+ Requires-Dist: python-docx>=1.1
34
+ Requires-Dist: numpy>=1.24
35
+ Requires-Dist: pillow>=10.0
36
+ Requires-Dist: lxml>=4.9
37
+ Provides-Extra: test
38
+ Requires-Dist: reportlab>=4.0; extra == "test"
39
+ Requires-Dist: fpdf2>=2.7; extra == "test"
40
+ Provides-Extra: mupdf
41
+ Requires-Dist: pymupdf>=1.23; extra == "mupdf"
42
+ Provides-Extra: gdocs
43
+ Requires-Dist: google-api-python-client>=2.100; extra == "gdocs"
44
+ Requires-Dist: google-auth-httplib2>=0.1; extra == "gdocs"
45
+ Requires-Dist: google-auth-oauthlib>=1.1; extra == "gdocs"
46
+ Dynamic: license-file
47
+
48
+ # exactdoc
49
+
50
+ **Turn a PDF into a Word document that looks like the original and that you
51
+ can actually edit.**
52
+
53
+ exactdoc writes a DOCX made of real headings, paragraphs, lists, tables,
54
+ footnotes and page headers, and lays them out so each page matches the PDF.
55
+ Its output is measured by opening it in Microsoft Word, LibreOffice and Google
56
+ Docs and comparing every page with the original. It runs entirely on your
57
+ machine: no telemetry, no account, and no network unless you ask for the
58
+ optional Google Docs measurement ([details](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/install.md#what-talks-to-the-network)).
59
+
60
+ ![Animation. On the left, page 1 of a whitepaper as the original PDF. On the right, the DOCX exactdoc made from it, shown in turn as Microsoft Word, Google Docs and LibreOffice lay it out. All four pages look almost the same.](https://raw.githubusercontent.com/ebt55/exactdoc/v0.3.0b1/docs/images/hero-readers.gif)
61
+
62
+ <sub>Page 1 of one of the project's test whitepapers, converted with the default
63
+ settings; Google Docs shows the DOCX made for it ([still image](https://raw.githubusercontent.com/ebt55/exactdoc/v0.3.0b1/docs/images/hero-readers.png),
64
+ [how it was made](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/images/README.md)). Small differences remain: Google Docs
65
+ adds a thin white strip above the dark band, and the footer's page number sits
66
+ further left than in the PDF, set larger in Word and Google Docs.</sub>
67
+
68
+ > **Beta (0.3.0b1), on PyPI.** Not announced yet: see the results on
69
+ > [documents it has never seen](#tested-on-documents-it-has-never-seen) below.
70
+
71
+ ## Install
72
+
73
+ You need Python 3.9 or newer.
74
+
75
+ ```bash
76
+ pip install --pre exactdoc
77
+ exactdoc --version
78
+ ```
79
+
80
+ Optional, and recommended: **[LibreOffice](https://www.libreoffice.org/download/)**
81
+ (free). When it is installed, exactdoc opens its own DOCX in it, compares each
82
+ page with the PDF and corrects page breaks and spacing. Without it, exactdoc
83
+ converts in one pass and says so. [docs/install.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/install.md) covers the
84
+ fonts LibreOffice needs on Linux, how long the check takes, and the optional
85
+ extras.
86
+
87
+ ## Quick start
88
+
89
+ ```bash
90
+ exactdoc report.pdf # writes report.docx next to it
91
+ exactdoc report.pdf --output-profile gdocs --refine 0 # a DOCX made for Google Docs
92
+ exactdoc --input-dir pdfs --out-dir docx --recursive # a whole folder
93
+ ```
94
+
95
+ ```python
96
+ from exactdoc import convert
97
+ convert("report.pdf", "report.docx") # with LibreOffice's check
98
+ convert("report.pdf", "report.docx", refine_rounds=0, oracle="none") # without LibreOffice
99
+ ```
100
+
101
+ exactdoc never replaces a file you did not name. The Google Docs option writes
102
+ the same document in a form Google Docs' importer reads correctly; it is still
103
+ made offline, and you upload it to Drive yourself. Every option, the Python API
104
+ and the exit codes are in [docs/usage.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/usage.md).
105
+
106
+ ## What you get
107
+
108
+ The DOCX is built from the same pieces you would use to write the document in
109
+ Word yourself, not from text boxes pinned to the page:
110
+
111
+ ![Page 2 of the whitepaper's DOCX with its parts labelled: a header that repeats on every page, a bulleted list, Heading 2 and Heading 1 styles, a table with real rows and cells, a chart kept as a picture, and a footer with a live page number.](https://raw.githubusercontent.com/ebt55/exactdoc/v0.3.0b1/docs/images/editable-structure.png)
112
+
113
+ - **Headings** use Word's heading styles, so the navigation pane and Google
114
+ Docs' outline work.
115
+ - **Paragraphs** flow and re-wrap when you edit them.
116
+ - **Lists** are real bulleted and numbered lists.
117
+ - **Tables** are real tables, with merged cells and rows that run over pages.
118
+ - **Headers and footers** repeat on every page, with live page numbers.
119
+ **Footnotes** are real Word footnotes (plain text in the Google Docs output,
120
+ because Docs moves real ones), and links still work.
121
+ - **Charts, logos and artwork** stay pictures, placed where the PDF has them.
122
+
123
+ ## What works, and what does not yet
124
+
125
+ What exactdoc promises depends on the program that made the PDF. Documents
126
+ written as flowing text in **Word, Google Docs, LibreOffice or LaTeX** are
127
+ promised. Designed layouts are not, yet. Numbers below are from the release
128
+ measurement ([record](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/evidence/release-documents-2026-10-11.json)) and,
129
+ where they say "never seen", from [the test below](#tested-on-documents-it-has-never-seen)
130
+ ([results](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/evidence/holdout2-2026-10-11.json)).
131
+
132
+ | Kind of PDF | Today |
133
+ |---|---|
134
+ | Letters, memos, policies, syllabi and other documents of up to 20 pages written in Word, Google Docs, LibreOffice or LaTeX | Works well |
135
+ | Résumés | Mostly: of 8 never seen, 5 kept their page count and words; a federal-style résumé went from 3 pages to 6 |
136
+ | Reports over 20 pages written in Word | Mixed: of 4 never seen, one came back exact; three US government audit reports gained 2–4 pages, with about a third of their words on the right page |
137
+ | Long documents written in LaTeX | Mostly: two manuals never seen came back page for page; a 77-page technical report came back with 78 pages and 42% of its words on the right page |
138
+ | Tables, simple two-column pages, headers, footers, footnotes, links | Works well |
139
+ | Latin, Cyrillic and Greek text | Works well |
140
+ | Chinese, Japanese and Korean text | Partly: the text survives, but some runs become pictures |
141
+ | Arabic, Hebrew and Persian (right-to-left) | Partly: right-to-left paragraphs in reading order; pages can grow, and the Google Docs output is not yet right-to-left |
142
+ | Long documents opened in Google Docs | Mostly: some gain pages (IRS Publication 15: 62 pages for 59) |
143
+ | Designed reports and annual reports (InDesign, Affinity, QuarkXPress, Publisher) | Not yet: the text stays editable, but the layout does not hold |
144
+ | Multi-column booklets (IRS, GPO, Federal Register style) | Not yet: IRS Publication 501 grows from 31 pages to 45 in LibreOffice |
145
+ | Dense journal papers, equations | Not yet: equations come apart, and pages can be added |
146
+ | Slide decks, brochures, posters | Not yet |
147
+ | Web pages printed from a browser | Not yet: a 7-page Wikipedia article printed from Chrome came back with 8 pages and a third of its words on the right page |
148
+ | Scans without a text layer, fillable forms, over 250 pages | Refused with a clear message and exit code (no OCR is built in; `--max-pages` raises the cap) |
149
+
150
+ <table>
151
+ <tr>
152
+ <td width="50%"><img src="https://raw.githubusercontent.com/ebt55/exactdoc/v0.3.0b1/docs/images/works-tables.png" alt="A page of tables, PDF beside DOCX. A table with merged header cells, a nested table and a long striped table look the same in both."></td>
153
+ <td width="50%"><img src="https://raw.githubusercontent.com/ebt55/exactdoc/v0.3.0b1/docs/images/not-yet-dense-paper.png" alt="Page 1 of a two-column arXiv paper beside its DOCX. The text and columns match, but a summation equation is broken apart, outlined in red."></td>
154
+ </tr>
155
+ <tr>
156
+ <td><b>Works:</b> tables become real Word tables, merged cells included.</td>
157
+ <td><b>Not yet:</b> in a dense arXiv paper (CC BY 4.0) the text converts, but equations come apart.</td>
158
+ </tr>
159
+ </table>
160
+
161
+ To see which program made a PDF, open **File → Properties** in a PDF viewer and
162
+ read the Producer and Application fields, or run `exactdoc --diagnose your.pdf`,
163
+ which prints them without any of the document's text. The full list, with
164
+ numbers, is in [docs/deep-dive/limitations.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/deep-dive/limitations.md);
165
+ more side-by-side pictures are in [docs/examples.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/examples.md).
166
+
167
+ ## How we know
168
+
169
+ Measured, not eyeballed. Every change must pass 16 frozen test documents,
170
+ gated on every push in CI inside the pinned measurement image, and
171
+ each milestone converts 95 frozen PDFs (those 16 and 79 more, most of them
172
+ public real-world documents), opens every DOCX in LibreOffice, Microsoft Word
173
+ and Google Docs, and compares it with the PDF page by page. In the final
174
+ measurement for the beta ([record](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/evidence/release-documents-2026-10-11.json),
175
+ [scorecard](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/evidence/beta-readiness-2026-10-11.json)):
176
+
177
+ - all 41 promised documents of up to 20 pages kept exactly their page count in
178
+ all three;
179
+ - of the 21 promised documents over 20 pages, all 21 in LibreOffice and Word,
180
+ and 18 in Google Docs, kept their page count within 2% (or one page) with at
181
+ least 85% of their words on the right page;
182
+ - across everything, including the kinds marked "Not yet", Word opened all 90
183
+ DOCX files without asking to repair one, and in Google Docs
184
+ 66 of the 90 compared came back with exactly the right number of pages.
185
+ The other five are PDFs exactdoc refuses on purpose.
186
+
187
+ These are the documents exactdoc was developed against, so they show how well
188
+ it does on PDFs it has seen. How the measurement works:
189
+ [docs/deep-dive/measured-state.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/deep-dive/measured-state.md).
190
+
191
+ ### Tested on documents it has never seen
192
+
193
+ Before the release, 32 public PDFs never used in development were sealed and
194
+ then converted once, on the release candidate. 23 were classed as promised
195
+ before the run, including the web page now marked "Not yet". The verdicts were
196
+ the same in LibreOffice and Word; Google Docs was not part of this test ([results](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/evidence/holdout2-2026-10-11.txt), [data](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/evidence/holdout2-2026-10-11.json)):
197
+
198
+ - **No crashes, and Word opened all 32 cleanly: pass.**
199
+ - **Short promised documents: fail.** 13 of 16 kept exactly their page count, but only 12 of 16 had at least 90% of their words on the right page, below the 80% bar. The four misses: a CMU sample résumé set (9 pages for 8), a federal-style résumé, a LaTeX résumé (88% of words) and a Wikipedia article printed from Chrome (8 pages for 7).
200
+ - **No unusable result: fail.** The federal-style résumé came back with 6 pages for 3 and about a third of its text on the right page.
201
+ - **Long promised documents (reported):** a median page-count error of 1.3%; 4 of 7 within 2% (or one page), and 3 of 7 with at least 85% of their words on the right page.
202
+
203
+ This did not meet the bar we set in advance for announcing it; 0.3.0b2 is the
204
+ fix release.
205
+
206
+ ## Fonts
207
+
208
+ The DOCX names only fonts that a standard Windows 10 or 11 computer with
209
+ Microsoft Office has, with one exception: Chinese, Japanese, Korean, Arabic,
210
+ Hebrew, Persian and Thai text keeps the PDF's own font name, so a reader who
211
+ has that font sees it and one who does not gets Word's default for the script.
212
+ The fonts the test documents name this way are `Noto Sans CJK JP`,
213
+ `IPAPGothic`, `WenQuanYi Zen Hei`, `DFKai-SB`, `DejaVu Sans`,
214
+ `Noto Naskh Arabic`, `David`, `Narkisim`, `BNazanin` and `Thonburi`.
215
+
216
+ ## Contributing
217
+
218
+ PRs welcome. See [CONTRIBUTING.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/CONTRIBUTING.md) for the one-command quality
219
+ check every PR runs. If a conversion goes wrong,
220
+ [report it](https://github.com/ebt55/exactdoc/issues/new?template=bad-conversion.yml)
221
+ with the output of `exactdoc --diagnose your.pdf` instead of the PDF itself.
222
+
223
+ ## Learn more
224
+
225
+ | | |
226
+ |---|---|
227
+ | [docs/install.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/install.md) | LibreOffice and its fonts, timing, the optional extras, what talks to the network |
228
+ | [docs/usage.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/usage.md) | Every option, the Python API, batch mode, exit codes |
229
+ | [docs/deep-dive/limitations.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/deep-dive/limitations.md) | What does not work yet, with numbers |
230
+ | [docs/examples.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/examples.md) | More pages side by side, the good and the bad |
231
+ | [docs/deep-dive/measured-state.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/deep-dive/measured-state.md) | How the numbers are measured |
232
+ | [CHANGELOG.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/CHANGELOG.md) | What changed, release by release |
233
+ | [SECURITY.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/SECURITY.md) | Reporting a security problem privately |
234
+ | [docs/README.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/README.md) | Index of every deeper document |
235
+
236
+ ## Licence
237
+
238
+ exactdoc is [Apache-2.0](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/LICENSE). A default install pulls in no copyleft code.
239
+ The optional `mupdf` extra (`pip install "exactdoc[mupdf]"`) adds PyMuPDF, which is
240
+ AGPL-3.0; it is only a reference for measurements and does not change the output.
241
+ Details: [docs/deep-dive/licensing.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/deep-dive/licensing.md) and
242
+ [docs/license-audit.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/license-audit.md).
@@ -0,0 +1,195 @@
1
+ # exactdoc
2
+
3
+ **Turn a PDF into a Word document that looks like the original and that you
4
+ can actually edit.**
5
+
6
+ exactdoc writes a DOCX made of real headings, paragraphs, lists, tables,
7
+ footnotes and page headers, and lays them out so each page matches the PDF.
8
+ Its output is measured by opening it in Microsoft Word, LibreOffice and Google
9
+ Docs and comparing every page with the original. It runs entirely on your
10
+ machine: no telemetry, no account, and no network unless you ask for the
11
+ optional Google Docs measurement ([details](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/install.md#what-talks-to-the-network)).
12
+
13
+ ![Animation. On the left, page 1 of a whitepaper as the original PDF. On the right, the DOCX exactdoc made from it, shown in turn as Microsoft Word, Google Docs and LibreOffice lay it out. All four pages look almost the same.](https://raw.githubusercontent.com/ebt55/exactdoc/v0.3.0b1/docs/images/hero-readers.gif)
14
+
15
+ <sub>Page 1 of one of the project's test whitepapers, converted with the default
16
+ settings; Google Docs shows the DOCX made for it ([still image](https://raw.githubusercontent.com/ebt55/exactdoc/v0.3.0b1/docs/images/hero-readers.png),
17
+ [how it was made](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/images/README.md)). Small differences remain: Google Docs
18
+ adds a thin white strip above the dark band, and the footer's page number sits
19
+ further left than in the PDF, set larger in Word and Google Docs.</sub>
20
+
21
+ > **Beta (0.3.0b1), on PyPI.** Not announced yet: see the results on
22
+ > [documents it has never seen](#tested-on-documents-it-has-never-seen) below.
23
+
24
+ ## Install
25
+
26
+ You need Python 3.9 or newer.
27
+
28
+ ```bash
29
+ pip install --pre exactdoc
30
+ exactdoc --version
31
+ ```
32
+
33
+ Optional, and recommended: **[LibreOffice](https://www.libreoffice.org/download/)**
34
+ (free). When it is installed, exactdoc opens its own DOCX in it, compares each
35
+ page with the PDF and corrects page breaks and spacing. Without it, exactdoc
36
+ converts in one pass and says so. [docs/install.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/install.md) covers the
37
+ fonts LibreOffice needs on Linux, how long the check takes, and the optional
38
+ extras.
39
+
40
+ ## Quick start
41
+
42
+ ```bash
43
+ exactdoc report.pdf # writes report.docx next to it
44
+ exactdoc report.pdf --output-profile gdocs --refine 0 # a DOCX made for Google Docs
45
+ exactdoc --input-dir pdfs --out-dir docx --recursive # a whole folder
46
+ ```
47
+
48
+ ```python
49
+ from exactdoc import convert
50
+ convert("report.pdf", "report.docx") # with LibreOffice's check
51
+ convert("report.pdf", "report.docx", refine_rounds=0, oracle="none") # without LibreOffice
52
+ ```
53
+
54
+ exactdoc never replaces a file you did not name. The Google Docs option writes
55
+ the same document in a form Google Docs' importer reads correctly; it is still
56
+ made offline, and you upload it to Drive yourself. Every option, the Python API
57
+ and the exit codes are in [docs/usage.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/usage.md).
58
+
59
+ ## What you get
60
+
61
+ The DOCX is built from the same pieces you would use to write the document in
62
+ Word yourself, not from text boxes pinned to the page:
63
+
64
+ ![Page 2 of the whitepaper's DOCX with its parts labelled: a header that repeats on every page, a bulleted list, Heading 2 and Heading 1 styles, a table with real rows and cells, a chart kept as a picture, and a footer with a live page number.](https://raw.githubusercontent.com/ebt55/exactdoc/v0.3.0b1/docs/images/editable-structure.png)
65
+
66
+ - **Headings** use Word's heading styles, so the navigation pane and Google
67
+ Docs' outline work.
68
+ - **Paragraphs** flow and re-wrap when you edit them.
69
+ - **Lists** are real bulleted and numbered lists.
70
+ - **Tables** are real tables, with merged cells and rows that run over pages.
71
+ - **Headers and footers** repeat on every page, with live page numbers.
72
+ **Footnotes** are real Word footnotes (plain text in the Google Docs output,
73
+ because Docs moves real ones), and links still work.
74
+ - **Charts, logos and artwork** stay pictures, placed where the PDF has them.
75
+
76
+ ## What works, and what does not yet
77
+
78
+ What exactdoc promises depends on the program that made the PDF. Documents
79
+ written as flowing text in **Word, Google Docs, LibreOffice or LaTeX** are
80
+ promised. Designed layouts are not, yet. Numbers below are from the release
81
+ measurement ([record](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/evidence/release-documents-2026-10-11.json)) and,
82
+ where they say "never seen", from [the test below](#tested-on-documents-it-has-never-seen)
83
+ ([results](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/evidence/holdout2-2026-10-11.json)).
84
+
85
+ | Kind of PDF | Today |
86
+ |---|---|
87
+ | Letters, memos, policies, syllabi and other documents of up to 20 pages written in Word, Google Docs, LibreOffice or LaTeX | Works well |
88
+ | Résumés | Mostly: of 8 never seen, 5 kept their page count and words; a federal-style résumé went from 3 pages to 6 |
89
+ | Reports over 20 pages written in Word | Mixed: of 4 never seen, one came back exact; three US government audit reports gained 2–4 pages, with about a third of their words on the right page |
90
+ | Long documents written in LaTeX | Mostly: two manuals never seen came back page for page; a 77-page technical report came back with 78 pages and 42% of its words on the right page |
91
+ | Tables, simple two-column pages, headers, footers, footnotes, links | Works well |
92
+ | Latin, Cyrillic and Greek text | Works well |
93
+ | Chinese, Japanese and Korean text | Partly: the text survives, but some runs become pictures |
94
+ | Arabic, Hebrew and Persian (right-to-left) | Partly: right-to-left paragraphs in reading order; pages can grow, and the Google Docs output is not yet right-to-left |
95
+ | Long documents opened in Google Docs | Mostly: some gain pages (IRS Publication 15: 62 pages for 59) |
96
+ | Designed reports and annual reports (InDesign, Affinity, QuarkXPress, Publisher) | Not yet: the text stays editable, but the layout does not hold |
97
+ | Multi-column booklets (IRS, GPO, Federal Register style) | Not yet: IRS Publication 501 grows from 31 pages to 45 in LibreOffice |
98
+ | Dense journal papers, equations | Not yet: equations come apart, and pages can be added |
99
+ | Slide decks, brochures, posters | Not yet |
100
+ | Web pages printed from a browser | Not yet: a 7-page Wikipedia article printed from Chrome came back with 8 pages and a third of its words on the right page |
101
+ | Scans without a text layer, fillable forms, over 250 pages | Refused with a clear message and exit code (no OCR is built in; `--max-pages` raises the cap) |
102
+
103
+ <table>
104
+ <tr>
105
+ <td width="50%"><img src="https://raw.githubusercontent.com/ebt55/exactdoc/v0.3.0b1/docs/images/works-tables.png" alt="A page of tables, PDF beside DOCX. A table with merged header cells, a nested table and a long striped table look the same in both."></td>
106
+ <td width="50%"><img src="https://raw.githubusercontent.com/ebt55/exactdoc/v0.3.0b1/docs/images/not-yet-dense-paper.png" alt="Page 1 of a two-column arXiv paper beside its DOCX. The text and columns match, but a summation equation is broken apart, outlined in red."></td>
107
+ </tr>
108
+ <tr>
109
+ <td><b>Works:</b> tables become real Word tables, merged cells included.</td>
110
+ <td><b>Not yet:</b> in a dense arXiv paper (CC BY 4.0) the text converts, but equations come apart.</td>
111
+ </tr>
112
+ </table>
113
+
114
+ To see which program made a PDF, open **File → Properties** in a PDF viewer and
115
+ read the Producer and Application fields, or run `exactdoc --diagnose your.pdf`,
116
+ which prints them without any of the document's text. The full list, with
117
+ numbers, is in [docs/deep-dive/limitations.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/deep-dive/limitations.md);
118
+ more side-by-side pictures are in [docs/examples.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/examples.md).
119
+
120
+ ## How we know
121
+
122
+ Measured, not eyeballed. Every change must pass 16 frozen test documents,
123
+ gated on every push in CI inside the pinned measurement image, and
124
+ each milestone converts 95 frozen PDFs (those 16 and 79 more, most of them
125
+ public real-world documents), opens every DOCX in LibreOffice, Microsoft Word
126
+ and Google Docs, and compares it with the PDF page by page. In the final
127
+ measurement for the beta ([record](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/evidence/release-documents-2026-10-11.json),
128
+ [scorecard](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/evidence/beta-readiness-2026-10-11.json)):
129
+
130
+ - all 41 promised documents of up to 20 pages kept exactly their page count in
131
+ all three;
132
+ - of the 21 promised documents over 20 pages, all 21 in LibreOffice and Word,
133
+ and 18 in Google Docs, kept their page count within 2% (or one page) with at
134
+ least 85% of their words on the right page;
135
+ - across everything, including the kinds marked "Not yet", Word opened all 90
136
+ DOCX files without asking to repair one, and in Google Docs
137
+ 66 of the 90 compared came back with exactly the right number of pages.
138
+ The other five are PDFs exactdoc refuses on purpose.
139
+
140
+ These are the documents exactdoc was developed against, so they show how well
141
+ it does on PDFs it has seen. How the measurement works:
142
+ [docs/deep-dive/measured-state.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/deep-dive/measured-state.md).
143
+
144
+ ### Tested on documents it has never seen
145
+
146
+ Before the release, 32 public PDFs never used in development were sealed and
147
+ then converted once, on the release candidate. 23 were classed as promised
148
+ before the run, including the web page now marked "Not yet". The verdicts were
149
+ the same in LibreOffice and Word; Google Docs was not part of this test ([results](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/evidence/holdout2-2026-10-11.txt), [data](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/evidence/holdout2-2026-10-11.json)):
150
+
151
+ - **No crashes, and Word opened all 32 cleanly: pass.**
152
+ - **Short promised documents: fail.** 13 of 16 kept exactly their page count, but only 12 of 16 had at least 90% of their words on the right page, below the 80% bar. The four misses: a CMU sample résumé set (9 pages for 8), a federal-style résumé, a LaTeX résumé (88% of words) and a Wikipedia article printed from Chrome (8 pages for 7).
153
+ - **No unusable result: fail.** The federal-style résumé came back with 6 pages for 3 and about a third of its text on the right page.
154
+ - **Long promised documents (reported):** a median page-count error of 1.3%; 4 of 7 within 2% (or one page), and 3 of 7 with at least 85% of their words on the right page.
155
+
156
+ This did not meet the bar we set in advance for announcing it; 0.3.0b2 is the
157
+ fix release.
158
+
159
+ ## Fonts
160
+
161
+ The DOCX names only fonts that a standard Windows 10 or 11 computer with
162
+ Microsoft Office has, with one exception: Chinese, Japanese, Korean, Arabic,
163
+ Hebrew, Persian and Thai text keeps the PDF's own font name, so a reader who
164
+ has that font sees it and one who does not gets Word's default for the script.
165
+ The fonts the test documents name this way are `Noto Sans CJK JP`,
166
+ `IPAPGothic`, `WenQuanYi Zen Hei`, `DFKai-SB`, `DejaVu Sans`,
167
+ `Noto Naskh Arabic`, `David`, `Narkisim`, `BNazanin` and `Thonburi`.
168
+
169
+ ## Contributing
170
+
171
+ PRs welcome. See [CONTRIBUTING.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/CONTRIBUTING.md) for the one-command quality
172
+ check every PR runs. If a conversion goes wrong,
173
+ [report it](https://github.com/ebt55/exactdoc/issues/new?template=bad-conversion.yml)
174
+ with the output of `exactdoc --diagnose your.pdf` instead of the PDF itself.
175
+
176
+ ## Learn more
177
+
178
+ | | |
179
+ |---|---|
180
+ | [docs/install.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/install.md) | LibreOffice and its fonts, timing, the optional extras, what talks to the network |
181
+ | [docs/usage.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/usage.md) | Every option, the Python API, batch mode, exit codes |
182
+ | [docs/deep-dive/limitations.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/deep-dive/limitations.md) | What does not work yet, with numbers |
183
+ | [docs/examples.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/examples.md) | More pages side by side, the good and the bad |
184
+ | [docs/deep-dive/measured-state.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/deep-dive/measured-state.md) | How the numbers are measured |
185
+ | [CHANGELOG.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/CHANGELOG.md) | What changed, release by release |
186
+ | [SECURITY.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/SECURITY.md) | Reporting a security problem privately |
187
+ | [docs/README.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/README.md) | Index of every deeper document |
188
+
189
+ ## Licence
190
+
191
+ exactdoc is [Apache-2.0](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/LICENSE). A default install pulls in no copyleft code.
192
+ The optional `mupdf` extra (`pip install "exactdoc[mupdf]"`) adds PyMuPDF, which is
193
+ AGPL-3.0; it is only a reference for measurements and does not change the output.
194
+ Details: [docs/deep-dive/licensing.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/deep-dive/licensing.md) and
195
+ [docs/license-audit.md](https://github.com/ebt55/exactdoc/blob/v0.3.0b1/docs/license-audit.md).