From d9debcfb0d4134b63aa5ab402670e0577811a8e9 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Thu, 15 Feb 2024 23:20:29 +0200 Subject: [PATCH] process annotations --- lib/pdf_processor.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/pdf_processor.rb b/lib/pdf_processor.rb index e0ad0198..2c485132 100644 --- a/lib/pdf_processor.rb +++ b/lib/pdf_processor.rb @@ -70,6 +70,18 @@ class PdfProcessor < HexaPDF::Content::Processor page.contents = process_handler_instance.contents end + page[:Annots].to_a.each do |annot| + next unless annot + + text = annot[:Contents].to_s.squish + + next unless text.starts_with?('{{') && text.ends_with?('}}') + + result_handler.call({ text:, rect: annot[:Rect] }, page, acc) + + page[:Annots].delete(annot) + end + process_handler_instance.result.each do |item| result_handler.call(item, page, acc) end