(Feature) Add Duplex sort / collate documents (Fixes #220)#752
(Feature) Add Duplex sort / collate documents (Fixes #220)#752r0ckarong wants to merge 6 commits into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (14)
✅ Files skipped from review due to trivial changes (4)
🚧 Files skipped from review as they are similar to previous changes (7)
📝 WalkthroughWalkthroughAdds a new "Duplex Collate" tool to BentoPDF that reorders ADF-scanned PDFs from block front/back order into interleaved reading order. The tool registers itself in the tool config, catalog pages, i18n locale files (en/de), and translation key map. A new ChangesDuplex Collate tool
Sequence Diagram(s)sequenceDiagram
participant User
participant DuplexCollatePage
participant buildDuplexOrder
participant pdfLib as pdf-lib
participant JSZip
User->>DuplexCollatePage: Upload PDF file
DuplexCollatePage->>pdfLib: Load PDFDocument (with optional password)
pdfLib-->>DuplexCollatePage: PDFDocument + pageCount
DuplexCollatePage->>User: Show duplex options panel
User->>DuplexCollatePage: Click "Collate PDF"
DuplexCollatePage->>buildDuplexOrder: buildDuplexOrder(totalPages, splitPoint, backOrder)
buildDuplexOrder-->>DuplexCollatePage: { order[], frontCount, backCount }
alt front/back block sizes differ
DuplexCollatePage->>User: Confirm uneven blocks
end
alt grouped export enabled
loop per chunk
DuplexCollatePage->>pdfLib: createPdfFromIndices(chunk)
pdfLib-->>DuplexCollatePage: PDF bytes
DuplexCollatePage->>JSZip: Add chunk PDF to archive
end
JSZip-->>DuplexCollatePage: ZIP blob
DuplexCollatePage->>User: Download ZIP archive
else single PDF
DuplexCollatePage->>pdfLib: createPdfFromIndices(order)
pdfLib-->>DuplexCollatePage: PDF bytes
DuplexCollatePage->>User: Download collated PDF
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/tools/duplex-collate.md`:
- Around line 33-35: The current documentation for grouped mode on line 34
states it returns "one ZIP containing multiple PDFs" without clarifying the
behavior when only a single grouped chunk is produced. Update the grouped mode
description to explicitly note that a ZIP is returned only when multiple chunks
are created, but a single PDF is downloaded when the grouping results in only
one chunk. This will prevent user confusion about the output format based on the
actual chunking outcome.
In `@src/pages/duplex-collate.html`:
- Line 78: The HTMLHint linter is incorrectly flagging the `>` character in
valid Handlebars partial syntax `{{> navbar }}` as an unescaped spec character.
Add HTMLHint suppression comments above the affected lines (line 78 with the
navbar partial and line 268 with its similar partial reference) to tell HTMLHint
to ignore the spec-char-escape rule for these specific valid Handlebars
expressions, allowing the lint check to pass without blocking CI.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 147b7565-a204-4126-8f72-7779dbb0ad3f
📒 Files selected for processing (12)
docs/.vitepress/config.mtsdocs/tools/duplex-collate.mddocs/tools/index.mdpdf-merge-split.htmlpublic/locales/de/tools.jsonpublic/locales/en/tools.jsonsrc/js/config/tools.tssrc/js/logic/duplex-collate-page.tssrc/js/main.tssrc/pages/duplex-collate.htmlsrc/tests/duplex-collate.test.tstools.html
b35319b to
4daa155
Compare
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Improve function-level documentation coverage for duplex collate page functions to satisfy documentation quality checks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
feaa7dd to
ad5811e
Compare
Description
The new tool takes a PDF that contains the contents of a duplex scan (all front sides, all back sides) and sorts them into the correct "per document" order. It also allows saving the respective documents as separate files.
The tool also corrects the orientation of the scanned page block if the stack was inserted the wrong way on the second pass.
Fixes #220
Type of change
🧪 How Has This Been Tested?
Checklist:
Expected Results:
Actual Results:
Checklist:
FRONT11_collated_grouped.zip
FRONT11_collated.pdf
FRONT11.pdf
Summary by CodeRabbit
Summary