diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2008-07-25 10:55:49 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2008-07-25 10:55:49 +0000 |
commit | d058e870151a49af34ec1e7204edd0ffc64aaefc (patch) | |
tree | 14c346af79c0d2207f98b17e1e9f0212c8c32f44 /src/java/org/apache/fop/render/pdf | |
parent | cc5d6604bde87fca098633ceccd66fc92808bddc (diff) | |
download | xmlgraphics-fop-d058e870151a49af34ec1e7204edd0ffc64aaefc.tar.gz xmlgraphics-fop-d058e870151a49af34ec1e7204edd0ffc64aaefc.zip |
Merged revisions 679052-679352 via svnmerge from
https://svn.eu.apache.org/repos/asf/xmlgraphics/fop/trunk
........
r679060 | acumiskey | 2008-07-23 11:39:11 +0100 (Wed, 23 Jul 2008) | 2 lines
My bad.. copy paste error I introduced which broke forrest.
........
r679164 | jeremias | 2008-07-23 20:33:24 +0100 (Wed, 23 Jul 2008) | 1 line
Only update the generated files if any source file is newer than the generated ones.
........
r679326 | vhennebert | 2008-07-24 10:35:34 +0100 (Thu, 24 Jul 2008) | 2 lines
Fed up with all those trailing whitespaces. Let's remove them all (once... and for all?)
........
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@679758 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/pdf')
19 files changed, 230 insertions, 230 deletions
diff --git a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java index caf8928ac..cbaac4e55 100644 --- a/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java +++ b/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java @@ -5,9 +5,9 @@ * 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. @@ -48,7 +48,7 @@ public abstract class AbstractImageAdapter implements PDFImage { private String key; /** the image */ protected Image image; - + private PDFICCStream pdfICCStream = null; /** @@ -77,7 +77,7 @@ public abstract class AbstractImageAdapter implements PDFImage { protected ColorSpace getImageColorSpace() { return image.getColorSpace(); } - + /** {@inheritDoc} */ public void setup(PDFDocument doc) { @@ -88,7 +88,7 @@ public abstract class AbstractImageAdapter implements PDFImage { } if (doc.getProfile().getPDFAMode().isPDFA1LevelB()) { if (pdfCS != null - && pdfCS.getColorSpace() != PDFDeviceColorSpace.DEVICE_RGB + && pdfCS.getColorSpace() != PDFDeviceColorSpace.DEVICE_RGB && pdfCS.getColorSpace() != PDFDeviceColorSpace.DEVICE_GRAY && prof == null) { //See PDF/A-1, ISO 19005:1:2005(E), 6.2.3.3 @@ -107,7 +107,7 @@ public abstract class AbstractImageAdapter implements PDFImage { protected ICC_Profile getEffectiveICCProfile() { return image.getICCProfile(); } - + private static PDFICCStream setupColorProfile(PDFDocument doc, ICC_Profile prof, PDFDeviceColorSpace pdfCS) { boolean defaultsRGB = ColorProfileUtil.isDefaultsRGB(prof); @@ -154,32 +154,32 @@ public abstract class AbstractImageAdapter implements PDFImage { public boolean isTransparent() { return false; } - + /** {@inheritDoc} */ public PDFColor getTransparentColor() { return null; } - + /** {@inheritDoc} */ public String getMask() { return null; } - + /** {@inheritDoc} */ public String getSoftMask() { return null; } - + /** {@inheritDoc} */ public PDFReference getSoftMaskReference() { return null; } - + /** {@inheritDoc} */ public boolean isInverted() { return false; } - + /** {@inheritDoc} */ public boolean isPS() { return false; @@ -194,7 +194,7 @@ public abstract class AbstractImageAdapter implements PDFImage { public void populateXObjectDictionary(PDFDictionary dict) { //nop } - + /** * Converts a ColorSpace object to a PDFColorSpace object. * @param cs ColorSpace instance diff --git a/src/java/org/apache/fop/render/pdf/CTMHelper.java b/src/java/org/apache/fop/render/pdf/CTMHelper.java index e2d29f768..ced025ea3 100644 --- a/src/java/org/apache/fop/render/pdf/CTMHelper.java +++ b/src/java/org/apache/fop/render/pdf/CTMHelper.java @@ -5,9 +5,9 @@ * 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. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.render.pdf; import java.awt.geom.AffineTransform; @@ -37,7 +37,7 @@ public final class CTMHelper { * <p>Converts the sourceMatrix to a string for use in the PDFRenderer cm operations.</p> * <p>For example: * <pre> - * org.apache.fop.area.CTM ctm = + * org.apache.fop.area.CTM ctm = * new org.apache.fop.area.CTM(1.0, 0.0, 0.0, 1.0, 1000.0, 1000.0); * String pdfMatrix = org.apache.fop.render.pdf.CTMHelper.toPDFString(ctm); * </pre> @@ -58,7 +58,7 @@ public final class CTMHelper { } /** - * <p>Converts the AffineTransform instance to a string for use in the PDFRenderer + * <p>Converts the AffineTransform instance to a string for use in the PDFRenderer * cm operations.</p> * * @param transform The matrix to convert. @@ -83,21 +83,21 @@ public final class CTMHelper { } private static String constructPDFArray(double[] matrix) { - return PDFNumber.doubleOut(matrix[0], 8) + " " - + PDFNumber.doubleOut(matrix[1], 8) + " " - + PDFNumber.doubleOut(matrix[2], 8) + " " - + PDFNumber.doubleOut(matrix[3], 8) + " " - + PDFNumber.doubleOut(matrix[4], 8) + " " + return PDFNumber.doubleOut(matrix[0], 8) + " " + + PDFNumber.doubleOut(matrix[1], 8) + " " + + PDFNumber.doubleOut(matrix[2], 8) + " " + + PDFNumber.doubleOut(matrix[3], 8) + " " + + PDFNumber.doubleOut(matrix[4], 8) + " " + PDFNumber.doubleOut(matrix[5], 8); } - + /** * <p>Creates a new CTM based in the sourceMatrix.</p> * <p>For example: * <pre> - * org.apache.fop.area.CTM inCTM = + * org.apache.fop.area.CTM inCTM = * new org.apache.fop.area.CTM(1.0, 0.0, 0.0, 1.0, 1000.0, 1000.0); - * org.apache.fop.area.CTM outCTM = + * org.apache.fop.area.CTM outCTM = * org.apache.fop.render.pdf.CTMHelper.toPDFCTM(ctm); * </pre> * will return a new CTM where a == 1.0, b == 0.0, c == 0.0, d == 1.0, e == 1.0 and f == 1.0. @@ -121,7 +121,7 @@ public final class CTMHelper { * <p>Creates an array of six doubles from the source CTM.</p> * <p>For example: * <pre> - * org.apache.fop.area.CTM inCTM = + * org.apache.fop.area.CTM inCTM = * new org.apache.fop.area.CTM(1.0, 0.0, 0.0, 1.0, 1000.0, 1000.0); * double matrix[] = org.apache.fop.render.pdf.CTMHelper.toPDFArray(ctm); * </pre> diff --git a/src/java/org/apache/fop/render/pdf/ImageRawCCITTFaxAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRawCCITTFaxAdapter.java index b80e2c03e..f158f6a14 100644 --- a/src/java/org/apache/fop/render/pdf/ImageRawCCITTFaxAdapter.java +++ b/src/java/org/apache/fop/render/pdf/ImageRawCCITTFaxAdapter.java @@ -5,9 +5,9 @@ * 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. @@ -55,7 +55,7 @@ public class ImageRawCCITTFaxAdapter extends AbstractImageAdapter { public ImageRawCCITTFax getImage() { return ((ImageRawCCITTFax)this.image); } - + /** {@inheritDoc} */ public void setup(PDFDocument doc) { pdfFilter = new CCFFilter(); @@ -95,7 +95,7 @@ public class ImageRawCCITTFaxAdapter extends AbstractImageAdapter { public PDFFilter getPDFFilter() { return pdfFilter; } - + /** {@inheritDoc} */ public void outputContents(OutputStream out) throws IOException { getImage().writeTo(out); diff --git a/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java index 1e505daed..a60c9e92c 100644 --- a/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java +++ b/src/java/org/apache/fop/render/pdf/ImageRawJPEGAdapter.java @@ -5,9 +5,9 @@ * 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. @@ -64,7 +64,7 @@ public class ImageRawJPEGAdapter extends AbstractImageAdapter { public ImageRawJPEG getImage() { return ((ImageRawJPEG)this.image); } - + /** {@inheritDoc} */ public void setup(PDFDocument doc) { pdfFilter = new DCTFilter(); @@ -88,12 +88,12 @@ public class ImageRawJPEGAdapter extends AbstractImageAdapter { public boolean isInverted() { return getImage().isInverted(); } - + /** {@inheritDoc} */ public PDFFilter getPDFFilter() { return pdfFilter; } - + /** {@inheritDoc} */ public void outputContents(OutputStream out) throws IOException { InputStream in = getImage().createInputStream(); @@ -101,7 +101,7 @@ public class ImageRawJPEGAdapter extends AbstractImageAdapter { try { JPEGFile jpeg = new JPEGFile(in); DataInput din = jpeg.getDataInput(); - + //Copy the whole JPEG file except: // - the ICC profile //TODO Thumbnails could safely be skipped, too. @@ -149,7 +149,7 @@ public class ImageRawJPEGAdapter extends AbstractImageAdapter { default: out.write(0xFF); out.write(segID); - + reclen = jpeg.readSegmentLength(); //write short out.write((reclen >>> 8) & 0xFF); diff --git a/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java b/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java index 62e83da81..e8988244f 100644 --- a/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java +++ b/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java @@ -5,9 +5,9 @@ * 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. @@ -52,7 +52,7 @@ public class ImageRenderedAdapter extends AbstractImageAdapter { private static Log log = LogFactory.getLog(ImageRenderedAdapter.class); private ImageEncodingHelper encodingHelper; - + private PDFFilter pdfFilter = null; private String maskRef; private PDFReference softMask; @@ -74,11 +74,11 @@ public class ImageRenderedAdapter extends AbstractImageAdapter { public ImageRendered getImage() { return ((ImageRendered)this.image); } - + private ColorModel getEffectiveColorModel() { return encodingHelper.getEncodedColorModel(); } - + /** {@inheritDoc} */ protected ColorSpace getImageColorSpace() { return getEffectiveColorModel().getColorSpace(); @@ -90,14 +90,14 @@ public class ImageRenderedAdapter extends AbstractImageAdapter { ColorModel cm = getEffectiveColorModel(); super.setup(doc); - + //Handle transparency mask if applicable - ColorModel orgcm = ri.getColorModel(); + ColorModel orgcm = ri.getColorModel(); if (orgcm.hasAlpha() && orgcm.getTransparency() == ColorModel.TRANSLUCENT) { doc.getProfile().verifyTransparencyAllowed(image.getInfo().getOriginalURI()); //TODO Implement code to combine image with background color if transparency is not //allowed (need BufferedImage support for that) - + AlphaRasterImage alphaImage = new AlphaRasterImage("Mask:" + getKey(), ri); this.softMask = doc.addImage(null, alphaImage).makeReference(); } @@ -130,7 +130,7 @@ public class ImageRenderedAdapter extends AbstractImageAdapter { } return (getImage().getTransparentColor() != null); } - + private static Integer getIndexOfFirstTransparentColorInPalette(RenderedImage image) { ColorModel cm = image.getColorModel(); if (cm instanceof IndexColorModel) { @@ -180,19 +180,19 @@ public class ImageRenderedAdapter extends AbstractImageAdapter { public PDFReference getSoftMaskReference() { return softMask; } - + /** {@inheritDoc} */ public PDFFilter getPDFFilter() { return pdfFilter; } - + /** {@inheritDoc} */ public void outputContents(OutputStream out) throws IOException { encodingHelper.encode(out); } private static final int MAX_HIVAL = 255; - + /** {@inheritDoc} */ public void populateXObjectDictionary(PDFDictionary dict) { ColorModel cm = getEffectiveColorModel(); @@ -200,11 +200,11 @@ public class ImageRenderedAdapter extends AbstractImageAdapter { IndexColorModel icm = (IndexColorModel)cm; PDFArray indexed = new PDFArray(dict); indexed.add(new PDFName("Indexed")); - + if (icm.getColorSpace().getType() != ColorSpace.TYPE_RGB) { log.warn("Indexed color space is not using RGB as base color space." + " The image may not be handled correctly." - + " Base color space: " + icm.getColorSpace() + + " Base color space: " + icm.getColorSpace() + " Image: " + image.getInfo()); } indexed.add(new PDFName(toPDFColorSpace(icm.getColorSpace()).getName())); @@ -229,7 +229,7 @@ public class ImageRenderedAdapter extends AbstractImageAdapter { dict.put("ColorSpace", indexed); dict.put("BitsPerComponent", icm.getPixelSize()); - + Integer index = getIndexOfFirstTransparentColorInPalette(getImage().getRenderedImage()); if (index != null) { PDFArray mask = new PDFArray(dict); @@ -239,7 +239,7 @@ public class ImageRenderedAdapter extends AbstractImageAdapter { } } } - + /** {@inheritDoc} */ public String getFilterHint() { return PDFFilterList.IMAGE_FILTER; diff --git a/src/java/org/apache/fop/render/pdf/PDFEventProducer.java b/src/java/org/apache/fop/render/pdf/PDFEventProducer.java index f8b1bbb33..2c3be9736 100644 --- a/src/java/org/apache/fop/render/pdf/PDFEventProducer.java +++ b/src/java/org/apache/fop/render/pdf/PDFEventProducer.java @@ -31,7 +31,7 @@ public interface PDFEventProducer extends EventProducer { /** Provider class for the event producer. */ class Provider { - + /** * Returns an event producer. * @param broadcaster the event broadcaster to use @@ -50,9 +50,9 @@ public interface PDFEventProducer extends EventProducer { public EventModel createEventModel() { return loadModel(getClass(), "event-model.xml"); } - + } - + /** * Some link targets haven't been fully resolved. * @param source the event source @@ -60,5 +60,5 @@ public interface PDFEventProducer extends EventProducer { * @event.severity WARN */ void nonFullyResolvedLinkTargets(Object source, int count); - + } diff --git a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java index c47b944d0..b61ebc346 100644 --- a/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java @@ -5,9 +5,9 @@ * 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. @@ -16,7 +16,7 @@ */ /* $Id$ */ - + package org.apache.fop.render.pdf; import java.awt.Color; @@ -49,18 +49,18 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter { public PDFGraphics2DAdapter(PDFRenderer renderer) { this.renderer = renderer; } - + /** {@inheritDoc} */ public void paintImage(Graphics2DImagePainter painter, RendererContext context, int x, int y, int width, int height) throws IOException { - + PDFSVGHandler.PDFInfo pdfInfo = PDFSVGHandler.getPDFInfo(context); float fwidth = width / 1000f; float fheight = height / 1000f; float fx = x / 1000f; float fy = y / 1000f; - + // get the 'width' and 'height' attributes of the SVG document Dimension dim = painter.getImageSize(); float imw = (float)dim.getWidth() / 1000f; @@ -72,7 +72,7 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter { renderer.saveGraphicsState(); renderer.setColor(Color.black, false, null); renderer.setColor(Color.black, true, null); - + //TODO Clip to the image area. // transform so that the coordinates (0,0) is from the top left @@ -86,13 +86,13 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter { if (pdfInfo.pdfContext == null) { pdfInfo.pdfContext = pdfInfo.pdfPage; } - PDFGraphics2D graphics = new PDFGraphics2D(textAsShapes, + PDFGraphics2D graphics = new PDFGraphics2D(textAsShapes, pdfInfo.fi, pdfInfo.pdfDoc, pdfInfo.pdfContext, pdfInfo.pdfPage.referencePDF(), pdfInfo.currentFontName, pdfInfo.currentFontSize); graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); - + AffineTransform transform = new AffineTransform(); transform.translate(fx, fy); pdfInfo.pdfState.concatenate(transform); @@ -105,7 +105,7 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter { RendererContextWrapper ctx = RendererContext.wrapRendererContext(context); BufferedImage bi = paintToBufferedImage(painter, ctx, resolution, false, false); - float scale = PDFRenderer.NORMAL_PDF_RESOLUTION + float scale = PDFRenderer.NORMAL_PDF_RESOLUTION / context.getUserAgent().getTargetResolution(); graphics.drawImage(bi, new AffineTransform(scale, 0, 0, scale, 0, 0), null); } else { @@ -121,9 +121,9 @@ public class PDFGraphics2DAdapter extends AbstractGraphics2DAdapter { /** {@inheritDoc} */ protected void setRenderingHintsForBufferedImage(Graphics2D g2d) { super.setRenderingHintsForBufferedImage(g2d); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); } diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandler.java b/src/java/org/apache/fop/render/pdf/PDFImageHandler.java index d62dcbc5b..f93ee5a97 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandler.java @@ -5,9 +5,9 @@ * 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. @@ -41,19 +41,19 @@ public interface PDFImageHandler { * @return a positive integer (>0) indicating the priority */ int getPriority(); - + /** * Returns the {@link ImageFlavor}s supported by this instance * @return the supported image flavors */ ImageFlavor[] getSupportedImageFlavors(); - + /** * Returns the {@link Image} subclass supported by this instance. * @return the Image type */ Class getSupportedImageClass(); - + /** * Generates the PDF objects for the given {@link Image} instance. If the handler generates * an XObject, it shall return it or otherwise return null. A generated XObject shall be @@ -66,7 +66,7 @@ public interface PDFImageHandler { * @return the generated XObject or null if no XObject was generated * @throws IOException if an I/O error occurs */ - PDFXObject generateImage(RendererContext context, Image image, + PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) throws IOException; - + } diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java index f1825297e..a58fe5922 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java @@ -38,9 +38,9 @@ public class PDFImageHandlerGraphics2D implements PDFImageHandler { private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { ImageFlavor.GRAPHICS2D, }; - + /** {@inheritDoc} */ - public PDFXObject generateImage(RendererContext context, Image image, + public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) throws IOException { PDFRenderer renderer = (PDFRenderer)context.getRenderer(); diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java index 65142878a..9f56ebfea 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java @@ -41,9 +41,9 @@ public class PDFImageHandlerRawCCITTFax implements PDFImageHandler { private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { ImageFlavor.RAW_CCITTFAX, }; - + /** {@inheritDoc} */ - public PDFXObject generateImage(RendererContext context, Image image, + public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) throws IOException { PDFRenderer renderer = (PDFRenderer)context.getRenderer(); @@ -52,7 +52,7 @@ public class PDFImageHandlerRawCCITTFax implements PDFImageHandler { PDFRendererContextConstants.PDF_DOCUMENT); PDFResourceContext resContext = (PDFResourceContext)context.getProperty( PDFRendererContextConstants.PDF_CONTEXT); - + PDFImage pdfimage = new ImageRawCCITTFaxAdapter(ccitt, image.getInfo().getOriginalURI()); PDFXObject xobj = pdfDoc.addImage(resContext, pdfimage); @@ -61,7 +61,7 @@ public class PDFImageHandlerRawCCITTFax implements PDFImageHandler { float w = (float)pos.getWidth() / 1000f; float h = (float)pos.getHeight() / 1000f; renderer.placeImage(x, y, w, h, xobj); - + return xobj; } diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java index 58c9f1f53..f971a49ae 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java @@ -41,9 +41,9 @@ public class PDFImageHandlerRawJPEG implements PDFImageHandler { private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { ImageFlavor.RAW_JPEG, }; - + /** {@inheritDoc} */ - public PDFXObject generateImage(RendererContext context, Image image, + public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) throws IOException { PDFRenderer renderer = (PDFRenderer)context.getRenderer(); @@ -52,7 +52,7 @@ public class PDFImageHandlerRawJPEG implements PDFImageHandler { PDFRendererContextConstants.PDF_DOCUMENT); PDFResourceContext resContext = (PDFResourceContext)context.getProperty( PDFRendererContextConstants.PDF_CONTEXT); - + PDFImage pdfimage = new ImageRawJPEGAdapter(jpeg, image.getInfo().getOriginalURI()); PDFXObject xobj = pdfDoc.addImage(resContext, pdfimage); @@ -61,7 +61,7 @@ public class PDFImageHandlerRawJPEG implements PDFImageHandler { float w = (float)pos.getWidth() / 1000f; float h = (float)pos.getHeight() / 1000f; renderer.placeImage(x, y, w, h, xobj); - + return xobj; } diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java index 536fc19b0..b664a0a24 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java @@ -5,9 +5,9 @@ * 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. @@ -41,7 +41,7 @@ public class PDFImageHandlerRegistry { /** the logger */ private static Log log = LogFactory.getLog(PDFImageHandlerRegistry.class); - + private static final Comparator HANDLER_COMPARATOR = new Comparator() { public int compare(Object o1, Object o2) { PDFImageHandler h1 = (PDFImageHandler)o1; @@ -54,19 +54,19 @@ public class PDFImageHandlerRegistry { private Map handlers = new java.util.HashMap(); /** List containing the same handlers as above but ordered by priority */ private List handlerList = new java.util.LinkedList(); - + /** Sorted Set of registered handlers */ private ImageFlavor[] supportedFlavors = new ImageFlavor[0]; private int handlerRegistrations; private int lastSync; - + /** * Default constructor. */ public PDFImageHandlerRegistry() { discoverHandlers(); } - + /** * Add an PDFImageHandler. The handler itself is inspected to find out what it supports. * @param classname the fully qualified class name @@ -87,11 +87,11 @@ public class PDFImageHandlerRegistry { + classname); } catch (ClassCastException e) { throw new IllegalArgumentException(classname - + " is not an " + + " is not an " + PDFImageHandler.class.getName()); } } - + /** * Add an image handler. The handler itself is inspected to find out what it supports. * @param handler the PDFImageHandler instance @@ -99,7 +99,7 @@ public class PDFImageHandlerRegistry { public synchronized void addHandler(PDFImageHandler handler) { Class imageClass = handler.getSupportedImageClass(); this.handlers.put(imageClass, handler); - + //Sorted insert ListIterator iter = this.handlerList.listIterator(); while (iter.hasNext()) { @@ -112,7 +112,7 @@ public class PDFImageHandlerRegistry { iter.add(handler); this.handlerRegistrations++; } - + /** * Returns an PDFImageHandler which handles an specific image type given the MIME type * of the image. @@ -143,7 +143,7 @@ public class PDFImageHandlerRegistry { } /** - * Returns the ordered array of supported image flavors. + * Returns the ordered array of supported image flavors. * @return the array of image flavors */ public synchronized ImageFlavor[] getSupportedFlavors() { @@ -162,7 +162,7 @@ public class PDFImageHandlerRegistry { } return this.supportedFlavors; } - + /** * Discovers PDFImageHandler implementations through the classpath and dynamically * registers them. @@ -175,7 +175,7 @@ public class PDFImageHandlerRegistry { PDFImageHandler handler = (PDFImageHandler)providers.next(); try { if (log.isDebugEnabled()) { - log.debug("Dynamically adding PDFImageHandler: " + log.debug("Dynamically adding PDFImageHandler: " + handler.getClass().getName()); } addHandler(handler); diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java index 628883b9f..783cb225c 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java @@ -40,11 +40,11 @@ public class PDFImageHandlerRenderedImage implements PDFImageHandler { private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { ImageFlavor.BUFFERED_IMAGE, - ImageFlavor.RENDERED_IMAGE + ImageFlavor.RENDERED_IMAGE }; - + /** {@inheritDoc} */ - public PDFXObject generateImage(RendererContext context, Image image, + public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) throws IOException { PDFRenderer renderer = (PDFRenderer)context.getRenderer(); @@ -53,7 +53,7 @@ public class PDFImageHandlerRenderedImage implements PDFImageHandler { PDFRendererContextConstants.PDF_DOCUMENT); PDFResourceContext resContext = (PDFResourceContext)context.getProperty( PDFRendererContextConstants.PDF_CONTEXT); - + PDFImage pdfimage = new ImageRenderedAdapter(imageRend, image.getInfo().getOriginalURI()); PDFXObject xobj = pdfDoc.addImage(resContext, pdfimage); @@ -62,7 +62,7 @@ public class PDFImageHandlerRenderedImage implements PDFImageHandler { float w = (float)pos.getWidth() / 1000f; float h = (float)pos.getHeight() / 1000f; renderer.placeImage(x, y, w, h, xobj); - + return xobj; } diff --git a/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java b/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java index ba47cce69..d111e733f 100644 --- a/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java +++ b/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java @@ -41,9 +41,9 @@ public class PDFImageHandlerXML implements PDFImageHandler { private static final ImageFlavor[] FLAVORS = new ImageFlavor[] { ImageFlavor.XML_DOM, }; - + /** {@inheritDoc} */ - public PDFXObject generateImage(RendererContext context, Image image, + public PDFXObject generateImage(RendererContext context, Image image, Point origin, Rectangle pos) throws IOException { PDFRenderer renderer = (PDFRenderer)context.getRenderer(); diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index c3e4a9657..27caf86b4 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -122,7 +122,7 @@ import org.apache.fop.util.ColorProfileUtil; * Renderer that renders areas to PDF. */ public class PDFRenderer extends AbstractPathOrientedRenderer { - + /** * The mime type for pdf */ @@ -130,7 +130,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { /** Normal PDF resolution (72dpi) */ public static final int NORMAL_PDF_RESOLUTION = 72; - + /** PDF encryption parameter: all parameters as object, datatype: PDFEncryptionParams */ public static final String ENCRYPTION_PARAMS = "encryption-params"; /** PDF encryption parameter: user password, datatype: String */ @@ -159,7 +159,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { /** Controls whether comments are written to the PDF stream. */ protected static final boolean WRITE_COMMENTS = true; - + /** * the PDF Document being created */ @@ -167,10 +167,10 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { /** the PDF/A mode (Default: disabled) */ protected PDFAMode pdfAMode = PDFAMode.DISABLED; - + /** the PDF/X mode (Default: disabled) */ protected PDFXMode pdfXMode = PDFXMode.DISABLED; - + /** * Map of pages using the PageViewport as the key * this is used for prepared pages that cannot be immediately @@ -246,10 +246,10 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { protected PDFICCBasedColorSpace sRGBColorSpace; /** controls whether the sRGB color space should be installed */ protected boolean disableSRGBColorSpace = false; - + /** Optional URI to an output profile to be used. */ - protected String outputProfileURI; - + protected String outputProfileURI; + /** drawing state */ protected PDFState currentState = null; @@ -263,7 +263,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { /** Image handler registry */ private PDFImageHandlerRegistry imageHandlerRegistry = new PDFImageHandlerRegistry(); - + /** * create the PDF renderer */ @@ -279,13 +279,13 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { throw new IllegalArgumentException("Boolean or \"true\" or \"false\" expected."); } } - + /** * {@inheritDoc} */ public void setUserAgent(FOUserAgent agent) { super.setUserAgent(agent); - PDFEncryptionParams params + PDFEncryptionParams params = (PDFEncryptionParams)agent.getRendererOptions().get(ENCRYPTION_PARAMS); if (params != null) { this.encryptionParams = params; //overwrite if available @@ -381,7 +381,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { } if (pdfXMode != PDFXMode.DISABLED) { log.debug(pdfXMode + " is active."); - log.warn("Note: " + pdfXMode + log.warn("Note: " + pdfXMode + " support is work-in-progress and not fully implemented, yet!"); addPDFXOutputIntent(); } @@ -389,7 +389,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { log.debug("PDF/A is active. Conformance Level: " + pdfAMode); addPDFA1OutputIntent(); } - + } private void addsRGBColorSpace() throws IOException { @@ -409,7 +409,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { this.sRGBColorSpace = PDFICCBasedColorSpace.setupsRGBAsDefaultRGBColorSpace(pdfDoc); } } - + private void addDefaultOutputProfile() throws IOException { if (this.outputProfile != null) { return; @@ -438,7 +438,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { outputProfile = sRGBColorSpace.getICCStream(); } } - + /** * Adds an OutputIntent to the PDF as mandated by PDF/A-1 when uncalibrated color spaces * are used (which is true if we use DeviceRGB to represent sRGB colors). @@ -446,7 +446,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { */ private void addPDFA1OutputIntent() throws IOException { addDefaultOutputProfile(); - + String desc = ColorProfileUtil.getICCProfileDescription(this.outputProfile.getICCProfile()); PDFOutputIntent outputIntent = pdfDoc.getFactory().makeOutputIntent(); outputIntent.setSubtype(PDFOutputIntent.GTS_PDFA1); @@ -463,7 +463,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { */ private void addPDFXOutputIntent() throws IOException { addDefaultOutputProfile(); - + String desc = ColorProfileUtil.getICCProfileDescription(this.outputProfile.getICCProfile()); int deviceClass = this.outputProfile.getICCProfile().getProfileClass(); if (deviceClass != ICC_Profile.CLASS_OUTPUT) { @@ -627,7 +627,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { return new PDFGraphics2DAdapter(this); } - /** + /** * writes out a comment. * @param text text for the comment */ @@ -738,7 +738,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { page.getPageIndex()); pageReferences.put(page.getKey(), currentPage.referencePDF()); pvReferences.put(page.getKey(), page); - + //Produce page labels PDFPageLabels pageLabels = this.pdfDoc.getRoot().getPageLabels(); if (pageLabels == null) { @@ -746,14 +746,14 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { pageLabels = this.pdfDoc.getFactory().makePageLabels(); this.pdfDoc.getRoot().setPageLabels(pageLabels); } - PDFNumsArray nums = pageLabels.getNums(); + PDFNumsArray nums = pageLabels.getNums(); PDFDictionary dict = new PDFDictionary(nums); dict.put("P", page.getPageNumberString()); //TODO If the sequence of generated page numbers were inspected, this could be //expressed in a more space-efficient way nums.put(page.getPageIndex(), dict); } - + /** * This method creates a pdf stream for the current page * uses it as the contents of a new page. The page is written @@ -789,7 +789,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { pageHeight / 1000f); currentState.concatenate(basicPageTransform); currentStream.add(CTMHelper.toPDFString(basicPageTransform, false) + " cm\n"); - + super.renderPage(page); this.pdfDoc.registerObject(currentStream); @@ -811,9 +811,9 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { new AffineTransform(CTMHelper.toPDFArray(ctm))); if (clippingRect != null) { - clipRect((float)clippingRect.getX() / 1000f, - (float)clippingRect.getY() / 1000f, - (float)clippingRect.getWidth() / 1000f, + clipRect((float)clippingRect.getX() / 1000f, + (float)clippingRect.getY() / 1000f, + (float)clippingRect.getWidth() / 1000f, (float)clippingRect.getHeight() / 1000f); } // multiply with current CTM @@ -832,7 +832,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream.add(CTMHelper.toPDFString(at, false) + " cm\n"); } } - + /** * Formats a float value (normally coordinates) as Strings. * @param value the value @@ -841,9 +841,9 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { protected static String format(float value) { return PDFNumber.doubleOut(value); } - + /** {@inheritDoc} */ - protected void drawBorderLine(float x1, float y1, float x2, float y2, + protected void drawBorderLine(float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, Color col) { float w = x2 - x1; float h = y2 - y1; @@ -853,7 +853,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { return; } switch (style) { - case Constants.EN_DASHED: + case Constants.EN_DASHED: setColor(col, false, null); if (horz) { float unit = Math.abs(2 * h); @@ -865,7 +865,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream.add("[" + format(unit) + "] 0 d "); currentStream.add(format(h) + " w\n"); float ym = y1 + (h / 2); - currentStream.add(format(x1) + " " + format(ym) + " m " + currentStream.add(format(x1) + " " + format(ym) + " m " + format(x2) + " " + format(ym) + " l S\n"); } else { float unit = Math.abs(2 * w); @@ -877,7 +877,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream.add("[" + format(unit) + "] 0 d "); currentStream.add(format(w) + " w\n"); float xm = x1 + (w / 2); - currentStream.add(format(xm) + " " + format(y1) + " m " + currentStream.add(format(xm) + " " + format(y1) + " m " + format(xm) + " " + format(y2) + " l S\n"); } break; @@ -894,7 +894,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream.add("[0 " + format(unit) + "] 0 d "); currentStream.add(format(h) + " w\n"); float ym = y1 + (h / 2); - currentStream.add(format(x1) + " " + format(ym) + " m " + currentStream.add(format(x1) + " " + format(ym) + " m " + format(x2) + " " + format(ym) + " l S\n"); } else { float unit = Math.abs(2 * w); @@ -906,7 +906,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream.add("[0 " + format(unit) + " ] 0 d "); currentStream.add(format(w) + " w\n"); float xm = x1 + (w / 2); - currentStream.add(format(xm) + " " + format(y1) + " m " + currentStream.add(format(xm) + " " + format(y1) + " m " + format(xm) + " " + format(y2) + " l S\n"); } break; @@ -918,18 +918,18 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream.add(format(h3) + " w\n"); float ym1 = y1 + (h3 / 2); float ym2 = ym1 + h3 + h3; - currentStream.add(format(x1) + " " + format(ym1) + " m " + currentStream.add(format(x1) + " " + format(ym1) + " m " + format(x2) + " " + format(ym1) + " l S\n"); - currentStream.add(format(x1) + " " + format(ym2) + " m " + currentStream.add(format(x1) + " " + format(ym2) + " m " + format(x2) + " " + format(ym2) + " l S\n"); } else { float w3 = w / 3; currentStream.add(format(w3) + " w\n"); float xm1 = x1 + (w3 / 2); float xm2 = xm1 + w3 + w3; - currentStream.add(format(xm1) + " " + format(y1) + " m " + currentStream.add(format(xm1) + " " + format(y1) + " m " + format(xm1) + " " + format(y2) + " l S\n"); - currentStream.add(format(xm2) + " " + format(y1) + " m " + currentStream.add(format(xm2) + " " + format(y1) + " m " + format(xm2) + " " + format(y2) + " l S\n"); } break; @@ -945,13 +945,13 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream.add(format(h3) + " w\n"); float ym1 = y1 + (h3 / 2); setColor(uppercol, false, null); - currentStream.add(format(x1) + " " + format(ym1) + " m " + currentStream.add(format(x1) + " " + format(ym1) + " m " + format(x2) + " " + format(ym1) + " l S\n"); setColor(col, false, null); - currentStream.add(format(x1) + " " + format(ym1 + h3) + " m " + currentStream.add(format(x1) + " " + format(ym1 + h3) + " m " + format(x2) + " " + format(ym1 + h3) + " l S\n"); setColor(lowercol, false, null); - currentStream.add(format(x1) + " " + format(ym1 + h3 + h3) + " m " + currentStream.add(format(x1) + " " + format(ym1 + h3 + h3) + " m " + format(x2) + " " + format(ym1 + h3 + h3) + " l S\n"); } else { Color leftcol = lightenColor(col, -colFactor); @@ -960,13 +960,13 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream.add(format(w3) + " w\n"); float xm1 = x1 + (w3 / 2); setColor(leftcol, false, null); - currentStream.add(format(xm1) + " " + format(y1) + " m " + currentStream.add(format(xm1) + " " + format(y1) + " m " + format(xm1) + " " + format(y2) + " l S\n"); setColor(col, false, null); - currentStream.add(format(xm1 + w3) + " " + format(y1) + " m " + currentStream.add(format(xm1 + w3) + " " + format(y1) + " m " + format(xm1 + w3) + " " + format(y2) + " l S\n"); setColor(rightcol, false, null); - currentStream.add(format(xm1 + w3 + w3) + " " + format(y1) + " m " + currentStream.add(format(xm1 + w3 + w3) + " " + format(y1) + " m " + format(xm1 + w3 + w3) + " " + format(y2) + " l S\n"); } break; @@ -982,14 +982,14 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream.add(format(h) + " w\n"); float ym1 = y1 + (h / 2); setColor(c, false, null); - currentStream.add(format(x1) + " " + format(ym1) + " m " + currentStream.add(format(x1) + " " + format(ym1) + " m " + format(x2) + " " + format(ym1) + " l S\n"); } else { c = lightenColor(c, (startOrBefore ? 1 : -1) * colFactor); currentStream.add(format(w) + " w\n"); float xm1 = x1 + (w / 2); setColor(c, false, null); - currentStream.add(format(xm1) + " " + format(y1) + " m " + currentStream.add(format(xm1) + " " + format(y1) + " m " + format(xm1) + " " + format(y2) + " l S\n"); } break; @@ -1002,17 +1002,17 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { if (horz) { currentStream.add(format(h) + " w\n"); float ym = y1 + (h / 2); - currentStream.add(format(x1) + " " + format(ym) + " m " + currentStream.add(format(x1) + " " + format(ym) + " m " + format(x2) + " " + format(ym) + " l S\n"); } else { currentStream.add(format(w) + " w\n"); float xm = x1 + (w / 2); - currentStream.add(format(xm) + " " + format(y1) + " m " + currentStream.add(format(xm) + " " + format(y1) + " m " + format(xm) + " " + format(y2) + " l S\n"); } } } - + /** * Sets the current line width in points. * @param width line width in points @@ -1023,10 +1023,10 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream.add(format(width) + " w\n"); } } - + /** {@inheritDoc} */ protected void clipRect(float x, float y, float width, float height) { - currentStream.add(format(x) + " " + format(y) + " " + currentStream.add(format(x) + " " + format(y) + " " + format(width) + " " + format(height) + " re "); clip(); } @@ -1040,42 +1040,42 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { } /** - * Moves the current point to (x, y), omitting any connecting line segment. + * Moves the current point to (x, y), omitting any connecting line segment. * @param x x coordinate * @param y y coordinate */ protected void moveTo(float x, float y) { currentStream.add(format(x) + " " + format(y) + " m "); } - + /** - * Appends a straight line segment from the current point to (x, y). The - * new current point is (x, y). + * Appends a straight line segment from the current point to (x, y). The + * new current point is (x, y). * @param x x coordinate * @param y y coordinate */ protected void lineTo(float x, float y) { currentStream.add(format(x) + " " + format(y) + " l "); } - + /** - * Closes the current subpath by appending a straight line segment from + * Closes the current subpath by appending a straight line segment from * the current point to the starting point of the subpath. */ protected void closePath() { currentStream.add("h "); } - /** - * {@inheritDoc} + /** + * {@inheritDoc} */ protected void fillRect(float x, float y, float width, float height) { if (width > 0 && height > 0) { - currentStream.add(format(x) + " " + format(y) + " " + currentStream.add(format(x) + " " + format(y) + " " + format(width) + " " + format(height) + " re f\n"); } } - + /** * Draw a line. * @@ -1131,7 +1131,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { } /** - * Returns area's id if it is the first area in the document with that id + * Returns area's id if it is the first area in the document with that id * (i.e. if the area qualifies as a link target). * Otherwise, or if the area has no id, null is returned. * @@ -1216,7 +1216,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { * @param pdfPageRef the PDF page reference string * @param relativeIPP the *relative* IP position in millipoints * @param relativeBPP the *relative* BP position in millipoints - * @param tf the transformation to apply once the relative positions have been + * @param tf the transformation to apply once the relative positions have been * converted to points */ protected void saveAbsolutePosition(String id, String pdfPageRef, @@ -1258,13 +1258,13 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { * @param relativeBPP the *relative* BP position in millipoints */ protected void saveAbsolutePosition(String id, int relativeIPP, int relativeBPP) { - saveAbsolutePosition(id, currentPageRef, + saveAbsolutePosition(id, currentPageRef, relativeIPP, relativeBPP, currentState.getTransform()); } /** - * If the given block area is a possible link target, its id + absolute position will - * be saved. The saved position is only correct if this function is called at the very + * If the given block area is a possible link target, its id + absolute position will + * be saved. The saved position is only correct if this function is called at the very * start of renderBlock! * * @param block the block area in question @@ -1392,7 +1392,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { // warn if link trait found but not allowed, else create link if (linkTraitFound) { if (!annotsAllowed) { - log.warn("Skipping annotation for a link due to PDF profile: " + log.warn("Skipping annotation for a link due to PDF profile: " + pdfDoc.getProfile()); } else if (action != null) { PDFLink pdfLink = factory.makeLink(ipRect, action); @@ -1408,23 +1408,23 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { } return tf; } - + /** {@inheritDoc} */ public void renderText(TextArea text) { renderInlineAreaBackAndBorders(text); Color ct = (Color) text.getTrait(Trait.COLOR); updateColor(ct, true); - + beginTextObject(); String fontName = getInternalFontNameForArea(text); int size = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue(); - + // This assumes that *all* CIDFonts use a /ToUnicode mapping Typeface tf = getTypeface(fontName); - + textutil.updateTf(fontName, size / 1000f, tf.isMultiByte()); - + // word.getOffset() = only height of text itself // currentBlockIPPosition: 0 for beginning of line; nonzero @@ -1437,7 +1437,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { super.renderText(text); textutil.writeTJ(); - + renderTextDecoration(tf, size, text, bl, rx); } @@ -1446,7 +1446,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { Font font = getFontFromArea(word.getParentArea()); String s = word.getWord(); - escapeText(s, word.getLetterAdjustArray(), + escapeText(s, word.getLetterAdjustArray(), font, (AbstractTextArea)word.getParentArea()); super.renderWord(word); @@ -1456,7 +1456,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { public void renderSpace(SpaceArea space) { Font font = getFontFromArea(space.getParentArea()); String s = space.getSpace(); - + AbstractTextArea textArea = (AbstractTextArea)space.getParentArea(); escapeText(s, null, font, textArea); @@ -1485,7 +1485,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { Font font, AbstractTextArea parentArea) { escapeText(s, 0, s.length(), letterAdjust, font, parentArea); } - + /** * Escapes text according to PDF rules. * @param s Text to escape @@ -1507,7 +1507,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { } int l = s.length(); - + for (int i = start; i < end; i++) { char orgChar = s.charAt(i); char ch; @@ -1553,7 +1553,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { /** * Establishes a new foreground or fill color. In contrast to updateColor * this method does not check the PDFState for optimization possibilities. - * @param col the color to apply + * @param col the color to apply * @param fill true to set the fill color, false for the foreground color * @param pdf StringBuffer to write the PDF code to, if null, the code is * written to the current stream. @@ -1567,7 +1567,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream.add(color.getColorSpaceOut(fill)); } } - + /** * Establishes a new foreground or fill color. * @param col the color to apply (null skips this operation) @@ -1595,7 +1595,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { protected void updateColor(Color col, boolean fill) { updateColor(col, fill, null); } - + /** {@inheritDoc} */ public void renderImage(Image image, Rectangle2D pos) { endTextObject(); @@ -1618,7 +1618,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { protected void putImage(String uri, Rectangle2D pos) { putImage(uri, pos, null); } - + /** * Adds a PDF XObject (a bitmap or form) to the PDF that will later be referenced. * @param uri URL of the bitmap @@ -1650,11 +1650,11 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { try { ImageSessionContext sessionContext = getUserAgent().getImageSessionContext(); info = manager.getImageInfo(uri, sessionContext); - + Map hints = ImageUtil.getDefaultHints(sessionContext); org.apache.xmlgraphics.image.loader.Image img = manager.getImage( info, imageHandlerRegistry.getSupportedFlavors(), hints, sessionContext); - + //First check for a dynamically registered handler PDFImageHandler handler = imageHandlerRegistry.getHandler(img.getClass()); if (handler != null) { @@ -1712,13 +1712,13 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { currentStream.add(format(w) + " 0 0 " + format(-h) + " " + format(currentIPPosition / 1000f + x) + " " - + format(currentBPPosition / 1000f + h + y) + + format(currentBPPosition / 1000f + h + y) + " cm\n" + xobj.getName() + " Do\n"); restoreGraphicsState(); } /** {@inheritDoc} */ - protected RendererContext createRendererContext(int x, int y, int width, int height, + protected RendererContext createRendererContext(int x, int y, int width, int height, Map foreignAttributes) { RendererContext context = super.createRendererContext( x, y, width, height, foreignAttributes); @@ -1749,7 +1749,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { int style = area.getRuleStyle(); float startx = (currentIPPosition + area.getBorderAndPaddingWidthStart()) / 1000f; float starty = (currentBPPosition + area.getOffset()) / 1000f; - float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart() + float endx = (currentIPPosition + area.getBorderAndPaddingWidthStart() + area.getIPD()) / 1000f; float ruleThickness = area.getRuleThickness() / 1000f; Color col = (Color)area.getTrait(Trait.COLOR); @@ -1758,7 +1758,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { case EN_SOLID: case EN_DASHED: case EN_DOUBLE: - drawBorderLine(startx, starty, endx, starty + ruleThickness, + drawBorderLine(startx, starty, endx, starty + ruleThickness, true, true, style, col); break; case EN_DOTTED: @@ -1766,7 +1766,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { //This displaces the dots to the right by half a dot's width //TODO There's room for improvement here currentStream.add("1 0 0 1 " + format(ruleThickness / 2) + " 0 cm\n"); - drawBorderLine(startx, starty, endx, starty + ruleThickness, + drawBorderLine(startx, starty, endx, starty + ruleThickness, true, true, style, col); break; case EN_GROOVE: @@ -1811,7 +1811,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { public String getMimeType() { return MIME_TYPE; } - + /** * Sets the PDF/A mode for the PDF renderer. * @param mode the PDF/A mode @@ -1825,7 +1825,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { * @param mode the PDF/X mode */ public void setXMode(PDFXMode mode) { - this.pdfXMode = mode; + this.pdfXMode = mode; } /** @@ -1846,7 +1846,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer { /** * Sets the encryption parameters used by the PDF renderer. - * @param encryptionParams the encryption parameters + * @param encryptionParams the encryption parameters */ public void setEncryptionParams(PDFEncryptionParams encryptionParams) { this.encryptionParams = encryptionParams; diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java index 826f610c8..8d1042f7f 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java +++ b/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java @@ -5,9 +5,9 @@ * 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. @@ -36,7 +36,7 @@ import org.apache.fop.render.Renderer; import org.apache.fop.util.LogUtil; /** - * PDF renderer configurator + * PDF renderer configurator */ public class PDFRendererConfigurator extends PrintRendererConfigurator { @@ -70,9 +70,9 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator { } catch (ConfigurationException e) { LogUtil.handleException(log, e, false); } - + super.configure(renderer); - + String s = cfg.getChild(PDFRenderer.PDF_A_MODE, true).getValue(null); if (s != null) { pdfRenderer.setAMode(PDFAMode.valueOf(s)); @@ -143,7 +143,7 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator { * @return Map the newly built filter map * @throws ConfigurationException if a filter list is defined twice */ - public static Map buildFilterMapFromConfiguration(Configuration cfg) + public static Map buildFilterMapFromConfiguration(Configuration cfg) throws ConfigurationException { Map filterMap = new java.util.HashMap(); Configuration[] filterLists = cfg.getChildren("filterList"); @@ -156,11 +156,11 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator { String name = filt[j].getValue(); filterList.add(name); } - + if (type == null) { type = PDFFilterList.DEFAULT_FILTER; } - + if (!filterList.isEmpty() && log.isDebugEnabled()) { StringBuffer debug = new StringBuffer("Adding PDF filter"); if (filterList.size() != 1) { @@ -175,13 +175,13 @@ public class PDFRendererConfigurator extends PrintRendererConfigurator { } log.debug(debug.toString()); } - + if (filterMap.get(type) != null) { - throw new ConfigurationException("A filterList of type '" + throw new ConfigurationException("A filterList of type '" + type + "' has already been defined"); } filterMap.put(type, filterList); } - return filterMap; + return filterMap; } } diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java b/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java index d3efa9667..de51aabc7 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java +++ b/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java @@ -49,5 +49,5 @@ public interface PDFRendererContextConstants extends RendererContextConstants { /** The current pdf font size. */ String PDF_FONT_SIZE = "fontSize"; - + } diff --git a/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java b/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java index 98fd7b5db..fb65c9d74 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java +++ b/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java @@ -5,9 +5,9 @@ * 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. @@ -31,7 +31,7 @@ import org.apache.fop.render.RendererConfigurator; public class PDFRendererMaker extends AbstractRendererMaker { private static final String[] MIMES = new String[] {MimeConstants.MIME_PDF}; - + /** {@inheritDoc} */ public Renderer makeRenderer(FOUserAgent userAgent) { return new PDFRenderer(); @@ -41,7 +41,7 @@ public class PDFRendererMaker extends AbstractRendererMaker { public RendererConfigurator getConfigurator(FOUserAgent userAgent) { return new PDFRendererConfigurator(userAgent); } - + /** {@inheritDoc} */ public boolean needsOutputStream() { return true; diff --git a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java index 73b50e323..e31628160 100644 --- a/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java @@ -5,9 +5,9 @@ * 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. @@ -62,7 +62,7 @@ import org.apache.fop.svg.SVGUserAgent; * It renders SVG to the PDF document using the PDFGraphics2D. * The properties from the PDF renderer are subject to change. */ -public class PDFSVGHandler extends AbstractGenericSVGHandler +public class PDFSVGHandler extends AbstractGenericSVGHandler implements PDFRendererContextConstants { /** logging instance */ @@ -93,7 +93,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); QName qName = new QName(ExtensionElementMapping.URI, null, "conversion-mode"); - if (foreign != null + if (foreign != null && "bitmap".equalsIgnoreCase((String)foreign.get(qName))) { pdfi.paintAsBitmap = true; } @@ -156,12 +156,12 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler int xOffset = pdfInfo.currentXPosition; int yOffset = pdfInfo.currentYPosition; - FOUserAgent userAgent = context.getUserAgent(); + FOUserAgent userAgent = context.getUserAgent(); final float deviceResolution = userAgent.getTargetResolution(); if (log.isDebugEnabled()) { log.debug("Generating SVG at " + deviceResolution + "dpi."); } - + final float uaResolution = userAgent.getSourceResolution(); SVGUserAgent ua = new SVGUserAgent(userAgent, new AffineTransform()); @@ -169,22 +169,22 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler double s = uaResolution / deviceResolution; AffineTransform resolutionScaling = new AffineTransform(); resolutionScaling.scale(s, s); - + GVTBuilder builder = new GVTBuilder(); - + //Controls whether text painted by Batik is generated using text or path operations boolean strokeText = false; Configuration cfg = pdfInfo.cfg; if (cfg != null) { strokeText = cfg.getChild("stroke-text", true).getValueAsBoolean(strokeText); } - - BridgeContext ctx = new PDFBridgeContext(ua, + + BridgeContext ctx = new PDFBridgeContext(ua, (strokeText ? null : pdfInfo.fi), userAgent.getFactory().getImageManager(), userAgent.getImageSessionContext(), new AffineTransform()); - + GraphicsNode root; try { root = builder.build(ctx, doc); @@ -211,7 +211,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler AffineTransform imageTransform = new AffineTransform(); imageTransform.concatenate(scaling); imageTransform.concatenate(resolutionScaling); - + /* * Clip to the svg area. * Note: To have the svg overlay (under) a text area then use @@ -232,27 +232,27 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler if (pdfInfo.pdfContext == null) { pdfInfo.pdfContext = pdfInfo.pdfPage; } - PDFGraphics2D graphics = new PDFGraphics2D(true, pdfInfo.fi, + PDFGraphics2D graphics = new PDFGraphics2D(true, pdfInfo.fi, pdfInfo.pdfDoc, pdfInfo.pdfContext, pdfInfo.pdfPage.referencePDF(), pdfInfo.currentFontName, pdfInfo.currentFontSize); graphics.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); if (!resolutionScaling.isIdentity()) { - pdfInfo.currentStream.add("%resolution scaling for " + uaResolution + pdfInfo.currentStream.add("%resolution scaling for " + uaResolution + " -> " + deviceResolution + "\n"); pdfInfo.currentStream.add( CTMHelper.toPDFString(resolutionScaling, false) + " cm\n"); graphics.scale(1 / s, 1 / s); } - + pdfInfo.currentStream.add("%SVG start\n"); //Save state and update coordinate system for the SVG image pdfInfo.pdfState.push(); pdfInfo.pdfState.concatenate(imageTransform); - //Now that we have the complete transformation matrix for the image, we can update the + //Now that we have the complete transformation matrix for the image, we can update the //transformation matrix for the AElementBridge. PDFAElementBridge aBridge = (PDFAElementBridge)ctx.getBridge( SVGDOMImplementation.SVG_NAMESPACE_URI, SVGConstants.SVG_A_TAG); @@ -272,7 +272,7 @@ public class PDFSVGHandler extends AbstractGenericSVGHandler renderer.restoreGraphicsState(); pdfInfo.currentStream.add("%SVG end\n"); } - + /** {@inheritDoc} */ public boolean supportsRenderer(Renderer renderer) { return (renderer instanceof PDFRenderer); |