aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java18
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFRenderer.java4
2 files changed, 20 insertions, 2 deletions
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java
index 18717809d..c3242827a 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java
@@ -35,6 +35,7 @@ import org.apache.fop.pdf.PDFXObject;
import org.apache.fop.render.AbstractImageHandlerGraphics2D;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RenderingContext;
+import org.apache.fop.render.pdf.PDFLogicalStructureHandler.MarkedContentInfo;
import org.apache.fop.svg.PDFGraphics2D;
/**
@@ -63,6 +64,9 @@ public class PDFImageHandlerGraphics2D extends AbstractImageHandlerGraphics2D
renderer.currentPage,
renderer.getFontInfo());
Rectangle effPos = new Rectangle(origin.x + pos.x, origin.y + pos.y, pos.width, pos.height);
+ if (context.getUserAgent().isAccessibilityEnabled()) {
+ pdfContext.setMarkedContentInfo(renderer.addCurrentImageToStructureTree());
+ }
handleImage(pdfContext, image, effPos);
return null;
}
@@ -87,7 +91,13 @@ public class PDFImageHandlerGraphics2D extends AbstractImageHandlerGraphics2D
float sy = fheight / (float)imh;
generator.comment("G2D start");
- generator.saveGraphicsState();
+ boolean accessibilityEnabled = context.getUserAgent().isAccessibilityEnabled();
+ if (accessibilityEnabled) {
+ MarkedContentInfo mci = pdfContext.getMarkedContentInfo();
+ generator.saveGraphicsState(mci.tag, mci.mcid);
+ } else {
+ generator.saveGraphicsState();
+ }
generator.updateColor(Color.black, false, null);
generator.updateColor(Color.black, true, null);
@@ -115,7 +125,11 @@ public class PDFImageHandlerGraphics2D extends AbstractImageHandlerGraphics2D
imageG2D.getGraphics2DImagePainter().paint(graphics, area);
generator.add(graphics.getString());
- generator.restoreGraphicsState();
+ if (accessibilityEnabled) {
+ generator.restoreGraphicsStateAccess();
+ } else {
+ generator.restoreGraphicsState();
+ }
generator.comment("G2D end");
}
diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
index 380241ba0..6188433c6 100644
--- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java
+++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java
@@ -1347,5 +1347,9 @@ public class PDFRenderer extends AbstractPathOrientedRenderer implements PDFConf
public void setEncryptionParams(PDFEncryptionParams encryptionParams) {
this.pdfUtil.setEncryptionParams(encryptionParams);
}
+
+ MarkedContentInfo addCurrentImageToStructureTree() {
+ return logicalStructureHandler.addImageContentItem(imageReference);
+ }
}