evupdf 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. evupdf-0.1.0/.gitignore +14 -0
  2. evupdf-0.1.0/CHANGELOG.md +15 -0
  3. evupdf-0.1.0/LICENSE +21 -0
  4. evupdf-0.1.0/PKG-INFO +158 -0
  5. evupdf-0.1.0/README.md +129 -0
  6. evupdf-0.1.0/THIRD_PARTY_NOTICES.md +13 -0
  7. evupdf-0.1.0/docs/configuration.md +30 -0
  8. evupdf-0.1.0/docs/extraction.md +40 -0
  9. evupdf-0.1.0/docs/installation.md +23 -0
  10. evupdf-0.1.0/docs/output-schema.md +57 -0
  11. evupdf-0.1.0/docs/quickstart.md +28 -0
  12. evupdf-0.1.0/docs/troubleshooting.md +37 -0
  13. evupdf-0.1.0/examples/basic_extract.py +30 -0
  14. evupdf-0.1.0/plan.md +696 -0
  15. evupdf-0.1.0/pyproject.toml +84 -0
  16. evupdf-0.1.0/src/evupdf/__init__.py +47 -0
  17. evupdf-0.1.0/src/evupdf/client.py +79 -0
  18. evupdf-0.1.0/src/evupdf/config.py +31 -0
  19. evupdf-0.1.0/src/evupdf/exceptions.py +31 -0
  20. evupdf-0.1.0/src/evupdf/extractors/__init__.py +1 -0
  21. evupdf-0.1.0/src/evupdf/extractors/base.py +23 -0
  22. evupdf-0.1.0/src/evupdf/extractors/pymupdf.py +304 -0
  23. evupdf-0.1.0/src/evupdf/models/__init__.py +16 -0
  24. evupdf-0.1.0/src/evupdf/models/block.py +39 -0
  25. evupdf-0.1.0/src/evupdf/models/document.py +24 -0
  26. evupdf-0.1.0/src/evupdf/models/extraction.py +87 -0
  27. evupdf-0.1.0/src/evupdf/models/page.py +35 -0
  28. evupdf-0.1.0/src/evupdf/py.typed +0 -0
  29. evupdf-0.1.0/src/evupdf/utils/__init__.py +1 -0
  30. evupdf-0.1.0/src/evupdf/utils/dates.py +96 -0
  31. evupdf-0.1.0/src/evupdf/utils/files.py +54 -0
  32. evupdf-0.1.0/src/evupdf/utils/hashing.py +16 -0
  33. evupdf-0.1.0/tests/conftest.py +1 -0
  34. evupdf-0.1.0/tests/integration/test_extract.py +243 -0
  35. evupdf-0.1.0/tests/pdf_factory.py +55 -0
  36. evupdf-0.1.0/tests/unit/test_config.py +29 -0
  37. evupdf-0.1.0/tests/unit/test_dates.py +29 -0
  38. evupdf-0.1.0/tests/unit/test_files.py +57 -0
  39. evupdf-0.1.0/tests/unit/test_hashing.py +14 -0
  40. evupdf-0.1.0/tests/unit/test_models.py +104 -0
  41. evupdf-0.1.0/tests/unit/test_public_api.py +11 -0
@@ -0,0 +1,14 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .eggs/
5
+ build/
6
+ dist/
7
+ .venv/
8
+ venv/
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+ .pytest_cache/
12
+ .coverage
13
+ htmlcov/
14
+ .DS_Store
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — 2026-12-01
4
+
5
+ First usable release. Digital PDFs can be extracted offline, without an API key.
6
+
7
+ ### Added
8
+
9
+ - `PDFExtractor.extract()` reads a local PDF with PyMuPDF and returns a validated result.
10
+ - Raw results include metadata, page size, rotation, text blocks, and bounding boxes.
11
+ - `ExtractionResult.to_json()` and `save_json()` write schema version `1.0`.
12
+ - Pages with little or no extractable text set `ocr_recommended` and add a warning. OCR is not run.
13
+ - Configurable file-size, page-count, and page-dimension limits.
14
+ - Typed errors for a missing file, a bad extension, a malformed PDF, an encrypted PDF, and documents over those limits.
15
+ - A password can unlock an encrypted PDF and is not copied into the result.
evupdf-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 EvuPDF contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
evupdf-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,158 @@
1
+ Metadata-Version: 2.5
2
+ Name: evupdf
3
+ Version: 0.1.0
4
+ Summary: Extract text, layout, and metadata from digital PDFs into typed JSON.
5
+ Author: EvuPDF contributors
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Keywords: document,extraction,pdf,pymupdf,text
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Text Processing
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: pydantic>=2
23
+ Requires-Dist: pymupdf<2,>=1.26
24
+ Provides-Extra: dev
25
+ Requires-Dist: mypy>=1.13; extra == 'dev'
26
+ Requires-Dist: pytest>=8.0; extra == 'dev'
27
+ Requires-Dist: ruff>=0.8; extra == 'dev'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # EvuPDF
31
+
32
+ EvuPDF extracts text, page geometry, and metadata from digital PDFs. The result is a typed Python object with bounding boxes, a file hash, and JSON export. Core extraction works offline after installation. It does not call an AI provider.
33
+
34
+ ```bash
35
+ pip install evupdf
36
+ ```
37
+
38
+ ```python
39
+ from evupdf import PDFExtractor
40
+
41
+ extractor = PDFExtractor()
42
+ result = extractor.extract("sample.pdf")
43
+
44
+ result.save_json("sample.json")
45
+ print(result.text)
46
+ ```
47
+
48
+ Version 0.1.0 extracts digital PDFs. It detects pages that have little or no native text and reports that OCR may be needed. It does not run OCR, extract tables, extract images, classify documents, or call a language model.
49
+
50
+ ## Install
51
+
52
+ Python 3.10 or newer is required.
53
+
54
+ ```bash
55
+ pip install evupdf
56
+ ```
57
+
58
+ PyMuPDF 1.x is installed with EvuPDF. PyMuPDF is dual-licensed under the AGPL-3.0 or a commercial Artifex license. EvuPDF's own code is MIT. Read `THIRD_PARTY_NOTICES.md` before shipping a product that depends on this package.
59
+
60
+ Install from a checkout while developing:
61
+
62
+ ```bash
63
+ python -m pip install -e ".[dev]"
64
+ ```
65
+
66
+ ## Quickstart
67
+
68
+ `extract()` reads one local `.pdf` file:
69
+
70
+ ```python
71
+ from evupdf import PDFExtractor
72
+
73
+ document = PDFExtractor().extract("invoice.pdf")
74
+ print(document.page_count)
75
+ print(document.pages[0].blocks[0].text)
76
+ print(document.pages[0].blocks[0].bbox)
77
+ document.save_json("invoice.json")
78
+ ```
79
+
80
+ A runnable script is in `examples/basic_extract.py`.
81
+
82
+ ```bash
83
+ python examples/basic_extract.py invoice.pdf
84
+ ```
85
+
86
+ Encrypted PDFs need the user password. The password is used to open the file and is not written into the result:
87
+
88
+ ```python
89
+ document = PDFExtractor().extract("secret.pdf", password="user-password")
90
+ ```
91
+
92
+ Set `preserve_coordinates=False` when bounding boxes are not needed.
93
+
94
+ ## Coordinates
95
+
96
+ Bounding boxes and page width and height are in PDF points. One point is 1/72 inch. The origin is the top-left of the displayed page, x increases to the right, and y increases downward. Page numbers in the public result are 1-based. `rotation` is the page rotation in degrees.
97
+
98
+ `reading_order` follows PyMuPDF's content-stream order. EvuPDF does not yet reorder blocks into a layout-normalized reading order.
99
+
100
+ `source.confidence` is `null` for native text. EvuPDF does not invent a confidence score.
101
+
102
+ ## Limits
103
+
104
+ `ExtractorConfig` controls how much work extraction will attempt:
105
+
106
+ ```python
107
+ from evupdf import ExtractorConfig, PDFExtractor
108
+
109
+ extractor = PDFExtractor(
110
+ ExtractorConfig(
111
+ max_file_size_bytes=20 * 1024 * 1024,
112
+ max_page_count=100,
113
+ ocr_min_text_chars=20,
114
+ )
115
+ )
116
+ ```
117
+
118
+ The defaults are 50 MB, 500 pages, and a page dimension of 14,400 points (200 inches). A page with fewer than 20 non-whitespace characters is flagged with warning code `ocr_recommended`. That flag is a heuristic, not proof that the page is a scan.
119
+
120
+ If text extraction fails on one page, earlier and later pages are still returned. The failed page is empty and carries warning code `page_extraction_failed`.
121
+
122
+ ## Errors
123
+
124
+ | Exception | When it is raised |
125
+ | --- | --- |
126
+ | `FileValidationError` | The path is missing, not a file, or does not end in `.pdf`. |
127
+ | `InvalidPDFError` | The file is empty, has no `%PDF` header, or cannot be parsed. |
128
+ | `EncryptedPDFError` | A password is required and was omitted or rejected. |
129
+ | `PDFTooLargeError` | The file exceeds `max_file_size_bytes`. |
130
+ | `TooManyPagesError` | The document exceeds `max_page_count`. |
131
+
132
+ All of these inherit from `EvuPDFError`.
133
+
134
+ ## What this version does not do
135
+
136
+ - OCR, including Tesseract
137
+ - Table extraction
138
+ - Embedded image export
139
+ - AI classification or schema-based structuring
140
+ - A command-line interface and an HTTP API
141
+
142
+ Those are later milestones. Optional extras such as `evupdf[ocr]` are not published yet, because the features they would install are not implemented.
143
+
144
+ ## Development
145
+
146
+ ```bash
147
+ python -m pip install -e ".[dev]"
148
+ ruff check src tests examples
149
+ ruff format src tests examples
150
+ mypy
151
+ pytest
152
+ ```
153
+
154
+ Tests generate small PDFs at runtime. Do not commit customer documents.
155
+
156
+ ## License
157
+
158
+ EvuPDF source code is MIT. See `LICENSE` and `THIRD_PARTY_NOTICES.md`.
evupdf-0.1.0/README.md ADDED
@@ -0,0 +1,129 @@
1
+ # EvuPDF
2
+
3
+ EvuPDF extracts text, page geometry, and metadata from digital PDFs. The result is a typed Python object with bounding boxes, a file hash, and JSON export. Core extraction works offline after installation. It does not call an AI provider.
4
+
5
+ ```bash
6
+ pip install evupdf
7
+ ```
8
+
9
+ ```python
10
+ from evupdf import PDFExtractor
11
+
12
+ extractor = PDFExtractor()
13
+ result = extractor.extract("sample.pdf")
14
+
15
+ result.save_json("sample.json")
16
+ print(result.text)
17
+ ```
18
+
19
+ Version 0.1.0 extracts digital PDFs. It detects pages that have little or no native text and reports that OCR may be needed. It does not run OCR, extract tables, extract images, classify documents, or call a language model.
20
+
21
+ ## Install
22
+
23
+ Python 3.10 or newer is required.
24
+
25
+ ```bash
26
+ pip install evupdf
27
+ ```
28
+
29
+ PyMuPDF 1.x is installed with EvuPDF. PyMuPDF is dual-licensed under the AGPL-3.0 or a commercial Artifex license. EvuPDF's own code is MIT. Read `THIRD_PARTY_NOTICES.md` before shipping a product that depends on this package.
30
+
31
+ Install from a checkout while developing:
32
+
33
+ ```bash
34
+ python -m pip install -e ".[dev]"
35
+ ```
36
+
37
+ ## Quickstart
38
+
39
+ `extract()` reads one local `.pdf` file:
40
+
41
+ ```python
42
+ from evupdf import PDFExtractor
43
+
44
+ document = PDFExtractor().extract("invoice.pdf")
45
+ print(document.page_count)
46
+ print(document.pages[0].blocks[0].text)
47
+ print(document.pages[0].blocks[0].bbox)
48
+ document.save_json("invoice.json")
49
+ ```
50
+
51
+ A runnable script is in `examples/basic_extract.py`.
52
+
53
+ ```bash
54
+ python examples/basic_extract.py invoice.pdf
55
+ ```
56
+
57
+ Encrypted PDFs need the user password. The password is used to open the file and is not written into the result:
58
+
59
+ ```python
60
+ document = PDFExtractor().extract("secret.pdf", password="user-password")
61
+ ```
62
+
63
+ Set `preserve_coordinates=False` when bounding boxes are not needed.
64
+
65
+ ## Coordinates
66
+
67
+ Bounding boxes and page width and height are in PDF points. One point is 1/72 inch. The origin is the top-left of the displayed page, x increases to the right, and y increases downward. Page numbers in the public result are 1-based. `rotation` is the page rotation in degrees.
68
+
69
+ `reading_order` follows PyMuPDF's content-stream order. EvuPDF does not yet reorder blocks into a layout-normalized reading order.
70
+
71
+ `source.confidence` is `null` for native text. EvuPDF does not invent a confidence score.
72
+
73
+ ## Limits
74
+
75
+ `ExtractorConfig` controls how much work extraction will attempt:
76
+
77
+ ```python
78
+ from evupdf import ExtractorConfig, PDFExtractor
79
+
80
+ extractor = PDFExtractor(
81
+ ExtractorConfig(
82
+ max_file_size_bytes=20 * 1024 * 1024,
83
+ max_page_count=100,
84
+ ocr_min_text_chars=20,
85
+ )
86
+ )
87
+ ```
88
+
89
+ The defaults are 50 MB, 500 pages, and a page dimension of 14,400 points (200 inches). A page with fewer than 20 non-whitespace characters is flagged with warning code `ocr_recommended`. That flag is a heuristic, not proof that the page is a scan.
90
+
91
+ If text extraction fails on one page, earlier and later pages are still returned. The failed page is empty and carries warning code `page_extraction_failed`.
92
+
93
+ ## Errors
94
+
95
+ | Exception | When it is raised |
96
+ | --- | --- |
97
+ | `FileValidationError` | The path is missing, not a file, or does not end in `.pdf`. |
98
+ | `InvalidPDFError` | The file is empty, has no `%PDF` header, or cannot be parsed. |
99
+ | `EncryptedPDFError` | A password is required and was omitted or rejected. |
100
+ | `PDFTooLargeError` | The file exceeds `max_file_size_bytes`. |
101
+ | `TooManyPagesError` | The document exceeds `max_page_count`. |
102
+
103
+ All of these inherit from `EvuPDFError`.
104
+
105
+ ## What this version does not do
106
+
107
+ - OCR, including Tesseract
108
+ - Table extraction
109
+ - Embedded image export
110
+ - AI classification or schema-based structuring
111
+ - A command-line interface and an HTTP API
112
+
113
+ Those are later milestones. Optional extras such as `evupdf[ocr]` are not published yet, because the features they would install are not implemented.
114
+
115
+ ## Development
116
+
117
+ ```bash
118
+ python -m pip install -e ".[dev]"
119
+ ruff check src tests examples
120
+ ruff format src tests examples
121
+ mypy
122
+ pytest
123
+ ```
124
+
125
+ Tests generate small PDFs at runtime. Do not commit customer documents.
126
+
127
+ ## License
128
+
129
+ EvuPDF source code is MIT. See `LICENSE` and `THIRD_PARTY_NOTICES.md`.
@@ -0,0 +1,13 @@
1
+ # Third-party notices
2
+
3
+ EvuPDF's own source code is licensed under the MIT License. See `LICENSE`.
4
+
5
+ ## PyMuPDF
6
+
7
+ EvuPDF imports [PyMuPDF](https://pypi.org/project/pymupdf/) to read PDF text and geometry. PyMuPDF is dual-licensed under the GNU Affero General Public License v3.0 or a commercial license from Artifex Software. Version 0.1.0 depends on PyMuPDF `>=1.26,<2`, before the 2.x release.
8
+
9
+ Installing `evupdf` installs that PyMuPDF dependency. Complying with PyMuPDF's license for your own application or service is your responsibility. This notice is not legal advice. Commercial terms are published by Artifex at <https://pymupdf.io/licensing>.
10
+
11
+ ## Pydantic
12
+
13
+ Result and configuration models use [Pydantic](https://pypi.org/project/pydantic/) v2, which is licensed under the MIT License.
@@ -0,0 +1,30 @@
1
+ # Configuration
2
+
3
+ Pass an `ExtractorConfig` to `PDFExtractor`. There is no JSON config file in this version.
4
+
5
+ ```python
6
+ from evupdf import ExtractorConfig, PDFExtractor
7
+
8
+ config = ExtractorConfig(
9
+ max_file_size_bytes=50 * 1024 * 1024,
10
+ max_page_count=500,
11
+ max_page_dimension_points=14400,
12
+ ocr_min_text_chars=20,
13
+ preserve_coordinates=True,
14
+ )
15
+ extractor = PDFExtractor(config)
16
+ ```
17
+
18
+ | Field | Default | Effect |
19
+ | --- | --- | --- |
20
+ | `max_file_size_bytes` | 52428800 | Reject larger files before they are opened. |
21
+ | `max_page_count` | 500 | Reject documents with more pages. |
22
+ | `max_page_dimension_points` | 14400 | Skip text extraction on a larger page and warn. |
23
+ | `ocr_min_text_chars` | 20 | Flag a page with fewer non-whitespace characters. `0` turns the flag off. |
24
+ | `preserve_coordinates` | `True` | Store a bounding box on each text block. |
25
+
26
+ `extract(..., preserve_coordinates=False)` overrides the config value for one call.
27
+
28
+ `extract(..., password="...")` supplies the user password for that file only. Passwords are not part of `ExtractorConfig`, and they are not written to the result.
29
+
30
+ Raw extraction does not read API keys and does not make network calls.
@@ -0,0 +1,40 @@
1
+ # Extraction
2
+
3
+ `PDFExtractor.extract(path)` runs these steps:
4
+
5
+ 1. Check that the path exists, is a file, ends in `.pdf`, is within the size limit, and contains a `%PDF` marker in the first 1024 bytes.
6
+ 2. Hash the file with SHA-256.
7
+ 3. Open it with PyMuPDF. Encrypted files must be opened with `password`.
8
+ 4. Reject the document when `page_count` is over the configured limit.
9
+ 5. Copy metadata. Empty strings become `null`. Recognized PDF dates become ISO 8601.
10
+ 6. Read text blocks and bounding boxes from each page.
11
+ 7. Flag pages whose visible text is below `ocr_min_text_chars`.
12
+
13
+ A failure while reading one page does not discard the other pages. That page is returned with no blocks, `ocr_recommended` set, and a `page_extraction_failed` warning.
14
+
15
+ ## Coordinates
16
+
17
+ Values are PDF points on the displayed page, after rotation:
18
+
19
+ - origin: top-left
20
+ - x: increases to the right
21
+ - y: increases downward
22
+ - box: `[x0, y0, x1, y1]`
23
+ - `width` and `height`: `page.rect` from PyMuPDF, in the same space
24
+
25
+ `reading_order` is the order PyMuPDF returned the blocks. It is not a column-aware reading order.
26
+
27
+ ## OCR recommendation
28
+
29
+ `ocr_recommended` is true when the page's extracted text has fewer non-whitespace characters than `ocr_min_text_chars`. Image-only and blank pages are flagged. A page of real text that happens to be very short is flagged too. The warning code is `ocr_recommended`. This version does not call Tesseract or any other OCR engine.
30
+
31
+ ## Warning codes
32
+
33
+ | Code | Meaning |
34
+ | --- | --- |
35
+ | `ocr_recommended` | The page has little or no native text. |
36
+ | `page_extraction_failed` | Geometry or text for that page could not be read. |
37
+ | `page_dimension_exceeded` | The page is larger than `max_page_dimension_points`. Text was not extracted. |
38
+ | `metadata_unavailable` | The document information dictionary could not be read. |
39
+
40
+ Warnings are objects with `code`, `message`, and an optional `page_number`.
@@ -0,0 +1,23 @@
1
+ # Installation
2
+
3
+ Python 3.10 or newer is required. The published package installs the extraction library and its required dependencies:
4
+
5
+ ```bash
6
+ pip install evupdf
7
+ ```
8
+
9
+ That command installs PyMuPDF 1.26 or newer, before 2.0. No separate OCR program, model download, or API key is required for digital PDF extraction.
10
+
11
+ From a source checkout:
12
+
13
+ ```bash
14
+ python -m pip install -e ".[dev]"
15
+ ```
16
+
17
+ The `dev` extra installs pytest, Ruff, and mypy. It is not needed to extract PDFs.
18
+
19
+ ## PyMuPDF license
20
+
21
+ PyMuPDF is dual-licensed under the GNU AGPL-3.0 or a commercial license from Artifex. EvuPDF 0.1.0 depends on PyMuPDF 1.x, from 1.26 up to but not including 2.0, so the core install stays a text-extraction library. PyMuPDF 2.x also installs layout-model packages that this version does not use.
22
+
23
+ See `THIRD_PARTY_NOTICES.md` before you vendor or ship an application that imports EvuPDF.
@@ -0,0 +1,57 @@
1
+ # Output schema
2
+
3
+ Raw extraction uses schema version `1.0`. `ExtractionResult` validates every result before it is returned. `to_json()` and `save_json()` write that model. Unknown fields are rejected if you load the JSON back with `ExtractionResult.model_validate_json`.
4
+
5
+ `document_id` is the first 16 hex characters of the file's SHA-256 digest. `file_hash` is the full digest, prefixed with `sha256:`. Use `file_hash` when you need a stable identity.
6
+
7
+ `result.text` is computed in Python from the blocks. It is intentionally absent from the JSON so the saved document stays the structured record.
8
+
9
+ ```json
10
+ {
11
+ "schema_version": "1.0",
12
+ "document_id": "0123456789abcdef",
13
+ "file_name": "invoice.pdf",
14
+ "file_hash": "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
15
+ "mime_type": "application/pdf",
16
+ "page_count": 1,
17
+ "metadata": {
18
+ "title": null,
19
+ "author": null,
20
+ "creation_date": null,
21
+ "modification_date": null,
22
+ "subject": null,
23
+ "keywords": null,
24
+ "creator": null,
25
+ "producer": null
26
+ },
27
+ "pages": [
28
+ {
29
+ "page_number": 1,
30
+ "width": 595.0,
31
+ "height": 842.0,
32
+ "rotation": 0,
33
+ "extraction_method": "pymupdf",
34
+ "ocr_recommended": false,
35
+ "blocks": [
36
+ {
37
+ "block_id": "p1_b0",
38
+ "type": "text",
39
+ "text": "Invoice Number: INV-001",
40
+ "bbox": [40.0, 100.0, 300.0, 130.0],
41
+ "reading_order": 0,
42
+ "source": {
43
+ "engine": "pymupdf",
44
+ "confidence": null
45
+ }
46
+ }
47
+ ],
48
+ "tables": []
49
+ }
50
+ ],
51
+ "warnings": []
52
+ }
53
+ ```
54
+
55
+ `tables` is always an empty list in 0.1.0. The key is reserved for a later table model.
56
+
57
+ Missing metadata is `null`. A date that EvuPDF cannot parse is kept as the original string instead of being dropped or guessed.
@@ -0,0 +1,28 @@
1
+ # Quickstart
2
+
3
+ ```python
4
+ from evupdf import PDFExtractor
5
+
6
+ result = PDFExtractor().extract("sample.pdf")
7
+ result.save_json("sample.json")
8
+ print(result.text)
9
+ ```
10
+
11
+ `result.text` joins non-empty page text with a blank line. Empty pages stay in `result.pages` and are omitted from this string. It is a convenience for Python callers and is not a field in the JSON. The JSON is the raw extraction record: file hash, metadata, pages, blocks, boxes, and warnings.
12
+
13
+ ```python
14
+ page = result.pages[0]
15
+ print(page.page_number, page.width, page.height, page.rotation)
16
+ for block in page.blocks:
17
+ print(block.block_id, block.bbox, block.text)
18
+ ```
19
+
20
+ Block ids look like `p1_b0`: the 1-based page number and the block index on that page.
21
+
22
+ To try the example script from a checkout:
23
+
24
+ ```bash
25
+ python examples/basic_extract.py sample.pdf
26
+ ```
27
+
28
+ The script writes `sample.json` next to the PDF and prints the extracted text.
@@ -0,0 +1,37 @@
1
+ # Troubleshooting
2
+
3
+ ## `File not found` or `Expected a .pdf file`
4
+
5
+ `extract()` takes a filesystem path whose name ends in `.pdf` or `.PDF`. Pass the PDF itself, not a directory and not a JSON export.
6
+
7
+ ## `does not have a %PDF header` or `Could not open`
8
+
9
+ The file is empty, truncated, or not a PDF. EvuPDF will not try to repair it. Export the file again from the application that created it.
10
+
11
+ ## `is encrypted`
12
+
13
+ Open the call with the user password:
14
+
15
+ ```python
16
+ PDFExtractor().extract("secret.pdf", password="user-password")
17
+ ```
18
+
19
+ A wrong password raises the same `EncryptedPDFError`. The password is not included in the error text. An owner password that does not also open the document for reading will not unlock extraction.
20
+
21
+ ## `exceeds the configured limit`
22
+
23
+ The file is larger than `max_file_size_bytes`, or it has more pages than `max_page_count`. Raise the matching `ExtractorConfig` field only for documents you trust. A page larger than `max_page_dimension_points` is skipped instead of failing the whole file, and the result includes `page_dimension_exceeded`.
24
+
25
+ ## Text is missing on a page
26
+
27
+ Check `page.ocr_recommended` and warnings with code `ocr_recommended`. Scanned pages and pages that are only images have no native text in this version. OCR is not included in 0.1.0.
28
+
29
+ If the warning code is `page_extraction_failed`, the message names the page PyMuPDF could not read. Other pages are still present.
30
+
31
+ ## Boxes do not match another PDF tool
32
+
33
+ EvuPDF uses PyMuPDF's displayed-page coordinates: top-left origin, y downward, units in points, after rotation. Tools that report a bottom-left PDF user space will not match these numbers directly.
34
+
35
+ ## `tables` is empty
36
+
37
+ Table extraction is not part of this version. Text that visually belongs to a table is still returned as text blocks.
@@ -0,0 +1,30 @@
1
+ """Extract a local PDF and write JSON beside it.
2
+
3
+ Usage:
4
+ python examples/basic_extract.py path/to/file.pdf
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import sys
10
+ from pathlib import Path
11
+
12
+ from evupdf import PDFExtractor
13
+
14
+
15
+ def main(argv: list[str]) -> int:
16
+ if len(argv) != 2:
17
+ print("Usage: python examples/basic_extract.py path/to/file.pdf", file=sys.stderr)
18
+ return 2
19
+
20
+ source = Path(argv[1])
21
+ result = PDFExtractor().extract(source)
22
+ destination = source.with_suffix(".json")
23
+ result.save_json(destination)
24
+ print(result.text)
25
+ print(f"Wrote {destination}")
26
+ return 0
27
+
28
+
29
+ if __name__ == "__main__":
30
+ raise SystemExit(main(sys.argv))