Skip to content

Fix spurious leading blank page for tabular inputs#41

Merged
billdenney merged 1 commit into
mainfrom
claude/sleepy-zhukovsky-c15c10
Jul 2, 2026
Merged

Fix spurious leading blank page for tabular inputs#41
billdenney merged 1 commit into
mainfrom
claude/sleepy-zhukovsky-c15c10

Conversation

@billdenney

Copy link
Copy Markdown
Member

Under the single-device design (D-48), export_tfl() opens one pdf(file) device for both pagination measurement and drawing. For tabular inputs, pagination's convertHeight()/grobHeight() calls open a blank page 1 on the pdf device (even a bare convertHeight() does this). The draw loop then began every page, including the first, with grid.newpage(), advancing past that blank page and emitting a spurious leading blank page. Figures never measure, so their device stayed pristine and the first grid.newpage() was a no-op -- which is why the blank appeared only for tables.

Add a newpage = TRUE argument to export_tfl_page(); the normal-mode draw loop sets newpage = FALSE for the first page so drawing reuses the already-open page instead of advancing past it. When FALSE, the viewport stack is reset with grid::upViewport(0) in place of grid.newpage(). Preview mode is unchanged.

Add regression tests (with a pdftools-free count_pdf_pages() helper), regenerate man/*.Rd, and document the change as decision D-51.

Under the single-device design (D-48), export_tfl() opens one pdf(file)
device for both pagination measurement and drawing. For tabular inputs,
pagination's convertHeight()/grobHeight() calls open a blank page 1 on the
pdf device (even a bare convertHeight() does this). The draw loop then began
every page, including the first, with grid.newpage(), advancing past that
blank page and emitting a spurious leading blank page. Figures never measure,
so their device stayed pristine and the first grid.newpage() was a no-op --
which is why the blank appeared only for tables.

Add a newpage = TRUE argument to export_tfl_page(); the normal-mode draw loop
sets newpage = FALSE for the first page so drawing reuses the already-open
page instead of advancing past it. When FALSE, the viewport stack is reset
with grid::upViewport(0) in place of grid.newpage(). Preview mode is unchanged.

Add regression tests (with a pdftools-free count_pdf_pages() helper),
regenerate man/*.Rd, and document the change as decision D-51.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@billdenney billdenney merged commit c2cea4c into main Jul 2, 2026
9 checks passed
@billdenney billdenney deleted the claude/sleepy-zhukovsky-c15c10 branch July 2, 2026 16:16
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