Overlay v6 annotations on the original PDF (preserve A4/source page size)#85
Open
williamjameshandley wants to merge 2 commits into
Conversation
Use the source PDF's page rect for the annotated page instead of the reMarkable canvas dimensions, and apply the rm-scene -> PDF coordinate transform in drawing.py (scale = pdf_w / 1872, x centered around 0). Skip the legacy pre-rescale for V6 files since it double-applies the offset. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
williamjameshandley
marked this pull request as draft
June 3, 2026 09:42
The previous commit changed drawing.py and dropped existing comments. Revert drawing.py to upstream and apply the v6 transform entirely via the existing rescale_parsed_data path: scale = dims.width / RM_HEIGHT and offset_x = (RM_HEIGHT / 2) * scale, with dims taken from the source PDF page rect. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
williamjameshandley
marked this pull request as ready for review
June 3, 2026 10:30
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.
Summary
On the
v6_with_rmscenebranch, v6 (.rmsoftware 3+) annotations are placed on the rendered PDF using a scale derived from the stroke bbox extent and an x-offset ofRM_WIDTH / 2. For overlays on real source PDFs, this puts margin annotations off the page — the rm-scene canvas is referenced against rm screen height (1872), not width, and the natural offset isRM_HEIGHT / 2.Output is also stretched to rm-canvas dimensions, distorting non-rM-aspect PDFs (e.g. A4 portrait, 595 × 842).
This PR keeps the v5 path unchanged and adds a v6 branch that overlays annotations on the source PDF at its native size using the existing
rescale_parsed_datahelper.Changes (single file, +12 / -17)
remarks/remarks.py:pdf_src[page_idx].rect(source PDF size), not the rm canvas. The source page is copied 1:1.else:.drawing.pyis untouched.Why this transform
rm-scene points have x centred on 0 with the canonical canvas extending ±RM_HEIGHT/2 (the rm screen-height units in which the device represents portrait pages). The linear map back to source PDF coords is
out = in * (pdf_w / RM_HEIGHT) + (RM_HEIGHT / 2) * (pdf_w / RM_HEIGHT)for x, andout = in * (pdf_w / RM_HEIGHT)for y, which is exactly thescale * point + offsetshape thatrescale_parsed_dataalready implements.Test plan
python -m remarks <dir> <out>on a v6.rmdocwhose source PDF is portrait A4 → output is A4 (pdfinfoshows 595 × 842).🤖 Generated with Claude Code