Skip to content

Add PDF -> XLSX conversion support#29

Open
sergeyFlakon wants to merge 1 commit into
masterfrom
feature/pdf-to-xlsx
Open

Add PDF -> XLSX conversion support#29
sergeyFlakon wants to merge 1 commit into
masterfrom
feature/pdf-to-xlsx

Conversation

@sergeyFlakon

@sergeyFlakon sergeyFlakon commented Jul 6, 2026

Copy link
Copy Markdown

What

Adds PDF → XLSX conversion: mpx convert input.pdf output.xlsx.

xlsx is a supported v3/pdf conversion output — it extracts tabular content, producing one worksheet per detected table. The PDF path already downloads v3/pdf/{id}.{ext} directly, so this only needed:

  • .xlsx added to validDestinationExtensions (lib/mpx.js)
  • a pdf → xlsx dispatch case (lib/mpx.js)
  • PDFToXLSX() = ConvertPDF("xlsx", …) + export (lib/convert.js)
  • README example + command description

Scope: PDF sources only

Image and Markdown sources are intentionally not wired to xlsx. Both convert the OCR'd MMD through the /v1/export/{fmt} endpoints, and there is no /v1/export/xlsx endpoint. image.png → out.xlsx / doc.mmd → out.xlsx therefore fall through to the existing "Not implemented yet" message rather than failing on an invalid extension.

Supporting image/MMD → xlsx would require backend work — either adding a /v1/export/xlsx Snip endpoint, or rerouting the non-PDF paths through v3/converter (which does support xlsx). Left as a follow-up.

Testing

  • node --check on both edited files.
  • Validated against the live API using the CLI's exact call pattern: POST /v3/pdf-file (file only, no conversion_formats) → GET /v3/pdf/{id}.xlsx returns HTTP 200, a valid .xlsx (Microsoft Excel 2007+, one worksheet per detected table). Confirms the download path the CLI relies on produces xlsx without any extra submit options. Temporary test app_key deleted after verification.

Release note

Version not bumped — leaving the minor bump + npm publish to your normal release flow. This is a feature add (suggest 0.4.0 → 0.5.0).

Attribution

Triggered by user request: documenting/enabling XLSX across Mathpix conversion surfaces (companion to monorepo docs PR #21361 and website PR #21374). mathpix.com/docs/snip/mpx-cli should advertise xlsx only after this ships.

🤖 Generated with Claude Code

`mpx convert input.pdf output.xlsx` now works. xlsx is a supported
v3/pdf conversion output (extracts tabular content, one worksheet per
detected table). The PDF path downloads v3/pdf/{id}.xlsx directly, so
this only needs the new destination extension + dispatch case.

Scope: PDF sources only. Image and Markdown sources are intentionally
not wired up — those paths convert the OCR'd MMD via the /v1/export/*
endpoints, and there is no /v1/export/xlsx endpoint. Supporting them
would require backend work (a /v1/export/xlsx endpoint or rerouting
those paths through v3/converter) and is left as a follow-up.

Validated against the live API: POST /v3/pdf-file (file only) then
GET /v3/pdf/{id}.xlsx returns a valid .xlsx (HTTP 200), matching the
CLI's exact call pattern.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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