@@ -830,26 +830,35 @@ function page_mt.__index:updateMarkupAnnotation(annot, contents)
830830 if ok == nil then merror (self .ctx , " could not update markup annot contents" ) end
831831end
832832
833- function page_mt .__index :getMarkupAnnotationBoxesFromPage ()
834- local boxes = {}
833+ function page_mt .__index :getEmbeddedAnnotations ()
834+ local annotations = {}
835835 local annot = W .mupdf_pdf_first_annot (self .ctx , ffi .cast (" pdf_page*" , self .page ))
836836 while annot ~= nil do
837- local annot_boxes = {}
838- local quadpoint = ffi .new (" fz_quad[1]" )
839- local point_count = W .mupdf_pdf_annot_quad_point_count (self .ctx , annot )
840- for i = 0 , point_count - 1 do
841- W .mupdf_pdf_annot_quad_point (self .ctx , annot , i , quadpoint )
842- table.insert (annot_boxes , {
843- h = quadpoint [0 ].ll .y - quadpoint [0 ].ul .y + 1 ,
844- w = quadpoint [0 ].ur .x - quadpoint [0 ].ul .x + 1 ,
845- x = quadpoint [0 ].ul .x ,
846- y = quadpoint [0 ].ul .y ,
837+ local annot_type = W .mupdf_pdf_annot_type (self .ctx , annot )
838+ -- markup annotations: highlight=8, underline=9, squiggly=10, strikeout=11
839+ if annot_type >= 8 and annot_type <= 11 then
840+ local annot_boxes = {}
841+ local quadpoint = ffi .new (" fz_quad[1]" )
842+ local point_count = W .mupdf_pdf_annot_quad_point_count (self .ctx , annot )
843+ for i = 0 , point_count - 1 do
844+ W .mupdf_pdf_annot_quad_point (self .ctx , annot , i , quadpoint )
845+ table.insert (annot_boxes , {
846+ h = quadpoint [0 ].ll .y - quadpoint [0 ].ul .y + 1 ,
847+ w = quadpoint [0 ].ur .x - quadpoint [0 ].ul .x + 1 ,
848+ x = quadpoint [0 ].ul .x ,
849+ y = quadpoint [0 ].ul .y ,
850+ })
851+ end
852+ local contents = W .mupdf_pdf_annot_contents (self .ctx , annot )
853+ table.insert (annotations , {
854+ boxes = annot_boxes ,
855+ type = annot_type ,
856+ contents = contents ~= nil and ffi .string (contents ) or nil ,
847857 })
848858 end
849- table.insert (boxes , annot_boxes )
850859 annot = W .mupdf_pdf_next_annot (self .ctx , annot )
851860 end
852- return next (boxes ) and boxes
861+ return next (annotations ) and annotations
853862end
854863
855864-- image loading via MuPDF:
0 commit comments