From 7a310d0edfab5ee76303d2efb5e55373fbb176d2 Mon Sep 17 00:00:00 2001 From: Ignacio Rodriguez Date: Tue, 29 Oct 2019 16:16:28 -0300 Subject: [PATCH] lang and title support for span tag --- .../pdfboxout/PdfBoxAccessibilityHelper.java | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxAccessibilityHelper.java b/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxAccessibilityHelper.java index 135cb459c..ea5e70407 100644 --- a/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxAccessibilityHelper.java +++ b/openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxAccessibilityHelper.java @@ -75,7 +75,8 @@ private static Map> createTagSupplier suppliers.put("th", TableHeaderStructualElement::new); suppliers.put("a", AnchorStuctualElement::new); - + suppliers.put("span", SpanStuctualElement::new); + return suppliers; } @@ -236,7 +237,30 @@ void finish(AbstractStructualElement parent) { finishTreeItems(child.children, child); } } - + + private static class SpanStuctualElement extends GenericStructualElement { + @Override + String getPdfTag() { + return StandardStructureTypes.SPAN; + } + + @Override + void finish(AbstractStructualElement parent) { + SpanStuctualElement child = this; + + createPdfStrucureElement(parent, child); + + if (box.getElement() != null) { + String alternate = box.getElement().getAttribute("title"); + String lang = box.getElement().getAttribute("lang"); + child.elem.setAlternateDescription(alternate); + if (!lang.isEmpty()) child.elem.setLanguage(lang); + } + + finishTreeItems(child.children, child); + } + } + private static class ListStructualElement extends AbstractStructualElement { final List listItems = new ArrayList<>();