aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2014-04-04 15:52:30 +0000
committerVincent Hennebert <vhennebert@apache.org>2014-04-04 15:52:30 +0000
commit5cae15e0accf7bb753111394ba9870f5b815ab29 (patch)
tree88932201329ff59d7f7be340b54e2a5d6704dc8f /src
parentf8dd89a164228d28afd6080fb37e1f94b3e30a09 (diff)
downloadxmlgraphics-fop-5cae15e0accf7bb753111394ba9870f5b815ab29.tar.gz
xmlgraphics-fop-5cae15e0accf7bb753111394ba9870f5b815ab29.zip
FOP-2363: Better error message when PDF/A enabled and SVG contains bitmap with transparency
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1584765 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/pdf/PDFProfile.java3
-rw-r--r--src/java/org/apache/fop/pdf/TransparencyDisallowedException.java57
-rw-r--r--src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java5
-rw-r--r--src/java/org/apache/fop/svg/SVGEventProducer.java9
-rw-r--r--src/java/org/apache/fop/svg/SVGEventProducer.xml1
5 files changed, 73 insertions, 2 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFProfile.java b/src/java/org/apache/fop/pdf/PDFProfile.java
index 4ae5ba8df..4289d0ee8 100644
--- a/src/java/org/apache/fop/pdf/PDFProfile.java
+++ b/src/java/org/apache/fop/pdf/PDFProfile.java
@@ -171,8 +171,7 @@ public class PDFProfile {
public void verifyTransparencyAllowed(String context) {
Object profile = isTransparencyAllowed();
if (profile != null) {
- throw new PDFConformanceException(profile + " does not allow the use of transparency. ("
- + profile + ")");
+ throw new TransparencyDisallowedException(profile, context);
}
}
diff --git a/src/java/org/apache/fop/pdf/TransparencyDisallowedException.java b/src/java/org/apache/fop/pdf/TransparencyDisallowedException.java
new file mode 100644
index 000000000..11d8baf54
--- /dev/null
+++ b/src/java/org/apache/fop/pdf/TransparencyDisallowedException.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.pdf;
+
+/**
+ * The PDF profile being used does not allow transparency.
+ */
+public class TransparencyDisallowedException extends PDFConformanceException {
+
+ private static final long serialVersionUID = -1653621832449817596L;
+
+ private final Object profile;
+
+ private final String context;
+
+ public TransparencyDisallowedException(Object profile, String context) {
+ super(profile + " does not allow the use of transparency."
+ + (context == null ? "" : " (" + context + ")"));
+ this.profile = profile;
+ this.context = context;
+ }
+
+ /**
+ * Returns the profile that is being used and disallows transparency.
+ *
+ * @see PDFAMode
+ * @see PDFXMode
+ */
+ public Object getProfile() {
+ return profile;
+ }
+
+ /**
+ * Returns context information to help spotting the problem.
+ */
+ public String getContext() {
+ return context;
+ }
+
+}
diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java
index ae282f149..a71fe9417 100644
--- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java
+++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerSVG.java
@@ -44,6 +44,7 @@ import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.events.EventBroadcaster;
import org.apache.fop.image.loader.batik.BatikImageFlavors;
import org.apache.fop.image.loader.batik.BatikUtil;
+import org.apache.fop.pdf.TransparencyDisallowedException;
import org.apache.fop.render.ImageHandler;
import org.apache.fop.render.ImageHandlerUtil;
import org.apache.fop.render.RenderingContext;
@@ -207,6 +208,10 @@ public class PDFImageHandlerSVG implements ImageHandler {
root.paint(graphics);
ctx.dispose();
generator.add(graphics.getString());
+ } catch (TransparencyDisallowedException e) {
+ SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+ context.getUserAgent().getEventBroadcaster());
+ eventProducer.bitmapWithTransparency(this, e.getProfile(), image.getInfo().getOriginalURI());
} catch (Exception e) {
SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
context.getUserAgent().getEventBroadcaster());
diff --git a/src/java/org/apache/fop/svg/SVGEventProducer.java b/src/java/org/apache/fop/svg/SVGEventProducer.java
index 6bf7ed100..fd529ef04 100644
--- a/src/java/org/apache/fop/svg/SVGEventProducer.java
+++ b/src/java/org/apache/fop/svg/SVGEventProducer.java
@@ -98,4 +98,13 @@ public interface SVGEventProducer extends EventProducer {
*/
void transparencyIgnored(Object source, Object pdfProfile, String uri);
+
+ /**
+ * SVG references a bitmap image that contains transparency while it is not allowed.
+ * @param source the event source
+ * @param pdfProfile the PDF profile that disallows transparency
+ * @param uri the image URI, if available
+ * @event.severity ERROR
+ */
+ void bitmapWithTransparency(Object source, Object pdfProfile, String uri);
}
diff --git a/src/java/org/apache/fop/svg/SVGEventProducer.xml b/src/java/org/apache/fop/svg/SVGEventProducer.xml
index f5e1d300a..e7d9b555d 100644
--- a/src/java/org/apache/fop/svg/SVGEventProducer.xml
+++ b/src/java/org/apache/fop/svg/SVGEventProducer.xml
@@ -23,4 +23,5 @@
<message key="svgNotBuilt">SVG graphic could not be built. Reason: {e}</message>
<message key="svgRenderingError">SVG graphic could not be rendered. Reason: {e}</message>
<message key="transparencyIgnored">Transparency in an SVG image will be ignored because {pdfProfile} does not allow it[ (see {uri})].</message>
+ <message key="bitmapWithTransparency">An SVG image is referencing a bitmap with transparency while {pdfProfile} does not allow it[ (see {uri})].</message>
</catalogue>