Skip to content

Commit 11d2827

Browse files
Fix layout tagging for Canvas
DEVSIX-1652
1 parent 4cdd4ff commit 11d2827

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

layout/src/main/java/com/itextpdf/layout/renderer/CanvasRenderer.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,17 @@ protected void flushSingleRenderer(IRenderer resultRenderer) {
109109
if (toTag) {
110110
tagPointer = canvas.getPdfDocument().getTagStructureContext().getAutoTaggingPointer();
111111
tagPointer.setPageForTagging(canvas.getPage());
112-
tagPointer.setContentStreamForTagging(canvas.getPdfCanvas().getContentStream());
112+
113+
boolean pageStream = false;
114+
for (int i = canvas.getPage().getContentStreamCount() - 1; i >= 0; --i) {
115+
if (canvas.getPage().getContentStream(i).equals(canvas.getPdfCanvas().getContentStream())) {
116+
pageStream = true;
117+
break;
118+
}
119+
}
120+
if (!pageStream) {
121+
tagPointer.setContentStreamForTagging(canvas.getPdfCanvas().getContentStream());
122+
}
113123
}
114124
resultRenderer.draw(new DrawContext(canvas.getPdfDocument(), canvas.getPdfCanvas(), toTag));
115125
if (toTag) {

0 commit comments

Comments
 (0)