Skip to content

mupdf: add getMarkupAnnotationBoxesFromPage()#2280

Merged
hius07 merged 1 commit into
koreader:masterfrom
hius07:master
Feb 28, 2026
Merged

mupdf: add getMarkupAnnotationBoxesFromPage()#2280
hius07 merged 1 commit into
koreader:masterfrom
hius07:master

Conversation

@hius07

@hius07 hius07 commented Feb 26, 2026

Copy link
Copy Markdown
Member

Will be used to import PDF embedded highlights.


This change is Reviewable

Comment thread ffi/mupdf.lua
})
end
table.insert(boxes, annot_boxes)
annot = W.mupdf_pdf_next_annot(self.ctx, annot)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there also be a pdf_drop_annot somewhere in there?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original mupdf has pdf_drop_annot():
https://github.com/ArtifexSoftware/mupdf/blob/3d40818e511eaf8c49b92d8d3d4dc05fe76ab0f0/include/mupdf/pdf/annot.h#L168-L174

But it is not exposed, and is not used in existing

koreader-base/ffi/mupdf.lua

Lines 800 to 826 in 36613d0

function page_mt.__index:getMarkupAnnotation(points, n)
local annot = W.mupdf_pdf_first_annot(self.ctx, ffi.cast("pdf_page*", self.page))
while annot ~= nil do
local n2 = W.mupdf_pdf_annot_quad_point_count(self.ctx, annot)
if n == n2 then
local quadpoint = ffi.new("fz_quad[1]")
local match = true
for i = 0, n-1 do
W.mupdf_pdf_annot_quad_point(self.ctx, annot, i, quadpoint)
if (points[i].ul.x ~= quadpoint[0].ul.x or
points[i].ul.y ~= quadpoint[0].ul.y or
points[i].ur.x ~= quadpoint[0].ur.x or
points[i].ur.y ~= quadpoint[0].ur.y or
points[i].ll.x ~= quadpoint[0].ll.x or
points[i].ll.y ~= quadpoint[0].ll.y or
points[i].lr.x ~= quadpoint[0].lr.x or
points[i].lr.y ~= quadpoint[0].lr.y) then
match = false
break
end
end
if match then return annot end
end
annot = W.mupdf_pdf_next_annot(self.ctx, annot)
end
return nil
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, sounds like it happens automatically.

/*
	Returns a borrowed reference to the next annotation
	on a page, or NULL if none.

	The caller should fz_keep this if it intends to hold the
	pointer. Unless it fz_keeps it, it must not fz_drop it.
*/
pdf_annot *pdf_next_annot(fz_context *ctx, pdf_annot *annot);

@hius07 hius07 merged commit 2014b8a into koreader:master Feb 28, 2026
3 checks passed
benoit-pierre added a commit to benoit-pierre/koreader that referenced this pull request Feb 28, 2026
- zlib: update to 1.3.2 (koreader/koreader-base#2278)
- Expose MuPDF's search function (koreader/koreader-base#2279)
- mupdf: add getMarkupAnnotationBoxesFromPage() (koreader/koreader-base#2280)
- luajit: update to 2.1.1772148810 (koreader/koreader-base#2281)
Frenzie pushed a commit to koreader/koreader that referenced this pull request Feb 28, 2026
- zlib: update to 1.3.2 (koreader/koreader-base#2278)
- Expose MuPDF's search function (koreader/koreader-base#2279)
- mupdf: add getMarkupAnnotationBoxesFromPage() (koreader/koreader-base#2280)
- luajit: update to 2.1.1772148810 (koreader/koreader-base#2281)
benoit-pierre pushed a commit to benoit-pierre/koreader that referenced this pull request Mar 1, 2026
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
- zlib: update to 1.3.2 (koreader/koreader-base#2278)
- Expose MuPDF's search function (koreader/koreader-base#2279)
- mupdf: add getMarkupAnnotationBoxesFromPage() (koreader/koreader-base#2280)
- luajit: update to 2.1.1772148810 (koreader/koreader-base#2281)
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.

2 participants