Skip to content

Overlay v6 annotations on the original PDF (preserve A4/source page size)#85

Open
williamjameshandley wants to merge 2 commits into
Scrybbling-together:v6_with_rmscenefrom
williamjameshandley:fix/v6-overlay-on-original-pdf
Open

Overlay v6 annotations on the original PDF (preserve A4/source page size)#85
williamjameshandley wants to merge 2 commits into
Scrybbling-together:v6_with_rmscenefrom
williamjameshandley:fix/v6-overlay-on-original-pdf

Conversation

@williamjameshandley

@williamjameshandley williamjameshandley commented Jun 3, 2026

Copy link
Copy Markdown

Summary

On the v6_with_rmscene branch, v6 (.rm software 3+) annotations are placed on the rendered PDF using a scale derived from the stroke bbox extent and an x-offset of RM_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 is RM_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_data helper.

Changes (single file, +12 / -17)

remarks/remarks.py:

  • Page is created at pdf_src[page_idx].rect (source PDF size), not the rm canvas. The source page is copied 1:1.
  • In the rescale block, V6 takes a new branch:
    scale = dims.width / RM_HEIGHT
    offset_x = (RM_HEIGHT / 2) * scale
    ann_data = rescale_parsed_data(ann_data, scale, offset_x, offset_y)
  • V5 logic (the existing extent-derived scale branch) is wrapped unchanged in else:.

drawing.py is 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, and out = in * (pdf_w / RM_HEIGHT) for y, which is exactly the scale * point + offset shape that rescale_parsed_data already implements.

Test plan

  • python -m remarks <dir> <out> on a v6 .rmdoc whose source PDF is portrait A4 → output is A4 (pdfinfo shows 595 × 842).
  • Annotations land within the A4 page bounds, aligned with the content they were drawn next to on the device.
  • Verify against landscape PDF and rM-native-aspect notebook cases.

🤖 Generated with Claude Code

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
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
williamjameshandley marked this pull request as ready for review June 3, 2026 10:30
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