Fix spurious leading blank page for tabular inputs#41
Merged
Conversation
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>
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.
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.