Repository navigation
word and excel: the same reading, written out as Office files - #50
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pdfops wordandpdfops excelwrite the documentgo-pdfkit/documentreads off thepages as a
.docxor an.xlsx, throughgo-ooxml v0.3.0. That is BentoPDF's
pdf-to-wordandpdf-to-excel.⛔ What comes out is the document, not the pages. The fonts, the margins and
the page breaks are the typesetter's work; a
.docxthat reproduced them wouldbe a picture of a PDF rather than something anybody can edit.
⛔
excelwrites only the tables, one sheet each. A spreadsheet is a gridof 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
-pagesmeans the same thing in each and a defect found in one isfixed 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-ooxmlv0.3.0 fails only for a nildocument, 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
.docxcame back with its headings,paragraphs and indented bullets; the
.xlsxwith 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:
Both now assert what came back and what did not.
🤖 Generated with Claude Code