Skip to content

Add opt-in CAD PDF rejection and loss warnings - #2668

Open
Çağdaş Yürekli (cagdasyurekli) wants to merge 3 commits into
microsoft:mainfrom
cagdasyurekli:fix/cad-pdf-rejection-2667
Open

Çağdaş Yürekli (cagdasyurekli) wants to merge 3 commits into
microsoft:mainfrom
cagdasyurekli:fix/cad-pdf-rejection-2667

Conversation

@cagdasyurekli

@cagdasyurekli Çağdaş Yürekli (cagdasyurekli) commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

CAD-exported PDFs can return successful Markdown containing only labels, or effectively no content, while losing the drawing. Add an opt-in --reject-cad-pdfs / convert(..., reject_cad_pdfs=True) policy that rejects PDFs identifying AutoCAD, Revit, SolidWorks, or MicroStation in Creator/Producer metadata.

The check runs locally before converter selection, so plugins, cloud converters, and extraction fallbacks cannot bypass it. When the option is omitted, extraction and Markdown content remain unchanged, but a successfully converted PDF identifying a known CAD exporter emits a UserWarning (stderr in the CLI). Warning detection is best-effort and does not block custom/cloud conversion if PDF dependencies or inspectable metadata are absent. CLI rejection occurs before output is written.

This is a conservative exporter policy, not a drawing classifier: it also rejects text-heavy exports from those applications and cannot detect missing/rewritten metadata or unknown exporters. Passing the check does not establish fidelity. ZIP input retains its existing unsupported-member skipping behavior. Faithful drawing interpretation is outside this change.

Closes #2667.

Validation:

  • 14 of the initial 20 regression cases failed on the original source; all rejection tests now pass.
  • Final core suite: 1,081 passed, 57 skipped (GITHUB_ACTIONS=true python -m pytest packages/markitdown/tests -q, Python 3.12).
  • MCP suite: 21 passed.
  • OCR suite: 108 passed; no external OCR/model requests.
  • Black 23.7.0 check and git diff --check passed.
  • Synthetic PDFs have valid xref offsets; the vector plan was rendered and visually inspected.
  • Tested seven public PDFs (56 pages), including five Creator-metadata-confirmed CAD exports (28 pages). The strict policy rejects all five after accommodating case-insensitive metadata field names. A real Revit 2026 export uses /creator instead of /Creator; two additional regression cases fail before that correction and pass afterward. Two processed drawing documents identify PowerPoint or a scanner and demonstrate the documented detection limit. Third-party PDFs are not included in the repository.

Public direct-export samples: Revit 2026, SOLIDWORKS 2024, SOLIDWORKS 2025, MicroStation 8.5, and AutoCAD LT 2024. Conversion was tested on complete documents; 11 representative pages across the seven PDFs were rendered and visually inspected. The PowerPoint-processed document already has visible overlap in its source; that is not attributed to MarkItDown.

Scope: net +84 production lines, +208 test lines, +38 documentation lines. No new runtime or test dependencies.

Three warning regressions failed before the warning change and pass afterward. PDF metadata is inspected with pdfminer without loading pages, preserving the one-pass page-cleanup behavior verified by the existing memory tests. Drawing-aware extraction and Markdown reporting are separate proposals; this PR does not change the default to rejection.

@cagdasyurekli Çağdaş Yürekli (cagdasyurekli) changed the title Add opt-in rejection of known CAD-exported PDFs Add opt-in CAD PDF rejection and loss warnings Oct 10, 2026
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.

Feature request: reject known CAD-exported PDFs when partial text extraction is unacceptable

1 participant