Skip to content

word and excel: the same reading, written out as Office files - #50

Merged
tannevaled merged 1 commit into
mainfrom
out-as-a-word-document-or-a-workbook
Oct 12, 2026
Merged

tannevaled merged 1 commit into
mainfrom
out-as-a-word-document-or-a-workbook

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

pdfops word and pdfops excel write the document
go-pdfkit/document reads off the
pages as a .docx or an .xlsx, through
go-ooxml v0.3.0. That is BentoPDF's
pdf-to-word and pdf-to-excel.

pdfops word report.pdf report.docx
pdfops excel accounts.pdf accounts.xlsx

⛔ What comes out is the document, not the pages. The fonts, the margins and
the page breaks are the typesetter's work; a .docx that reproduced them would
be a picture of a PDF rather than something anybody can edit.

⛔ excel writes only the tables, one sheet each. A spreadsheet is a grid
of cells and a document is not, so the prose around a table has nowhere to go —
and a page with no tables gives the one empty sheet a workbook has to have
rather than an error.

One function, two writers

Which is why -pages means the same thing in each and a defect found in one is
fixed in both. It also makes the writer a seam: the one branch no input can
reach — a writer that refuses — is covered by passing one that does, rather
than left as a branch nobody can see. go-ooxml v0.3.0 fails only for a nil
document, and the document here is never nil; the check stays so that a writer
gaining a failure mode later cannot mean a truncated file reported as bytes.

Smoke-tested through a reader other people wrote

LibreOffice, on a real 2-page PDF: the .docx came back with its headings,
paragraphs and indented bullets; the .xlsx with its table as cells.

How it is checked

100% of statements with no uncovered blocks, 8 mutations caught. Two were
survivors that said my tests were weak rather than the code:

the assertion what it could not tell apart
"it wrote some bytes" a range honoured from a range ignored
"it mentioned bytes" a real byte count from zero

Both now assert what came back and what did not.

🤖 Generated with Claude Code

pdfops word and pdfops excel write the document go-pdfkit/document reads off
the pages as a .docx or an .xlsx, through go-ooxml v0.3.0. That is BentoPDF's
pdf-to-word and pdf-to-excel.

What comes out is the DOCUMENT, not the pages. The fonts, the margins and the
page breaks are the typesetter's work, and a .docx that reproduced them would
be a picture of a PDF rather than something anybody can edit.

excel writes only the tables, one sheet each: a spreadsheet is a grid of cells
and a document is not, so the prose around a table has nowhere to go. A page
with no tables gives the one empty sheet a workbook has to have, not an error.

Both are one function with a different writer, which is why -pages means the
same thing in each and a defect found in one is fixed in both. It also makes
the writer a SEAM: the one branch no input can reach -- a writer that refuses
-- is covered by passing one that does, rather than left as a branch nobody
can see.

Smoke-tested through LibreOffice on a real 2-page PDF, which is a reader other
people wrote: the .docx came back with its headings, paragraphs and indented
bullets; the .xlsx with its table as cells.

100% of statements with no uncovered blocks, 8 mutations caught. Two were
survivors that said my tests were weak rather than the code: "it wrote some
bytes" could not tell a correct range from an ignored one, and "it mentioned
bytes" could not tell a real count from zero.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit bed8643 into main Oct 12, 2026
1 check passed
@tannevaled
tannevaled deleted the out-as-a-word-document-or-a-workbook branch October 12, 2026 08:58
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