
Turning one tall image into an A4 PDF sounds like simple arithmetic: calculate the page height and cut every fixed number of pixels. That approach can divide a line of text, detach a total from its label, or split a chart legend from the chart. Screenshot PDF therefore treats the mathematical A4 boundary as a proposal and searches for a visually quieter cut nearby.
This article documents the current version 0.0.13 algorithm. It explains what the pixel analysis can detect, what it cannot understand, and how to review the output without claiming that pixels reveal document semantics.
For portrait A4, the height-to-width ratio is approximately 1.4142. If an input Canvas is 1,000 pixels wide, a full A4-shaped page region is approximately 1,414 pixels high. The editor uses the source Canvas width so that pagination preserves the captured image's horizontal resolution.
If the image fits within one page, it remains one image. No-split mode also bypasses automatic pagination. Otherwise the editor proposes a boundary one A4-height below the current start position.
Pages use tinted backgrounds, table rules, cards, dark themes, photographs, and gradients. A useful boundary might be pale blue rather than white. Conversely, a white row can still contain thin text that should not be cut. Screenshot PDF measures horizontal color transitions across each candidate row instead of testing only brightness.
For every other horizontal pixel, the algorithm compares RGB values with a pixel two positions away. Differences above a threshold contribute to the row's transition energy. Dense text and detailed images tend to produce more transitions; open margins and simple horizontal bands tend to produce fewer.

A single unusually quiet row may be an antialiased edge or rendering artifact. The editor sums each row with its immediate neighbors, creating a three-row vertical smoothing window. It finds the minimum smoothed energy in the current page-sized search region, then accepts rows within a small tolerance of that minimum.
The search moves backward from the proposed A4 boundary. This preference uses as much of the page as possible while still choosing a visually quieter row. A minimum chunk height of 15 percent of an A4 page prevents the search from returning a tiny strip near the top.
Some images contain dense detail from top to bottom: photographs, maps, spreadsheets, code listings, or dashboards with a full-bleed background. If no qualifying lower-energy row appears above the minimum chunk height, the algorithm uses the proposed mathematical boundary.
That fallback is intentional. Returning no page would be worse, and moving arbitrarily far upward could produce dozens of mostly empty sheets. The preview exposes the result so the user can choose a different orientation, crop, margin, zoom, or sectional capture.
Intermediate slices are placed on a white Canvas with the A4-shaped height. If a safe boundary moves upward, the unused lower area remains white. The final sheet can use its actual shorter height instead of forcing an unnecessary full blank tail.
White padding is not evidence that source content was lost. It can indicate that the algorithm chose an earlier quiet boundary. Verify continuity by comparing the last visible row of one page with the first visible row of the next.
These are visual tendencies, not guaranteed categories. A table with tightly packed multi-line cells can still require manual review.
The algorithm does not understand that a signature belongs with a declaration, a subtotal belongs with item rows, or a chart legend belongs with a chart. It does not parse HTML, reading order, accessibility roles, or legal meaning because it receives an image.
Review every boundary near:
If the semantic relationship matters, make a smaller source capture around the complete unit or use a born-digital document.
Open the PDF at 100 percent. For each transition, record the last meaningful object on the first page and the first object on the next. Confirm that no text line, number, icon, or machine-readable code is divided. Repeat the check in a second PDF viewer because scaling and antialiasing differ.
For a controlled test, create three source bands: paragraph text, a table, and a full-bleed image. Capture the page at a recorded viewport and zoom. The expected outcome is not “no cut ever,” but a documented boundary choice and an honest fallback when the dense band offers no safe gap.
Pixel energy can reduce awkward cuts, but it cannot certify a document. Automatic pagination is a suggestion engine operating on visual information. The preview is where a user decides whether the suggestion preserves meaning.
The strongest workflow combines a deterministic ratio, a bounded visual search, transparent fallback behavior, and page-by-page inspection. That is more dependable than promising that an automatic algorithm can understand every webpage from pixels alone.