Skip to content

Add opt-in drawing PDF views and Markdown reports - #2689

Draft
Çağdaş Yürekli (cagdasyurekli) wants to merge 1 commit into
microsoft:mainfrom
cagdasyurekli:feat/pdf-drawing-markdown
Draft

Çağdaş Yürekli (cagdasyurekli) wants to merge 1 commit into
microsoft:mainfrom
cagdasyurekli:feat/pdf-drawing-markdown

Conversation

@cagdasyurekli

Copy link
Copy Markdown
Contributor

Vector drawing PDFs can return successful Markdown containing only isolated labels, while SHX annotation text and all drawing lines are omitted. Add an explicit, local --pdf-drawing-mode / pdf_drawing_mode=True path that returns located native/SHX labels, raster page views, and an English Markdown limitations report. Existing conversion defaults remain unchanged. This draft is a concrete proposal for review; core/plugin placement and API/report shape have not been accepted by maintainers.

CLI: markitdown drawing.pdf --pdf-drawing-mode -o drawing.md produces drawing.md, drawing.report.md, and drawing.assets/page-1.png, etc. New destinations only; collisions, symlinks, and source overwrites are refused. Output is staged, published through exclusive hard links, and rolled back on failure. Destination filesystems must support hard links. --conversion-report selects a different report path. Stdout requires explicit --keep-data-uris plus a report path.

The API exposes result.assets and result.conversion_report without filesystem writes. ZIP members retain distinct image names and reports; failed drawing rendering is not silently skipped or downgraded to successful text-only conversion. The optional MCP argument returns inline views and the report, with no file writes. Drawing mode runs before PDF plugin/cloud fallback selection; CLI cloud-mode combinations are rejected.

This is not lossless or semantic drawing reconstruction. PNG views use the CropBox at up to 200 DPI with an 8192-pixel longest-edge cap; fine detail can be lost. Reports give MediaBox/CropBox bounds and identify unresolved information without claiming exhaustive detection. No OCR, dimension associations, unit/scale inference, or external model calls. Angled lettering can have imperfect word grouping. The complete assets map is held in memory, and large drawings can be resource-heavy. Clients must provide image pixels to visual consumers explicitly.

Validation (Python 3.12):

  • Initial new drawing-mode regression set: 8 failed / 5 passed on the previous implementation; the completed set has 25 passing cases. A separate stream-position regression failed before its correction and passed afterward.
  • Final core suite: 1,075 passed, 57 skipped. OCR: 108 passed. MCP: 22 passed. Black 23.7.0 and git diff --check passed. OCR/MCP suites run separately because their test package names collide in a combined invocation.
  • Covers native and SHX text, geometry-only pages, 90/180/270-degree text, rotated/cropped multipage files, decodable images, escaping, plugin bypass, missing dependencies, rendering failure, file/report/source collisions, symlinks, staging rollback, stream position, and archive assets/reports/failures.
  • Tested seven public PDFs / all 56 pages: five direct CAD exports and two processed drawing documents. No third-party PDFs or assets are committed. Page-view output was visually reviewed on representative drawings and a synthetic fixture.
  • Image sizing preceded the default choice: 23-page AutoCAD export at 200 DPI = 75,335,775 PNG bytes / 100,447,732 base64 bytes; dense Revit page = 3,696,835 / 4,929,116 bytes. External assets therefore remain default. Full conversion produced approximately 0.89 MB AutoCAD Markdown and 5 KB Revit Markdown; process high-water mark across the corpus was about 1.3 GB.

Scope: net +338 production lines, +342 test lines, +59 documentation lines. Growth adds drawing extraction, safe output publication, and integration/regression coverage. No new runtime/test dependencies. Independent from the opt-in rejection/warning PR #2668. Related overlapping proposals: #1398 (bbox JSON/OCR) and #2055 (embedded image extraction).

Refs #2688. This is a separate RFC/draft contribution; it does not imply maintainer approval of core placement or sidecar behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant