From 61462bd27b424b73dc00b448b8584858f98d8fa6 Mon Sep 17 00:00:00 2001 From: giovi321 Date: Sun, 13 Sep 2026 01:41:34 +0200 Subject: [PATCH] fix: keep every page of a document, so annotations land on the right one Only pages carrying ink were added to the archive's page list, and the exporter takes a page's background from its position in that list. So on a partly annotated document the nth page with ink was drawn over the nth page of the document. Reported in #228. Measured on a 28 page document annotated on 14: the export had 14 pages, the backgrounds were source pages 1 to 14 in order, and the ink from page 8 was drawn over the background of page 3. That ink was confirmed as page 8's by comparing it against a copy of the same page exported by the tablet itself, 99.9% of its pixels matching. Adding an entry for every declared page puts each one back over its own background, and keeps the pages nobody drew on, which is the other half of the report. The same document now exports 28 pages, each over its own source page. This says nothing about where ink sits on a page. #483 covers that, and a landscape document needs both. --- internal/storage/models/archive.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/internal/storage/models/archive.go b/internal/storage/models/archive.go index d244db6d..729d13a0 100644 --- a/internal/storage/models/archive.go +++ b/internal/storage/models/archive.go @@ -65,7 +65,15 @@ func ArchiveFromHashDoc(doc *HashDoc, rs RemoteStorage) (*exporter.MyArchive, er } } + // Every page the document declares gets an entry, whether or not anyone + // drew on it. The exporter takes a page's background from its position in + // this list, so leaving the untouched ones out moves every page after + // them: the nth page with ink ends up over the nth page of the document. for _, p := range a.Content.Pages { + page := archive.Page{ + Pagedata: "Blank", + } + if hash, ok := pageMap[p]; ok { log.Debug("page ", hash) reader, err := rs.GetReader(hash) @@ -82,12 +90,10 @@ func ArchiveFromHashDoc(doc *HashDoc, rs RemoteStorage) (*exporter.MyArchive, er return nil, err } - page := archive.Page{ - Data: rmpage, - Pagedata: "Blank", - } - a.Pages = append(a.Pages, page) + page.Data = rmpage } + + a.Pages = append(a.Pages, page) } return &a, nil