Skip to content

Put two piles of scans together, and put a document on one sheet - #19

Merged
tannevaled merged 1 commit into
mainfrom
alternate-and-combine
Aug 30, 2026
Merged

Put two piles of scans together, and put a document on one sheet#19
tannevaled merged 1 commit into
mainfrom
alternate-and-combine

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Two verbs a page-manipulation library should have had.

Interleave takes pages from each document in turn. It is what a single-sided feeder leaves behind: a stack run through twice comes out as two files — the fronts and the backs — which is one document taken apart. Merging them end to end gives every front then every back; this gives the document. A shorter pile simply runs out, which is what a scanner leaves when the last sheet is single-sided.

OnePage stacks every page onto one sheet, one below the other. A page is a unit of paper, not a unit of reading: a receipt, a chat log and a web page cut into A4 are one thing a printer divided, and this puts them back so what is read scrolls rather than turns. Narrower pages are centred, because a column that jumps from side to side is harder to read than one that does not.

The order is asserted, not looked at

A PDF's origin is at the bottom, so the first page takes the largest offset and the last sits at zero. Reversed, every page is still there and the document is upside down — which no count of pages would catch.

And poppler was asked rather than ourselves

Three pages carrying a mark at a different height each, stacked and rendered:

measured computed
page 1's mark 28% 26.7%
page 2's mark 48% 46.7%
page 3's mark 70% 68.3%

Parity: BentoPDF's Alternate & Mix Pages and Combine to Single Page.

100% statement coverage, go vet and -race clean, nine cross-compile targets.

Two verbs a page-manipulation library should have had.

Interleave takes pages from each document in turn. It is what a single-sided
feeder leaves behind: a stack run through twice comes out as two files, the
fronts and the backs, which is one document taken apart. Merging them end to
end gives every front then every back; this gives the document. A shorter pile
simply runs out, which is what a scanner leaves when the last sheet is
single-sided.

OnePage stacks every page onto one sheet, one below the other. A page is a unit
of paper, not a unit of reading: a receipt, a chat log and a web page cut into
A4 are one thing a printer divided, and this puts them back so that what is
read scrolls rather than turns. The sheet is as wide as the widest page and as
tall as all of them stacked, and narrower pages are centred, because a column
that jumps from side to side is harder to read than one that does not.

The order is asserted rather than looked at. A PDF's origin is at the bottom,
so the FIRST page takes the LARGEST offset and the last sits at zero. Reversed,
every page is still there and the document is upside down — which no count of
pages would catch.

And poppler was asked rather than ourselves. Three pages carrying a mark at a
different height each, stacked and rendered: the marks come out at 28%, 48% and
70% of the sheet, against 26.7%, 46.7% and 68.3% computed from where they were
put.

Parity: BentoPDF's "Alternate & Mix Pages" and "Combine to Single Page".

100% statement coverage, go vet and -race clean, nine cross-compile targets.
@tannevaled
tannevaled merged commit b3f5b63 into main Aug 30, 2026
1 check passed
@tannevaled
tannevaled deleted the alternate-and-combine branch August 30, 2026 12:42
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