aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/java2d/Java2DRenderer.java6
-rw-r--r--fop-core/src/test/java/org/apache/fop/render/java2d/Java2DRendererTestCase.java60
2 files changed, 64 insertions, 2 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/render/java2d/Java2DRenderer.java b/fop-core/src/main/java/org/apache/fop/render/java2d/Java2DRenderer.java
index 825dc3754..ca74068d8 100644
--- a/fop-core/src/main/java/org/apache/fop/render/java2d/Java2DRenderer.java
+++ b/fop-core/src/main/java/org/apache/fop/render/java2d/Java2DRenderer.java
@@ -1004,12 +1004,14 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
// reset the current Positions
currentBPPosition = 0;
currentIPPosition = 0;
-
- renderPageAreas(viewport.getPage());
+ super.renderPage(viewport);
return PAGE_EXISTS;
} catch (FOPException e) {
log.error(e);
return NO_SUCH_PAGE;
+ } catch (IOException e) {
+ log.error(e);
+ return NO_SUCH_PAGE;
} finally {
state = null;
}
diff --git a/fop-core/src/test/java/org/apache/fop/render/java2d/Java2DRendererTestCase.java b/fop-core/src/test/java/org/apache/fop/render/java2d/Java2DRendererTestCase.java
new file mode 100644
index 000000000..8d22020cc
--- /dev/null
+++ b/fop-core/src/test/java/org/apache/fop/render/java2d/Java2DRendererTestCase.java
@@ -0,0 +1,60 @@
+/*
+ * 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: Java2DRenderer.java 1827168 2018-03-19 08:49:57Z ssteiner $ */
+package org.apache.fop.render.java2d;
+
+import java.awt.Rectangle;
+import java.awt.image.BufferedImage;
+import java.io.File;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.FopFactory;
+import org.apache.fop.area.BodyRegion;
+import org.apache.fop.area.CTM;
+import org.apache.fop.area.Page;
+import org.apache.fop.area.PageViewport;
+import org.apache.fop.area.RegionViewport;
+import org.apache.fop.fo.Constants;
+
+public class Java2DRendererTestCase {
+ @Test
+ public void testPrint() throws Exception {
+ FOUserAgent userAgent = FopFactory.newInstance(new File(".").toURI()).newFOUserAgent();
+ Java2DRenderer java2DRenderer = new Java2DRenderer(userAgent) {
+ public String getMimeType() {
+ return null;
+ }
+ };
+ PageViewport pageViewport = new PageViewport(new Rectangle(), 0, null, null, true);
+ pageViewport.setPageIndex(0);
+ Page page = new Page();
+ RegionViewport regionViewport = new RegionViewport(new Rectangle());
+ BodyRegion bodyRegion = new BodyRegion(Constants.FO_REGION_BODY, null, regionViewport, 0, 0);
+ bodyRegion.setCTM(new CTM());
+ bodyRegion.getMainReference().createSpan(true);
+ regionViewport.setRegionReference(bodyRegion);
+ page.setRegionViewport(Constants.FO_REGION_BODY, regionViewport);
+ pageViewport.setPage(page);
+ java2DRenderer.renderPage(pageViewport);
+ BufferedImage image = new BufferedImage(100, 50, BufferedImage.TYPE_INT_ARGB);
+ Assert.assertEquals(java2DRenderer.print(image.createGraphics(), null, 0), 0);
+ }
+}