markitdown-pdfluent 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.
@@ -0,0 +1,197 @@
1
+ /target
2
+ pdfluent-examples/dotnet/**/bin/
3
+ pdfluent-examples/dotnet/**/obj/
4
+ .env
5
+ .env.*
6
+ *.pem
7
+ *.key
8
+ *.p12
9
+ *.pfx
10
+ *.swp
11
+ *.swo
12
+ .DS_Store
13
+ *.pdf
14
+ # The two real arXiv pages of the aligner suite (CC BY 4.0, attribution in the directory): committed;
15
+ # the synthetic fixtures beside them are generated by make_fixtures.py and stay ignored.
16
+ !scripts/groundtruth/fixtures/real/*.pdf
17
+ !/tests/fixtures/*.pdf
18
+ !/fixtures/formcalc/*.pdf
19
+ !/fixtures/xfa-layout/*.pdf
20
+ !/fixtures/xfa-data/*.pdf
21
+ !/fixtures/scanned/*.pdf
22
+ # Hostile PDFs: small, hand-built files that must not crash the renderer (#262).
23
+ !/fixtures/pdf/*.pdf
24
+ # The document every binding's structured-extraction suite reads (#573). It is
25
+ # built and pinned by crates/pdf-engine/tests/the_api_over_the_block_model.rs;
26
+ # the older files beside it are tracked from before `*.pdf` was ignored at all,
27
+ # which is why only this one needs saying.
28
+ !/fixtures/structured.pdf
29
+ # Three text pages under a two-level outline, which the chunk suites of both
30
+ # bindings read for per-page toc_items. Built by
31
+ # scripts/make-outlined-fixture.py, byte-deterministic.
32
+ !/fixtures/outlined.pdf
33
+ # The four-page report with a running head and page numbers that the markdown
34
+ # furniture suites read. Built and pinned by
35
+ # crates/pdf-engine/tests/markdown_furniture_and_separators.rs.
36
+ !/fixtures/running-head.pdf
37
+ # One page with two hand-built image XObjects (7x5 RGB Flate, 4x3 Gray raw)
38
+ # that every binding's known-images suite reads. Built by
39
+ # fixtures/gen/known_images.py, byte-deterministic (#643).
40
+ !/fixtures/known-images.pdf
41
+ !/tests/corpus-mini/*.pdf
42
+ !/crates/pdf-java/src/test/resources/*.pdf
43
+ !/crates/visual-regression/fixtures/*.pdf
44
+ # The MCP server's own copies of five fixtures, so integrations/pdfluent-mcp
45
+ # tests the same way inside this tree and in its own repository (#625).
46
+ !/integrations/pdfluent-mcp/tests/fixtures/*.pdf
47
+ # One DocLayNet train page, registered in corpus_herkomst.py: the operator
48
+ # page of the list-splitting model (#599).
49
+ !/crates/pdf-engine/tests/fixtures/doclaynet/*.pdf
50
+ # PubTables-1M train pages, registered in corpus_herkomst.py (#574).
51
+ !/crates/pdf-engine/tests/fixtures/pubtables/*.pdf
52
+ metadata.sqlite
53
+ /reports/
54
+ /renders/
55
+ /crates/xfa-wasm/pkg/
56
+ /fuzz/artifacts/
57
+ /fuzz/corpus/*/
58
+ !/fuzz/corpus/*/seed_*
59
+ node_modules/
60
+ package-lock.json
61
+ !/test-data/xfa-golden/*.pdf
62
+ /benchmarks/weekly/benchmark-*.json
63
+ /benchmarks/weekly/benchmark-*-report.md
64
+ /benchmarks/weekly/regression-*.md
65
+ /benchmarks/stress-fixtures/
66
+ # Any __pycache__, at any depth. The narrower `scripts/__pycache__/` did not match
67
+ # scripts/ci/__pycache__/, so bytecode from the CI helpers kept turning up staged.
68
+ __pycache__/
69
+ *.pyc
70
+ .cache/
71
+ out/
72
+
73
+ # M8-CLEANUP-04 (#1380): VPS/local expensive validation reports
74
+ validation-reports/
75
+
76
+ # Build artifacts: Python bindings (maturin/PyO3 compiled extensions).
77
+ # Machine-specific, must never be committed.
78
+ crates/pdf-python/python/**/*.so
79
+ crates/pdf-python/python/**/*.pyd
80
+ crates/pdf-python/dist/
81
+ # Project-local Python environment (`maturin develop` installs here).
82
+ .venv/
83
+
84
+ # Build artifacts: Node.js bindings (napi-rs compiled .node files).
85
+ crates/pdf-node/index.*.node
86
+ crates/pdf-node/artifacts/
87
+
88
+ # Build artifacts: the @pdfluent/extract wrapper (tsc emit, never source).
89
+ integrations/pdfluent-extract-js/dist/
90
+
91
+ # Belt-and-suspenders for wasm-pack output within pkg/ (already covered by /crates/xfa-wasm/pkg/ above).
92
+ crates/xfa-wasm/pkg/*.js
93
+ crates/xfa-wasm/pkg/*.wasm
94
+ crates/xfa-wasm/pkg/*.d.ts
95
+
96
+ # .NET and Java build outputs (added wave1-release)
97
+ bindings/dotnet/**/bin/
98
+ bindings/dotnet/**/obj/
99
+ bindings/java/target/
100
+ crates/pdf-java/target/
101
+
102
+ # .NET runtime-specific native bundles (regenerated at release time)
103
+ bindings/dotnet/**/runtimes/
104
+
105
+ # Java JNA native bundles (built by release pipeline, not committed)
106
+ bindings/java/src/main/resources/native/
107
+
108
+ # .NET NuGet packages
109
+ *.nupkg
110
+
111
+ # Doxygen generated output
112
+ crates/pdf-capi/doxygen-out/
113
+
114
+ # Compiled C example binaries (built by examples/Makefile)
115
+ crates/pdf-capi/examples/license_activate
116
+
117
+ # M9-A hygiene: generated publish dry-run logs embed machine-local /Users/ paths
118
+ benchmarks/runs/**/dry_run_logs*/
119
+ benchmarks/runs/**/dry_run_logs/
120
+ **/audit_rust_post_commit.log
121
+
122
+ # Corpus PDFs: large public-domain input files; not needed for CI builds.
123
+ # Exception: small test fixtures referenced by non-ignored integration tests.
124
+ # Note: only ignore the PDFs/JSONs, not the directory itself, so exceptions work.
125
+ corpus/*.pdf
126
+ !/corpus/PDFBOX-4322-3.pdf
127
+ !/corpus/f1040.pdf
128
+ !/corpus/sf15.pdf
129
+ !/corpus/sf181.pdf
130
+ !/corpus/fw7.pdf
131
+ corpus/*.json
132
+ # The gate corpus is a manifest, not a directory of PDFs: URLs pinned to an
133
+ # upstream commit plus a SHA-256 each. Text, so it publishes safely (#215),
134
+ # and it is the thing the pull-request gates are pinned to (#276).
135
+ !/corpus/GATE_CORPUS_MANIFEST.json
136
+ !/corpus/GATE_CORPUS_KNOWN_CRASHES.json
137
+ # Where fetch_gate_corpus.py materialises that manifest. Never committed.
138
+ /corpus/gate/
139
+ # ...but the gate manifests are inputs, not outputs. They are tracked, and
140
+ # `corpus/*.json` above would silently drop a re-added one -- the others
141
+ # survive only because they predate that line. Declared, so the next person
142
+ # who deletes and restores one does not lose it without being told.
143
+ !/corpus/SSIM_GATE_MANIFEST.json
144
+
145
+ benchmarks/runs/xfa_enterprise_plan/sprint2/heatmaps_demo/
146
+ crates/pdf-capi/tests/test_text_blocks
147
+ crates/pdf-capi/tests/test_structured_extraction
148
+ crates/pdf-capi/tests/test_journal
149
+ crates/pdf-capi/tests/test_form_write
150
+ crates/pdf-capi/tests/test_plain_images
151
+ crates/pdf-capi/tests/test_compat_tables
152
+ benchmarks/runs/xfa_enterprise_plan/custom_defects/xfa_test_flatten/artifacts/
153
+ /dist/
154
+
155
+ # ── Fuzz build outputs ────────────────────────────────────────────────────────
156
+ # The root /target rule only covers the workspace target. Every fuzz crate builds
157
+ # its own target/ under its fuzz/ subdirectory and these are never source.
158
+ /fuzz/target/
159
+ **/fuzz/target/
160
+
161
+ # ── WASM pkg-release directory ────────────────────────────────────────────────
162
+ # /crates/xfa-wasm/pkg/ is already covered above; pkg-release/ is the optimised
163
+ # release variant produced by wasm-pack --release and is equally reproducible.
164
+ /crates/xfa-wasm/pkg-release/
165
+
166
+ # ── Native binary artifacts (belt-and-suspenders) ─────────────────────────────
167
+ # Specific directories are already covered above (bindings/**/runtimes/, etc.).
168
+ # These global patterns guard against any new crate that adds a native output
169
+ # path not yet covered by a directory rule.
170
+ # Exceptions: none expected — no legitimate source file has these extensions.
171
+ *.dylib
172
+ *.dylib.dSYM/
173
+ **/*.dSYM/
174
+ *.dll
175
+ *.so
176
+ # *.rlib and *.rmeta live inside target/ (already ignored) but cover edge cases
177
+ # where cargo or fuzz builds emit them outside the workspace target directory.
178
+ *.rlib
179
+ *.rmeta
180
+
181
+ # ── pdfluent-examples example node_modules ───────────────────────────────────
182
+ # The top-level node_modules/ rule covers workspace root, but examples that run
183
+ # npm install inside their own subdirectory need this explicit pattern.
184
+ pdfluent-examples/**/node_modules/
185
+ crates/pdf-node/node_modules/
186
+
187
+ # ── local measurement output ───────────────────────────────────────────────
188
+ # Jobs write evidence under meas-out/<name>/ inside the workspace; the
189
+ # launcher copies it out afterwards. Never committed, and invisible to the
190
+ # clean-tree gates (a run that refused itself over its own output dir).
191
+ # Measurement outputs: local proof logs, never tracked (#574).
192
+ meas-out/
193
+ # Measurement evidence, same rule: train Q carried meas/p4l-3f/ into the repo.
194
+ meas/
195
+
196
+ # Scratch output of local tools (rehearsals write to $TMPDIR, #1172); never part of a tree a release script checks for cleanliness.
197
+ /tmp/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Innovation Trigger B.V.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.5
2
+ Name: markitdown-pdfluent
3
+ Version: 0.1.0
4
+ Summary: A MarkItDown plugin that converts PDFs to Markdown with the PDFluent engine: reading order, headings, lists and tables, locally and offline.
5
+ Project-URL: Homepage, https://pdfluent.com
6
+ Project-URL: Documentation, https://pdfluent.com/docs
7
+ Project-URL: Repository, https://github.com/pdfluent/pdfluent-sdk
8
+ Project-URL: Bug Tracker, https://github.com/pdfluent/pdfluent-sdk/issues
9
+ Author-email: "Innovation Trigger B.V." <team@pdfluent.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: markdown,markitdown,pdf,pdfluent,plugin,rag
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: Text Processing
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: markitdown>=0.1.0
24
+ Requires-Dist: pdfluent>=1.1.0
25
+ Description-Content-Type: text/markdown
26
+
27
+ # markitdown-pdfluent
28
+
29
+ A [MarkItDown](https://github.com/microsoft/markitdown) plugin that converts PDFs with the
30
+ [PDFluent](https://pdfluent.com) engine. It runs on your machine and needs no network.
31
+
32
+ ## Install
33
+
34
+ ```bash
35
+ pip install markitdown-pdfluent
36
+ ```
37
+
38
+ ## Use
39
+
40
+ Plugins are off by default in MarkItDown. Turn them on:
41
+
42
+ ```python
43
+ from markitdown import MarkItDown
44
+
45
+ md = MarkItDown(enable_plugins=True)
46
+ print(md.convert("report.pdf").markdown)
47
+ ```
48
+
49
+ From the command line:
50
+
51
+ ```bash
52
+ markitdown --use-plugins report.pdf
53
+ ```
54
+
55
+ The plugin registers ahead of MarkItDown's built-in PDF converter, so PDFs go through PDFluent and
56
+ every other format keeps using MarkItDown's own converters.
57
+
58
+ ## Licence
59
+
60
+ This plugin is MIT licensed; see `LICENSE`. The PDFluent engine it calls (`pdfluent` on PyPI) is
61
+ licensed separately, under AGPL-3.0 or a commercial licence.
@@ -0,0 +1,35 @@
1
+ # markitdown-pdfluent
2
+
3
+ A [MarkItDown](https://github.com/microsoft/markitdown) plugin that converts PDFs with the
4
+ [PDFluent](https://pdfluent.com) engine. It runs on your machine and needs no network.
5
+
6
+ ## Install
7
+
8
+ ```bash
9
+ pip install markitdown-pdfluent
10
+ ```
11
+
12
+ ## Use
13
+
14
+ Plugins are off by default in MarkItDown. Turn them on:
15
+
16
+ ```python
17
+ from markitdown import MarkItDown
18
+
19
+ md = MarkItDown(enable_plugins=True)
20
+ print(md.convert("report.pdf").markdown)
21
+ ```
22
+
23
+ From the command line:
24
+
25
+ ```bash
26
+ markitdown --use-plugins report.pdf
27
+ ```
28
+
29
+ The plugin registers ahead of MarkItDown's built-in PDF converter, so PDFs go through PDFluent and
30
+ every other format keeps using MarkItDown's own converters.
31
+
32
+ ## Licence
33
+
34
+ This plugin is MIT licensed; see `LICENSE`. The PDFluent engine it calls (`pdfluent` on PyPI) is
35
+ licensed separately, under AGPL-3.0 or a commercial licence.
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.24"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "markitdown-pdfluent"
7
+ version = "0.1.0"
8
+ description = "A MarkItDown plugin that converts PDFs to Markdown with the PDFluent engine: reading order, headings, lists and tables, locally and offline."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ authors = [{ name = "Innovation Trigger B.V.", email = "team@pdfluent.com" }]
13
+ requires-python = ">=3.10"
14
+ # markitdown is MIT. pdfluent is the engine and is licensed separately (AGPL-3.0 or commercial).
15
+ dependencies = ["markitdown>=0.1.0", "pdfluent>=1.1.0"]
16
+ keywords = ["markitdown", "plugin", "pdf", "markdown", "rag", "pdfluent"]
17
+ classifiers = [
18
+ "Development Status :: 4 - Beta",
19
+ "Intended Audience :: Developers",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Topic :: Text Processing",
26
+ "Topic :: Software Development :: Libraries :: Python Modules",
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://pdfluent.com"
31
+ Documentation = "https://pdfluent.com/docs"
32
+ Repository = "https://github.com/pdfluent/pdfluent-sdk"
33
+ "Bug Tracker" = "https://github.com/pdfluent/pdfluent-sdk/issues"
34
+
35
+ [project.entry-points."markitdown.plugin"]
36
+ pdfluent = "markitdown_pdfluent"
37
+
38
+ [tool.hatch.build.targets.wheel]
39
+ packages = ["src/markitdown_pdfluent"]
40
+
41
+ [tool.pytest.ini_options]
42
+ testpaths = ["tests"]
@@ -0,0 +1,25 @@
1
+ """MarkItDown plugin: PDFs to Markdown with the PDFluent engine."""
2
+
3
+ # Copyright (c) 2026 Innovation Trigger B.V.
4
+ #
5
+ # Licensed under the MIT License. See the LICENSE file in this repository.
6
+
7
+ from __future__ import annotations
8
+
9
+ from typing import Any
10
+
11
+ from markitdown import MarkItDown
12
+
13
+ from ._converter import PDFluentPdfConverter
14
+
15
+ __plugin_interface_version__ = 1
16
+
17
+ # Lower values run first. MarkItDown's built-in PDF converter uses 0, so this runs before it.
18
+ PRIORITY = -1.0
19
+
20
+ __all__ = ["PDFluentPdfConverter", "register_converters"]
21
+
22
+
23
+ def register_converters(markitdown: MarkItDown, **kwargs: Any) -> None:
24
+ """Called by MarkItDown when plugins are enabled."""
25
+ markitdown.register_converter(PDFluentPdfConverter(), priority=PRIORITY)
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2026 Innovation Trigger B.V.
2
+ #
3
+ # Licensed under the MIT License. See the LICENSE file in this repository.
4
+
5
+ from __future__ import annotations
6
+
7
+ from typing import Any, BinaryIO
8
+
9
+ from markitdown import DocumentConverter, DocumentConverterResult, StreamInfo
10
+
11
+ _PDF_EXTENSIONS = (".pdf",)
12
+ _PDF_MIMETYPES = ("application/pdf", "application/x-pdf")
13
+ _PDF_MAGIC = b"%PDF-"
14
+
15
+
16
+ class PDFluentPdfConverter(DocumentConverter):
17
+ """Converts PDF streams to Markdown with the local PDFluent engine."""
18
+
19
+ def accepts(self, file_stream: BinaryIO, stream_info: StreamInfo, **kwargs: Any) -> bool:
20
+ extension = (stream_info.extension or "").lower()
21
+ mimetype = (stream_info.mimetype or "").lower()
22
+ if extension in _PDF_EXTENSIONS or mimetype.startswith(_PDF_MIMETYPES):
23
+ return True
24
+ # No hint from the caller: look at the first bytes, then put the stream back.
25
+ if not extension and not mimetype and file_stream.seekable():
26
+ position = file_stream.tell()
27
+ try:
28
+ return file_stream.read(len(_PDF_MAGIC)) == _PDF_MAGIC
29
+ finally:
30
+ file_stream.seek(position)
31
+ return False
32
+
33
+ def convert(
34
+ self, file_stream: BinaryIO, stream_info: StreamInfo, **kwargs: Any
35
+ ) -> DocumentConverterResult:
36
+ from pdfluent import Document
37
+
38
+ document = Document(file_stream.read())
39
+ with document:
40
+ markdown = document.extract_markdown()
41
+ return DocumentConverterResult(markdown=markdown.strip() + "\n")
@@ -0,0 +1,54 @@
1
+ """Runs the plugin through MarkItDown's own plugin loading, on a real PDF."""
2
+
3
+ import io
4
+ from pathlib import Path
5
+
6
+ import pytest
7
+ from markitdown import MarkItDown, StreamInfo
8
+
9
+ import markitdown_pdfluent
10
+ from markitdown_pdfluent import PDFluentPdfConverter
11
+
12
+ PDF = Path(__file__).parent / "fixtures" / "sample.pdf"
13
+
14
+
15
+ def test_entry_point_is_discovered():
16
+ from importlib.metadata import entry_points
17
+
18
+ names = {e.name for e in entry_points(group="markitdown.plugin")}
19
+ assert "pdfluent" in names
20
+ assert markitdown_pdfluent.__plugin_interface_version__ == 1
21
+
22
+
23
+ def test_plugin_converts_a_real_pdf():
24
+ result = MarkItDown(enable_plugins=True).convert(str(PDF))
25
+ assert "Individual Taxpayer Identification Number" in result.markdown
26
+ assert "W-7" in result.markdown
27
+
28
+
29
+ def test_plugin_output_is_the_pdfluent_engine_output():
30
+ from pdfluent import Document
31
+
32
+ with Document(PDF.read_bytes()) as doc:
33
+ expected = doc.extract_markdown().strip() + "\n"
34
+ assert MarkItDown(enable_plugins=True).convert(str(PDF)).markdown == expected
35
+ assert PDFluentPdfConverter().convert(io.BytesIO(PDF.read_bytes()), StreamInfo(extension=".pdf")).markdown == expected
36
+
37
+
38
+ def test_stream_without_hints_is_detected_by_magic():
39
+ c = PDFluentPdfConverter()
40
+ stream = io.BytesIO(PDF.read_bytes())
41
+ assert c.accepts(stream, StreamInfo())
42
+ assert stream.tell() == 0
43
+ assert not c.accepts(io.BytesIO(b"hello"), StreamInfo())
44
+
45
+
46
+ def test_other_formats_are_not_accepted():
47
+ c = PDFluentPdfConverter()
48
+ assert not c.accepts(io.BytesIO(b"x"), StreamInfo(extension=".docx"))
49
+ assert c.accepts(io.BytesIO(b"x"), StreamInfo(mimetype="application/pdf"))
50
+
51
+
52
+ def test_corrupt_pdf_raises():
53
+ with pytest.raises(Exception):
54
+ PDFluentPdfConverter().convert(io.BytesIO(b"%PDF-1.4 not really"), StreamInfo(extension=".pdf"))