Repository navigation
Pad the PDF export to an even page count or a multiple of four - #282
Merged
Merged
Conversation
Contributor
|
The preview of this pull request is deleted. |
Contributor
CI — all green
perf-gate — nativeperf-gate — wasmFull run · commit |
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.
Closes #186
exportPdftakes a page count to pad to. The PDF writer adds blank pages after the last page of the book until the PDF has an even page count or a multiple of four.What changed
fleuron::pdfhasPadTo::{Even, MultipleOfFour},write_padded, andpage_count.writeis unchanged and pads nothing.Session::export_padded(pad)writes the padded PDF.Session::exported_pages(pad)returns the page count without writing the PDF.exportPdf(multipleOf?), wheremultipleOfis 2 or 4, and haspdfPages(multipleOf?). Any other number is an error.Client.exportPdf(ops, { multipleOf })andPreview.exportPdf({ multipleOf })pad the PDF.Client.pdfPagesandPreview.pdfPagesreturn the page count. The reply towant: 'pdf'haspages, andwant: 'pages'is the question.Decisions for the reviewer
exportPdfstill returnsUint8Array | null. The page count is on the worker reply aspages, andClientreturns it throughpdfPagesand not through the return value ofexportPdf. This keeps every existing caller working. If you preferexportPdfto return{ bytes, pages }, that is a breaking change that I did not make without asking.exportPdfand the session only.Tests
pdf::tests::a_book_is_padded_to_an_even_count_or_a_multiple_of_four, andthe_export_takes_a_count_and_says_how_many_pages_it_writesin the session, for the first checkbox.pdf::tests::a_blank_leaf_is_the_size_of_the_last_page_and_carries_nothingfor the second. The book has a running head, a page number, a bleed, and crop marks, and its two pages differ in size.session::output::tests::padding_runs_no_stage_and_leaves_the_preview_as_it_wasfor the third.pdf::tests::the_count_answered_is_the_count_writtenfor the fourth.crates/fleuron-wasm/tests/pdf.rscovers the binding, and the worker harness pads the fixture book (25 pages to 26 and to 28) and readspagesfrom the reply.The CI mirror is green locally, and so is
npm testincrates/fleuron-wasm/npmagainst a fresh module. I did not run the browser test, the package test, or the docs build locally.