aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/afp
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/render/afp')
-rw-r--r--src/java/org/apache/fop/render/afp/AFPCustomizable.java17
-rw-r--r--src/java/org/apache/fop/render/afp/AFPDocumentHandler.java10
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandler.java11
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java19
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerRawJPEG.java205
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java21
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java37
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java44
-rw-r--r--src/java/org/apache/fop/render/afp/AFPSVGHandler.java17
-rw-r--r--src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java3
10 files changed, 347 insertions, 37 deletions
diff --git a/src/java/org/apache/fop/render/afp/AFPCustomizable.java b/src/java/org/apache/fop/render/afp/AFPCustomizable.java
index 04f3a6eeb..684ac057c 100644
--- a/src/java/org/apache/fop/render/afp/AFPCustomizable.java
+++ b/src/java/org/apache/fop/render/afp/AFPCustomizable.java
@@ -72,6 +72,16 @@ public interface AFPCustomizable {
void setDitheringQuality(float quality);
/**
+ * Sets the image encoding quality setting to use when encoding bitmap images.
+ * The default setting is 1.0 which means loss-less encoding. Settings of less than 1.0
+ * allow loss-less encoding schemes like JPEG. The value serves as quality setting for
+ * the encoders in that case.
+ * @param quality Defines the desired quality level.
+ * Valid values: a value between 0.0f (lowest) and 1.0f (best, loss-less)
+ */
+ void setBitmapEncodingQuality(float quality);
+
+ /**
* Sets the output/device resolution
*
* @param resolution
@@ -123,4 +133,11 @@ public interface AFPCustomizable {
*/
void setResourceLevelDefaults(AFPResourceLevelDefaults defaults);
+ /**
+ * Sets whether or not to JPEG images can be embedded in the AFP document.
+ *
+ * @param canEmbed whether or not to embed JPEG image
+ */
+ void canEmbedJpeg(boolean canEmbed);
+
}
diff --git a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
index 3c3fc123f..29f689555 100644
--- a/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
+++ b/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
@@ -429,6 +429,11 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
}
/** {@inheritDoc} */
+ public void setBitmapEncodingQuality(float quality) {
+ this.paintingState.setBitmapEncodingQuality(quality);
+ }
+
+ /** {@inheritDoc} */
public void setShadingMode(AFPShadingMode shadingMode) {
this.shadingMode = shadingMode;
}
@@ -483,4 +488,9 @@ public class AFPDocumentHandler extends AbstractBinaryWritingIFDocumentHandler
return pageSegmentMap.get(uri);
}
+ /** {@inheritDoc} */
+ public void canEmbedJpeg(boolean canEmbed) {
+ paintingState.setCanEmbedJpeg(canEmbed);
+ }
+
}
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandler.java b/src/java/org/apache/fop/render/afp/AFPImageHandler.java
index 244263213..118207d38 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandler.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandler.java
@@ -62,24 +62,17 @@ public abstract class AFPImageHandler implements ImageHandlerBase {
*/
public static AFPObjectAreaInfo createObjectAreaInfo(AFPPaintingState paintingState,
Rectangle targetRect) {
- AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo();
AFPUnitConverter unitConv = paintingState.getUnitConverter();
int[] coords = unitConv.mpts2units(new float[] {targetRect.x, targetRect.y});
- objectAreaInfo.setX(coords[X]);
- objectAreaInfo.setY(coords[Y]);
int width = Math.round(unitConv.mpt2units(targetRect.width));
- objectAreaInfo.setWidth(width);
int height = Math.round(unitConv.mpt2units(targetRect.height));
- objectAreaInfo.setHeight(height);
int resolution = paintingState.getResolution();
- objectAreaInfo.setHeightRes(resolution);
- objectAreaInfo.setWidthRes(resolution);
-
- objectAreaInfo.setRotation(paintingState.getRotation());
+ AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo(coords[X], coords[Y], width,
+ height, resolution, paintingState.getRotation());
return objectAreaInfo;
}
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java
index 83d41ba8c..85ef580f5 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java
@@ -19,6 +19,12 @@
package org.apache.fop.render.afp;
+import java.awt.Rectangle;
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
@@ -38,7 +44,11 @@ public class AFPImageHandlerRawCCITTFax extends AbstractAFPImageHandlerRawStream
ImageFlavor.RAW_CCITTFAX,
};
+ /** logging instance */
+ private final Log log = LogFactory.getLog(AFPImageHandlerRawJPEG.class);
+
/** {@inheritDoc} */
+ @Override
protected void setAdditionalParameters(AFPDataObjectInfo dataObjectInfo,
ImageRawStream image) {
AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)dataObjectInfo;
@@ -54,6 +64,15 @@ public class AFPImageHandlerRawCCITTFax extends AbstractAFPImageHandlerRawStream
}
/** {@inheritDoc} */
+ @Override
+ public void handleImage(RenderingContext context, Image image, Rectangle pos)
+ throws IOException {
+ log.debug("Embedding undecoded CCITT data as data container...");
+ super.handleImage(context, image, pos);
+ }
+
+ /** {@inheritDoc} */
+ @Override
protected AFPDataObjectInfo createDataObjectInfo() {
return new AFPImageObjectInfo();
}
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawJPEG.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawJPEG.java
new file mode 100644
index 000000000..e318c49fb
--- /dev/null
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawJPEG.java
@@ -0,0 +1,205 @@
+/*
+ * 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.render.afp;
+
+import java.awt.Rectangle;
+import java.awt.color.ColorSpace;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.xmlgraphics.image.loader.Image;
+import org.apache.xmlgraphics.image.loader.ImageFlavor;
+import org.apache.xmlgraphics.image.loader.ImageSize;
+import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG;
+import org.apache.xmlgraphics.image.loader.impl.JPEGConstants;
+import org.apache.xmlgraphics.util.MimeConstants;
+
+import org.apache.fop.afp.AFPDataObjectInfo;
+import org.apache.fop.afp.AFPImageObjectInfo;
+import org.apache.fop.afp.AFPObjectAreaInfo;
+import org.apache.fop.afp.AFPPaintingState;
+import org.apache.fop.afp.AFPResourceInfo;
+import org.apache.fop.afp.AFPResourceManager;
+import org.apache.fop.afp.ioca.ImageContent;
+import org.apache.fop.afp.modca.ResourceObject;
+import org.apache.fop.render.ImageHandler;
+import org.apache.fop.render.RenderingContext;
+
+/**
+ * {@link ImageHandler} implementation which handles ImageRawJPEG instances. JPEG data is
+ * embedded directly (not decoded) into IOCA images (FS11 or FS45).
+ */
+public class AFPImageHandlerRawJPEG extends AFPImageHandler implements ImageHandler {
+
+ /** logging instance */
+ private final Log log = LogFactory.getLog(AFPImageHandlerRawJPEG.class);
+
+ private void setDefaultResourceLevel(AFPImageObjectInfo imageObjectInfo,
+ AFPResourceManager resourceManager) {
+ AFPResourceInfo resourceInfo = imageObjectInfo.getResourceInfo();
+ if (!resourceInfo.levelChanged()) {
+ resourceInfo.setLevel(resourceManager.getResourceLevelDefaults()
+ .getDefaultResourceLevel(ResourceObject.TYPE_IMAGE));
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected AFPDataObjectInfo createDataObjectInfo() {
+ return new AFPImageObjectInfo();
+ }
+
+ /** {@inheritDoc} */
+ public int getPriority() {
+ return 150;
+ }
+
+ /** {@inheritDoc} */
+ public Class<?> getSupportedImageClass() {
+ return ImageRawJPEG.class;
+ }
+
+ /** {@inheritDoc} */
+ public ImageFlavor[] getSupportedImageFlavors() {
+ return new ImageFlavor[] {ImageFlavor.RAW_JPEG};
+ }
+
+ /** {@inheritDoc} */
+ public void handleImage(RenderingContext context, Image image, Rectangle pos)
+ throws IOException {
+ AFPRenderingContext afpContext = (AFPRenderingContext)context;
+
+ AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)createDataObjectInfo();
+ AFPPaintingState paintingState = afpContext.getPaintingState();
+
+ // set resource information
+ setResourceInformation(imageObjectInfo,
+ image.getInfo().getOriginalURI(),
+ afpContext.getForeignAttributes());
+ setDefaultResourceLevel(imageObjectInfo, afpContext.getResourceManager());
+
+ // Positioning
+ imageObjectInfo.setObjectAreaInfo(createObjectAreaInfo(paintingState, pos));
+ updateIntrinsicSize(imageObjectInfo, paintingState, image.getSize());
+
+ // Image content
+ ImageRawJPEG jpeg = (ImageRawJPEG)image;
+ imageObjectInfo.setCompression(ImageContent.COMPID_JPEG);
+ ColorSpace cs = jpeg.getColorSpace();
+ switch (cs.getType()) {
+ case ColorSpace.TYPE_GRAY:
+ imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS11);
+ imageObjectInfo.setColor(false);
+ imageObjectInfo.setBitsPerPixel(8);
+ break;
+ case ColorSpace.TYPE_RGB:
+ imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS11);
+ imageObjectInfo.setColor(true);
+ imageObjectInfo.setBitsPerPixel(24);
+ break;
+ case ColorSpace.TYPE_CMYK:
+ imageObjectInfo.setMimeType(MimeConstants.MIME_AFP_IOCA_FS45);
+ imageObjectInfo.setColor(true);
+ imageObjectInfo.setBitsPerPixel(32);
+ break;
+ default:
+ throw new IllegalStateException(
+ "Color space of JPEG image not supported: " + cs);
+ }
+
+ boolean included = afpContext.getResourceManager().tryIncludeObject(imageObjectInfo);
+ if (!included) {
+ log.debug("Embedding undecoded JPEG as IOCA image...");
+ InputStream inputStream = jpeg.createInputStream();
+ try {
+ imageObjectInfo.setData(IOUtils.toByteArray(inputStream));
+ } finally {
+ IOUtils.closeQuietly(inputStream);
+ }
+
+ // Create image
+ afpContext.getResourceManager().createObject(imageObjectInfo);
+ }
+ }
+
+ private void updateIntrinsicSize(AFPImageObjectInfo imageObjectInfo,
+ AFPPaintingState paintingState, ImageSize targetSize) {
+ //Update image object info
+ imageObjectInfo.setDataHeightRes((int)Math.round(
+ targetSize.getDpiHorizontal() * 10));
+ imageObjectInfo.setDataWidthRes((int)Math.round(
+ targetSize.getDpiVertical() * 10));
+ imageObjectInfo.setDataHeight(targetSize.getHeightPx());
+ imageObjectInfo.setDataWidth(targetSize.getWidthPx());
+
+ // set object area info
+ int resolution = paintingState.getResolution();
+ AFPObjectAreaInfo objectAreaInfo = imageObjectInfo.getObjectAreaInfo();
+ objectAreaInfo.setResolution(resolution);
+ }
+
+ /** {@inheritDoc} */
+ public boolean isCompatible(RenderingContext targetContext, Image image) {
+ if (!(targetContext instanceof AFPRenderingContext)) {
+ return false; //AFP-specific image handler
+ }
+ AFPRenderingContext context = (AFPRenderingContext)targetContext;
+ AFPPaintingState paintingState = context.getPaintingState();
+ if (!paintingState.canEmbedJpeg()) {
+ return false;
+ }
+ if (paintingState.getBitsPerPixel() < 8) {
+ return false; //This would stand in the way of dithering and cause exceptions
+ }
+ if (image == null) {
+ return true; //Don't know the image format, yet
+ }
+ if (image instanceof ImageRawJPEG) {
+ ImageRawJPEG jpeg = (ImageRawJPEG)image;
+ ColorSpace cs = jpeg.getColorSpace();
+ switch (cs.getType()) {
+ case ColorSpace.TYPE_GRAY:
+ case ColorSpace.TYPE_RGB:
+ //ok
+ break;
+ case ColorSpace.TYPE_CMYK:
+ if (!paintingState.isCMYKImagesSupported()) {
+ return false; //CMYK is disabled
+ //Note: you may need to disable this image handler through configuration
+ //if you want to paint a CMYK JPEG on 24bit and less configurations.
+ }
+ break;
+ default:
+ return false; //not supported
+ }
+
+ if (jpeg.getSOFType() != JPEGConstants.SOF0) {
+ return false; //We'll let only baseline DCT through.
+ }
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java
index fcfc9c64c..f32f7305b 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java
@@ -19,6 +19,12 @@
package org.apache.fop.render.afp;
+import java.awt.Rectangle;
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.impl.ImageRawEPS;
@@ -40,6 +46,9 @@ public class AFPImageHandlerRawStream extends AbstractAFPImageHandlerRawStream {
ImageFlavor.RAW_EPS,
};
+ /** logging instance */
+ private final Log log = LogFactory.getLog(AFPImageHandlerRawJPEG.class);
+
/** {@inheritDoc} */
public int getPriority() {
return 200;
@@ -56,11 +65,23 @@ public class AFPImageHandlerRawStream extends AbstractAFPImageHandlerRawStream {
}
/** {@inheritDoc} */
+ @Override
protected AFPDataObjectInfo createDataObjectInfo() {
return new AFPDataObjectInfo();
}
/** {@inheritDoc} */
+ @Override
+ public void handleImage(RenderingContext context, Image image, Rectangle pos)
+ throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Embedding undecoded image data (" + image.getInfo().getMimeType()
+ + ") as data container...");
+ }
+ super.handleImage(context, image, pos);
+ }
+
+ /** {@inheritDoc} */
public boolean isCompatible(RenderingContext targetContext, Image image) {
if (targetContext instanceof AFPRenderingContext) {
AFPRenderingContext afpContext = (AFPRenderingContext)targetContext;
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
index c516da702..0b4b6ea98 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
@@ -28,10 +28,10 @@ import java.awt.image.MultiPixelPackedSampleModel;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.awt.image.SampleModel;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -40,6 +40,9 @@ import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageSize;
import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
+import org.apache.xmlgraphics.image.writer.ImageWriter;
+import org.apache.xmlgraphics.image.writer.ImageWriterParams;
+import org.apache.xmlgraphics.image.writer.ImageWriterRegistry;
import org.apache.xmlgraphics.ps.ImageEncodingHelper;
import org.apache.xmlgraphics.util.MimeConstants;
import org.apache.xmlgraphics.util.UnitConv;
@@ -50,6 +53,7 @@ import org.apache.fop.afp.AFPObjectAreaInfo;
import org.apache.fop.afp.AFPPaintingState;
import org.apache.fop.afp.AFPResourceInfo;
import org.apache.fop.afp.AFPResourceManager;
+import org.apache.fop.afp.ioca.ImageContent;
import org.apache.fop.afp.modca.ResourceObject;
import org.apache.fop.render.ImageHandler;
import org.apache.fop.render.RenderingContext;
@@ -284,7 +288,26 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler implements Ima
functionSet = 45; //IOCA FS45 required for CMYK
}
- helper.encode(baos);
+ //Lossy or loss-less?
+ if (!paintingState.canEmbedJpeg()
+ && paintingState.getBitmapEncodingQuality() < 1.0f) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Encoding using baseline DCT (JPEG, q="
+ + paintingState.getBitmapEncodingQuality() + ")...");
+ }
+ encodeToBaselineDCT(renderedImage,
+ paintingState.getBitmapEncodingQuality(),
+ paintingState.getResolution(),
+ baos);
+ imageObjectInfo.setCompression(ImageContent.COMPID_JPEG);
+ } catch (IOException ioe) {
+ //Some JPEG codecs cannot encode CMYK
+ helper.encode(baos);
+ }
+ } else {
+ helper.encode(baos);
+ }
imageData = baos.toByteArray();
}
}
@@ -393,6 +416,14 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler implements Ima
return false;
}
- }
+ private void encodeToBaselineDCT(RenderedImage image,
+ float quality, int resolution, OutputStream out) throws IOException {
+ ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor("image/jpeg");
+ ImageWriterParams params = new ImageWriterParams();
+ params.setJPEGQuality(quality, true);
+ params.setResolution(resolution);
+ writer.writeImage(image, out, params);
+ }
+ }
}
diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
index fc8d10508..25d684e42 100644
--- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
@@ -23,10 +23,12 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.util.ArrayList;
import java.util.List;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+
import org.apache.fop.afp.AFPResourceLevel;
import org.apache.fop.afp.AFPResourceLevelDefaults;
import org.apache.fop.afp.fonts.AFPFont;
@@ -80,10 +82,10 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
log.error("Mandatory font configuration element '<font-triplet...' is missing");
return null;
}
- for (int j = 0; j < triple.length; j++) {
- int weight = FontUtil.parseCSS2FontWeight(triple[j].getAttribute("weight"));
- FontTriplet triplet = new FontTriplet(triple[j].getAttribute("name"),
- triple[j].getAttribute("style"),
+ for (Configuration config : triple) {
+ int weight = FontUtil.parseCSS2FontWeight(config.getAttribute("weight"));
+ FontTriplet triplet = new FontTriplet(config.getAttribute("name"),
+ config.getAttribute("style"),
weight);
tripletList.add(triplet);
}
@@ -183,10 +185,10 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
if (base14 != null) {
try {
- Class<?> clazz = Class.forName(
- "org.apache.fop.fonts.base14." + base14);
+ Class<? extends Typeface> clazz = Class.forName(
+ "org.apache.fop.fonts.base14." + base14).asSubclass(Typeface.class);
try {
- Typeface tf = (Typeface)clazz.newInstance();
+ Typeface tf = clazz.newInstance();
font.addCharacterSet(sizeMpt,
CharacterSetBuilder.getInstance()
.build(characterset, codepage, encoding, tf));
@@ -222,10 +224,10 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
String base14 = afpFontCfg.getAttribute("base14-font", null);
if (base14 != null) {
try {
- Class<?> clazz = Class.forName("org.apache.fop.fonts.base14."
- + base14);
+ Class<? extends Typeface> clazz = Class.forName("org.apache.fop.fonts.base14."
+ + base14).asSubclass(Typeface.class);
try {
- Typeface tf = (Typeface)clazz.newInstance();
+ Typeface tf = clazz.newInstance();
characterSet = CharacterSetBuilder.getInstance()
.build(characterset, codepage, encoding, tf);
} catch (Exception ie) {
@@ -319,7 +321,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
if (log.isDebugEnabled()) {
log.debug("Adding font " + afi.getAFPFont().getFontName());
}
- List/*<FontTriplet>*/ fontTriplets = afi.getFontTriplets();
+ List<FontTriplet> fontTriplets = afi.getFontTriplets();
for (int j = 0; j < fontTriplets.size(); ++j) {
FontTriplet triplet = (FontTriplet) fontTriplets.get(j);
if (log.isDebugEnabled()) {
@@ -396,6 +398,24 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
boolean nativeImageSupport = imagesCfg.getAttributeAsBoolean("native", false);
customizable.setNativeImagesSupported(nativeImageSupport);
+ Configuration jpegConfig = imagesCfg.getChild("jpeg");
+ boolean allowEmbedding = false;
+ float ieq = 1.0f;
+ if (jpegConfig != null) {
+ allowEmbedding = jpegConfig.getAttributeAsBoolean("allow-embedding", false);
+ String bitmapEncodingQuality = jpegConfig.getAttribute("bitmap-encoding-quality", null);
+
+ if (bitmapEncodingQuality != null) {
+ try {
+ ieq = Float.parseFloat(bitmapEncodingQuality);
+ } catch (NumberFormatException nfe) {
+ //ignore and leave the default above
+ }
+ }
+ }
+ customizable.canEmbedJpeg(allowEmbedding);
+ customizable.setBitmapEncodingQuality(ieq);
+
// shading (filled rectangles)
Configuration shadingCfg = cfg.getChild("shading");
AFPShadingMode shadingMode = AFPShadingMode.valueOf(
@@ -480,7 +500,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator
public void setupFontInfo(IFDocumentHandler documentHandler, FontInfo fontInfo)
throws FOPException {
FontManager fontManager = userAgent.getFactory().getFontManager();
- List<FontCollection> fontCollections = new java.util.ArrayList<FontCollection>();
+ List<AFPFontCollection> fontCollections = new ArrayList<AFPFontCollection>();
Configuration cfg = super.getRendererConfig(documentHandler.getMimeType());
if (cfg != null) {
diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
index 7ade64006..48b82bbf3 100644
--- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
+++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
@@ -154,23 +154,18 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler {
private AFPObjectAreaInfo createObjectAreaInfo(AFPPaintingState paintingState,
int x, int y, int width, int height, int resolution) {
// set the data object parameters
- AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo();
AffineTransform at = paintingState.getData().getTransform();
at.translate(x, y);
- objectAreaInfo.setX((int)Math.round(at.getTranslateX()));
- objectAreaInfo.setY((int)Math.round(at.getTranslateY()));
-
- objectAreaInfo.setWidthRes(resolution);
- objectAreaInfo.setHeightRes(resolution);
-
AFPUnitConverter unitConv = paintingState.getUnitConverter();
- objectAreaInfo.setWidth(Math.round(unitConv.mpt2units(width)));
- objectAreaInfo.setHeight(Math.round(unitConv.mpt2units(height)));
int rotation = paintingState.getRotation();
- objectAreaInfo.setRotation(rotation);
-
+ int objX = (int) Math.round(at.getTranslateX());
+ int objY = (int) Math.round(at.getTranslateY());
+ int objWidth = Math.round(unitConv.mpt2units(width));
+ int objHeight = Math.round(unitConv.mpt2units(height));
+ AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo(objX, objY, objWidth, objHeight,
+ resolution, rotation);
return objectAreaInfo;
}
diff --git a/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java b/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java
index 5374c7051..b36646117 100644
--- a/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java
+++ b/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java
@@ -103,8 +103,7 @@ public abstract class AbstractAFPImageHandlerRawStream extends AFPImageHandler
AFPPaintingState paintingState = afpContext.getPaintingState();
int resolution = paintingState.getResolution();
AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();
- objectAreaInfo.setWidthRes(resolution);
- objectAreaInfo.setHeightRes(resolution);
+ objectAreaInfo.setResolution(resolution);
// Image content
ImageRawStream imageStream = (ImageRawStream)image;