Author: jahewson Date: Mon Feb 24 23:05:20 2014 New Revision: 1571482 URL: http://svn.apache.org/r1571482 Log: Overhaul to support uncolored patterns for PDFBOX-1094
Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDPatternDictionary.java - copied, changed from r1571090, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDPatternResources.java pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPattern.java - copied, changed from r1571090, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPatternResources.java pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDTilingPattern.java - copied, changed from r1571090, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDTilingPatternResources.java pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/tiling/TilingPaint.java - copied, changed from r1571090, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/tiling/ColoredTilingPaint.java Removed: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDPatternResources.java pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPatternResources.java pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDTilingPatternResources.java pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/tiling/ColoredTilingContext.java pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/tiling/ColoredTilingPaint.java Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColor.java pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpace.java pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDPattern.java pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/TilingPatternValidationProcess.java Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java?rev=1571482&r1=1571481&r2=1571482&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfviewer/PageDrawer.java Mon Feb 24 23:05:20 2014 @@ -66,6 +66,9 @@ import org.apache.pdfbox.pdmodel.font.PD import org.apache.pdfbox.pdmodel.font.PDType3Font; import org.apache.pdfbox.pdmodel.graphics.PDGraphicsState; import org.apache.pdfbox.pdmodel.graphics.PDShading; +import org.apache.pdfbox.pdmodel.graphics.color.PDColor; +import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace; +import org.apache.pdfbox.pdmodel.graphics.pattern.PDTilingPattern; import org.apache.pdfbox.pdmodel.graphics.shading.AxialShadingPaint; import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingResources; import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType2; @@ -178,25 +181,39 @@ public class PageDrawer extends PDFStrea } } } + graphics = null; } /** - * This will draw the page to the requested context. + * This will draw the pattern stream to the requested context. * * @param g The graphics context to draw onto. - * @param stream The stream to be used. - * @param resources resources to be used when drawing the stream + * @param pattern The tiling pattern to be used. * @param pageDimension The size of the page to draw. - * * @throws IOException If there is an IO error while drawing the page. */ - public void drawStream(Graphics g, COSStream stream, PDResources resources, PDRectangle pageDimension) - throws IOException + public void drawTilingPattern(Graphics2D g, PDTilingPattern pattern, PDRectangle pageDimension, + Matrix matrix, PDColorSpace colorSpace, PDColor color) + throws IOException { - graphics = (Graphics2D) g; + graphics = g; graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); - processStream(resources, stream, pageDimension, 0); + + initStream(pageDimension, 0); + + // transform ctm + Matrix concat = getGraphicsState().getCurrentTransformationMatrix().multiply(matrix); + getGraphicsState().setCurrentTransformationMatrix(concat); + + // color + if (colorSpace != null) + { + getGraphicsState().setNonStrokingColorSpace(colorSpace); + getGraphicsState().setNonStrokingColor(color); + } + + processSubStream(pattern.getResources(), (COSStream)pattern.getCOSObject()); } /** Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java?rev=1571482&r1=1571481&r2=1571482&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDResources.java Mon Feb 24 23:05:20 2014 @@ -32,7 +32,7 @@ import org.apache.pdfbox.pdmodel.font.PD import org.apache.pdfbox.pdmodel.font.PDFontFactory; import org.apache.pdfbox.pdmodel.graphics.PDExtendedGraphicsState; import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace; -import org.apache.pdfbox.pdmodel.graphics.pattern.PDPatternResources; +import org.apache.pdfbox.pdmodel.graphics.pattern.PDPatternDictionary; import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingResources; import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject; import org.apache.pdfbox.pdmodel.graphics.PDXObject; @@ -55,7 +55,7 @@ public class PDResources implements COSO private Map<PDXObject, String> xobjectMappings = null; private HashMap<String, PDImageXObject> images = null; private Map<String, PDExtendedGraphicsState> graphicsStates = null; - private Map<String, PDPatternResources> patterns = null; + private Map<String, PDPatternDictionary> patterns = null; private Map<String, PDShadingResources> shadings = null; /** @@ -465,24 +465,24 @@ public class PDResources implements COSO /** * This will get the map of patterns. This will return null if the underlying resources dictionary does not have a - * patterns dictionary. The keys are the pattern name as a String and the values are PDPatternResources objects. + * patterns dictionary. The keys are the pattern name as a String and the values are PDPatternDictionary objects. * * @return The map of pattern resources objects. * * @throws IOException If there is an error getting the pattern resources. */ - public Map<String, PDPatternResources> getPatterns() throws IOException + public Map<String, PDPatternDictionary> getPatterns() throws IOException { if (patterns == null) { COSDictionary patternsDictionary = (COSDictionary) resources.getDictionaryObject(COSName.PATTERN); if (patternsDictionary != null) { - patterns = new HashMap<String, PDPatternResources>(); + patterns = new HashMap<String, PDPatternDictionary>(); for (COSName name : patternsDictionary.keySet()) { COSDictionary dictionary = (COSDictionary) patternsDictionary.getDictionaryObject(name); - patterns.put(name.getName(), PDPatternResources.create(dictionary)); + patterns.put(name.getName(), PDPatternDictionary.create(dictionary)); } } } @@ -494,7 +494,7 @@ public class PDResources implements COSO * * @param patternsValue The new map of patterns. */ - public void setPatterns(Map<String, PDPatternResources> patternsValue) + public void setPatterns(Map<String, PDPatternDictionary> patternsValue) { patterns = patternsValue; if (patternsValue != null) @@ -504,7 +504,7 @@ public class PDResources implements COSO while (iter.hasNext()) { String name = iter.next(); - PDPatternResources pattern = patternsValue.get(name); + PDPatternDictionary pattern = patternsValue.get(name); dic.setItem(COSName.getPDFName(name), pattern.getCOSObject()); } resources.setItem(COSName.PATTERN, dic); Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColor.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColor.java?rev=1571482&r1=1571481&r2=1571482&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColor.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColor.java Mon Feb 24 23:05:20 2014 @@ -20,12 +20,8 @@ import org.apache.pdfbox.cos.COSArray; import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.cos.COSNumber; import org.apache.pdfbox.cos.COSString; -import org.apache.pdfbox.pdmodel.graphics.pattern.PDPatternResources; -import java.awt.Paint; -import java.io.IOException; import java.util.Arrays; -import java.util.Map; /** * A color value, consisting of one or more color components, or for pattern color spaces, Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpace.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpace.java?rev=1571482&r1=1571481&r2=1571482&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpace.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDColorSpace.java Mon Feb 24 23:05:20 2014 @@ -21,7 +21,7 @@ import org.apache.pdfbox.cos.COSArray; import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.pdmodel.common.COSObjectable; -import org.apache.pdfbox.pdmodel.graphics.pattern.PDPatternResources; +import org.apache.pdfbox.pdmodel.graphics.pattern.PDPatternDictionary; import java.awt.Color; import java.awt.Paint; @@ -66,7 +66,7 @@ public abstract class PDColorSpace imple */ public static PDColorSpace create(COSBase colorSpace, Map<String, PDColorSpace> colorSpaces, - Map<String, PDPatternResources> patterns) + Map<String, PDPatternDictionary> patterns) throws IOException { if (colorSpace instanceof COSName) @@ -137,7 +137,7 @@ public abstract class PDColorSpace imple } else if (name == COSName.PATTERN) { - return new PDPattern(patterns); + return new PDPattern(patterns, PDColorSpace.create(array.get(1))); } else { Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDPattern.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDPattern.java?rev=1571482&r1=1571481&r2=1571482&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDPattern.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDPattern.java Mon Feb 24 23:05:20 2014 @@ -19,10 +19,10 @@ package org.apache.pdfbox.pdmodel.graphi import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.pdfbox.cos.COSName; -import org.apache.pdfbox.pdmodel.graphics.pattern.PDPatternResources; -import org.apache.pdfbox.pdmodel.graphics.pattern.PDShadingPatternResources; -import org.apache.pdfbox.pdmodel.graphics.pattern.PDTilingPatternResources; -import org.apache.pdfbox.pdmodel.graphics.pattern.tiling.ColoredTilingPaint; +import org.apache.pdfbox.pdmodel.graphics.pattern.PDPatternDictionary; +import org.apache.pdfbox.pdmodel.graphics.pattern.PDShadingPattern; +import org.apache.pdfbox.pdmodel.graphics.pattern.PDTilingPattern; +import org.apache.pdfbox.pdmodel.graphics.pattern.tiling.TilingPaint; import org.apache.pdfbox.pdmodel.graphics.shading.AxialShadingPaint; import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingResources; import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingType1; @@ -53,16 +53,26 @@ public final class PDPattern extends PDS { private static final Log LOG = LogFactory.getLog(PDPattern.class); - private Map<String, PDPatternResources> patterns; + private Map<String, PDPatternDictionary> patterns; + private PDColorSpace underlyingColorSpace; /** - * Creates a new Pattern color space. + * Creates a new pattern color space. */ - public PDPattern(Map<String, PDPatternResources> patterns) + public PDPattern(Map<String, PDPatternDictionary> patterns) { this.patterns = patterns; } + /** + * Creates a new uncolored tiling pattern color space. + */ + public PDPattern(Map<String, PDPatternDictionary> patterns, PDColorSpace colorSpace) + { + this.patterns = patterns; + this.underlyingColorSpace = colorSpace; + } + @Override public String getName() { @@ -113,35 +123,32 @@ public final class PDPattern extends PDS throw new IOException("pattern " + color.getPatternName() + " was not found"); } - PDPatternResources pattern = patterns.get(color.getPatternName()); - if (pattern instanceof PDTilingPatternResources) + PDPatternDictionary pattern = patterns.get(color.getPatternName()); + if (pattern instanceof PDTilingPattern) { - return toTilingPaint((PDTilingPatternResources)pattern, color); + return toTilingPaint((PDTilingPattern)pattern, color); } else { - return toShadingPaint((PDShadingPatternResources)pattern, pageHeight); + return toShadingPaint((PDShadingPattern)pattern, pageHeight); } } - public Paint toTilingPaint(PDTilingPatternResources tilingPattern, PDColor color) + public Paint toTilingPaint(PDTilingPattern tilingPattern, PDColor color) throws IOException { - if (tilingPattern.getPatternType() == PDTilingPatternResources.COLORED_TILING_PATTERN) + if (tilingPattern.getPaintType() == PDTilingPattern.PAINT_COLORED) { // colored tiling pattern - // TODO we should be passing the color to ColoredTilingPaint - return new ColoredTilingPaint(tilingPattern); + return new TilingPaint(tilingPattern); } else { // uncolored tiling pattern - // TODO ... - LOG.debug("Not implemented: uncoloured tiling patterns"); - return new Color(0, 0, 0, 0); // transparent + return new TilingPaint(tilingPattern, underlyingColorSpace, color); } } - public Paint toShadingPaint(PDShadingPatternResources shadingPattern, int pageHeight) + public Paint toShadingPaint(PDShadingPattern shadingPattern, int pageHeight) throws IOException { PDShadingResources shadingResources = shadingPattern.getShading(); Copied: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDPatternDictionary.java (from r1571090, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDPatternResources.java) URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDPatternDictionary.java?p2=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDPatternDictionary.java&p1=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDPatternResources.java&r1=1571090&r2=1571482&rev=1571482&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDPatternResources.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDPatternDictionary.java Mon Feb 24 23:05:20 2014 @@ -16,7 +16,6 @@ */ package org.apache.pdfbox.pdmodel.graphics.pattern; - import java.io.IOException; import org.apache.pdfbox.cos.COSBase; @@ -25,37 +24,63 @@ import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.pdmodel.common.COSObjectable; /** - * This represents the resources for a pattern color space. + * A Pattern dictionary from a page's resources. + * @author Andreas Lehmkühler */ -public abstract class PDPatternResources implements COSObjectable +public abstract class PDPatternDictionary implements COSObjectable { + /** Tiling pattern type. */ + public static final int TYPE_TILING_PATTERN = 1; + + /** Shading pattern type. */ + public static final int TYPE_SHADING_PATTERN = 2; + + /** + * Create the correct PD Model pattern based on the COS base pattern. + * @param resourceDictionary the COS pattern dictionary + * @return the newly created pattern resources object + * @throws IOException If we are unable to create the PDPattern object. + */ + public static PDPatternDictionary create(COSDictionary resourceDictionary) throws IOException + { + PDPatternDictionary pattern; + int patternType = resourceDictionary.getInt(COSName.PATTERN_TYPE, 0); + switch (patternType) + { + case TYPE_TILING_PATTERN: + pattern = new PDTilingPattern(resourceDictionary); + break; + case TYPE_SHADING_PATTERN: + pattern = new PDShadingPattern(resourceDictionary); + break; + default: + throw new IOException("Error: Unknown pattern type " + patternType); + } + return pattern; + } + private COSDictionary patternDictionary; - public static final int TILING_PATTERN = 1; - public static final int SHADING_PATTERN = 2; - /** - * Default constructor. + * Creates a new Pattern dictionary. */ - public PDPatternResources() + public PDPatternDictionary() { patternDictionary = new COSDictionary(); patternDictionary.setName(COSName.TYPE, COSName.PATTERN.getName()); } /** - * Prepopulated pattern resources. - * + * Creates a new Pattern dictionary from the given COS dictionary. * @param resourceDictionary The COSDictionary for this pattern resource. */ - public PDPatternResources( COSDictionary resourceDictionary ) + public PDPatternDictionary(COSDictionary resourceDictionary) { patternDictionary = resourceDictionary; } /** * This will get the underlying dictionary. - * * @return The dictionary for these pattern resources. */ public COSDictionary getCOSDictionary() @@ -65,7 +90,6 @@ public abstract class PDPatternResources /** * Convert this standard java object to a COS object. - * * @return The cos object that matches this Java object. */ public COSBase getCOSObject() @@ -75,27 +99,24 @@ public abstract class PDPatternResources /** * Sets the filter entry of the encryption dictionary. - * * @param filter The filter name. */ public void setFilter(String filter) { - patternDictionary.setItem( COSName.FILTER, COSName.getPDFName( filter ) ); + patternDictionary.setItem(COSName.FILTER, COSName.getPDFName(filter)); } /** * Get the name of the filter. - * * @return The filter name contained in this encryption dictionary. */ public String getFilter() { - return patternDictionary.getNameAsString( COSName.FILTER ); + return patternDictionary.getNameAsString(COSName.FILTER); } /** * This will set the length of the content stream. - * * @param length The new stream length. */ public void setLength(int length) @@ -105,17 +126,15 @@ public abstract class PDPatternResources /** * This will return the length of the content stream. - * * @return The length of the content stream */ public int getLength() { - return patternDictionary.getInt( COSName.LENGTH, 0 ); + return patternDictionary.getInt(COSName.LENGTH, 0); } /** * This will set the paint type. - * * @param paintType The new paint type. */ public void setPaintType(int paintType) @@ -125,7 +144,6 @@ public abstract class PDPatternResources /** * This will return the paint type. - * * @return The type of object that this is. */ public String getType() @@ -135,7 +153,6 @@ public abstract class PDPatternResources /** * This will set the pattern type. - * * @param patternType The new pattern type. */ public void setPatternType(int patternType) @@ -145,35 +162,7 @@ public abstract class PDPatternResources /** * This will return the pattern type. - * * @return The pattern type */ public abstract int getPatternType(); - - /** - * Create the correct PD Model pattern based on the COS base pattern. - * - * @param resourceDictionary the COS pattern dictionary - * - * @return the newly created pattern resources object - * - * @throws IOException If we are unable to create the PDPattern object. - */ - public static PDPatternResources create(COSDictionary resourceDictionary) throws IOException - { - PDPatternResources pattern = null; - int patternType = resourceDictionary.getInt( COSName.PATTERN_TYPE, 0 ); - switch (patternType) - { - case TILING_PATTERN: - pattern = new PDTilingPatternResources(resourceDictionary); - break; - case SHADING_PATTERN: - pattern = new PDShadingPatternResources(resourceDictionary); - break; - default: - throw new IOException( "Error: Unknown pattern type " + patternType ); - } - return pattern; - } } Copied: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPattern.java (from r1571090, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPatternResources.java) URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPattern.java?p2=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPattern.java&p1=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPatternResources.java&r1=1571090&r2=1571482&rev=1571482&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPatternResources.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDShadingPattern.java Mon Feb 24 23:05:20 2014 @@ -29,45 +29,42 @@ import org.apache.pdfbox.pdmodel.graphic import org.apache.pdfbox.util.Matrix; /** - * This represents the resources for a shading pattern. - * + * A shading pattern dictionary. + * @author Andreas Lehmkühler */ -public class PDShadingPatternResources extends PDPatternResources +public class PDShadingPattern extends PDPatternDictionary { private PDExtendedGraphicsState extendedGraphicsState; private PDShadingResources shading; private COSArray matrix = null; /** - * Default constructor. + * Creates a new shading pattern. */ - public PDShadingPatternResources() + public PDShadingPattern() { super(); - getCOSDictionary().setInt(COSName.PATTERN_TYPE, PDPatternResources.SHADING_PATTERN); + getCOSDictionary().setInt(COSName.PATTERN_TYPE, PDPatternDictionary.TYPE_SHADING_PATTERN); } /** - * Prepopulated pattern resources. - * + * Creates a new shading pattern from the given COS dictionary. * @param resourceDictionary The COSDictionary for this pattern resource. */ - public PDShadingPatternResources( COSDictionary resourceDictionary ) + public PDShadingPattern(COSDictionary resourceDictionary) { super(resourceDictionary); } - /** - * {@inheritDoc} - */ + @Override public int getPatternType() { - return PDPatternResources.SHADING_PATTERN; + return PDPatternDictionary.TYPE_SHADING_PATTERN; } /** * This will get the optional Matrix of a Pattern. - * It maps the form space into the user space + * It maps the form space into the user space. * @return the form matrix */ public Matrix getMatrix() @@ -108,7 +105,6 @@ public class PDShadingPatternResources e /** * This will get the extended graphics state for this pattern. - * * @return The extended graphics state for this pattern. */ public PDExtendedGraphicsState getExtendedGraphicsState() @@ -126,7 +122,6 @@ public class PDShadingPatternResources e /** * This will set the extended graphics state for this pattern. - * * @param extendedGraphicsState The new extended graphics state for this pattern. */ public void setExtendedGraphicsState( PDExtendedGraphicsState extendedGraphicsState ) @@ -144,9 +139,7 @@ public class PDShadingPatternResources e /** * This will get the shading resources for this pattern. - * - * @return The shading resourcesfor this pattern. - * + * @return The shading resources for this pattern. * @throws IOException if something went wrong */ public PDShadingResources getShading() throws IOException @@ -164,7 +157,6 @@ public class PDShadingPatternResources e /** * This will set the shading resources for this pattern. - * * @param shadingResources The new shading resources for this pattern. */ public void setShading( PDShadingResources shadingResources ) Copied: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDTilingPattern.java (from r1571090, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDTilingPatternResources.java) URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDTilingPattern.java?p2=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDTilingPattern.java&p1=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDTilingPatternResources.java&r1=1571090&r2=1571482&rev=1571482&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDTilingPatternResources.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/PDTilingPattern.java Mon Feb 24 23:05:20 2014 @@ -28,62 +28,52 @@ import org.apache.pdfbox.pdmodel.common. import org.apache.pdfbox.util.Matrix; /** - * This represents the resources for a tiling pattern. + * A tiling pattern dictionary. + * @author Andreas Lehmkühler */ -public class PDTilingPatternResources extends PDPatternResources +public class PDTilingPattern extends PDPatternDictionary { - /** - * paint type 1 = colored tiling pattern. - */ - public static final int COLORED_TILING_PATTERN = 1; - /** - * paint type 2 = uncolored tiling pattern. - */ - public static final int UNCOLORED_TILING_PATTERN = 2; + /** paint type 1 = colored tiling pattern. */ + public static final int PAINT_COLORED = 1; - /** - * tiling type 1 = constant spacing. - */ + /** paint type 2 = uncolored tiling pattern. */ + public static final int PAINT_UNCOLORED = 2; + + /** tiling type 1 = constant spacing.*/ public static final int TILING_CONSTANT_SPACING = 1; - /** - * tiling type 2 = no distortion. - */ + + /** tiling type 2 = no distortion. */ public static final int TILING_NO_DISTORTION = 2; - /** - * tiling type 3 = constant spacing and faster tiling. - */ + + /** tiling type 3 = constant spacing and faster tiling. */ public static final int TILING_CONSTANT_SPACING_FASTER_TILING = 3; /** - * Default constructor. + * Creates a new tiling pattern. */ - public PDTilingPatternResources() + public PDTilingPattern() { super(); - getCOSDictionary().setInt(COSName.PATTERN_TYPE, PDPatternResources.TILING_PATTERN); + getCOSDictionary().setInt(COSName.PATTERN_TYPE, PDPatternDictionary.TYPE_TILING_PATTERN); } /** - * Prepopulated pattern resources. - * + * Creates a new tiling pattern from the given COS dictionary. * @param resourceDictionary The COSDictionary for this pattern resource. */ - public PDTilingPatternResources( COSDictionary resourceDictionary ) + public PDTilingPattern(COSDictionary resourceDictionary) { super(resourceDictionary); } - /** - * {@inheritDoc} - */ + @Override public int getPatternType() { - return PDPatternResources.TILING_PATTERN; + return PDPatternDictionary.TYPE_TILING_PATTERN; } /** * This will set the length of the content stream. - * * @param length The new stream length. */ public void setLength(int length) @@ -93,7 +83,6 @@ public class PDTilingPatternResources ex /** * This will return the length of the content stream. - * * @return The length of the content stream */ public int getLength() @@ -103,7 +92,6 @@ public class PDTilingPatternResources ex /** * This will set the paint type. - * * @param paintType The new paint type. */ public void setPaintType(int paintType) @@ -113,7 +101,6 @@ public class PDTilingPatternResources ex /** * This will return the paint type. - * * @return The paint type */ public int getPaintType() @@ -123,7 +110,6 @@ public class PDTilingPatternResources ex /** * This will set the tiling type. - * * @param tilingType The new tiling type. */ public void setTilingType(int tilingType) @@ -133,7 +119,6 @@ public class PDTilingPatternResources ex /** * This will return the tiling type. - * * @return The tiling type */ public int getTilingType() @@ -143,7 +128,6 @@ public class PDTilingPatternResources ex /** * This will set the XStep value. - * * @param xStep The new XStep value. */ public void setXStep(int xStep) @@ -153,7 +137,6 @@ public class PDTilingPatternResources ex /** * This will return the XStep value. - * * @return The XStep value */ public int getXStep() @@ -163,7 +146,6 @@ public class PDTilingPatternResources ex /** * This will set the YStep value. - * * @param yStep The new YStep value. */ public void setYStep(int yStep) @@ -173,7 +155,6 @@ public class PDTilingPatternResources ex /** * This will return the YStep value. - * * @return The YStep value */ public int getYStep() @@ -184,13 +165,13 @@ public class PDTilingPatternResources ex /** * This will get the resources for this pattern. * This will return null if no resources are available at this level. - * * @return The resources for this pattern. */ public PDResources getResources() { PDResources retval = null; - COSDictionary resources = (COSDictionary)getCOSDictionary().getDictionaryObject( COSName.RESOURCES ); + COSDictionary resources = (COSDictionary)getCOSDictionary() + .getDictionaryObject( COSName.RESOURCES ); if( resources != null ) { retval = new PDResources( resources ); @@ -200,7 +181,6 @@ public class PDTilingPatternResources ex /** * This will set the resources for this pattern. - * * @param resources The new resources for this pattern. */ public void setResources( PDResources resources ) @@ -235,7 +215,6 @@ public class PDTilingPatternResources ex /** * This will set the BBox (bounding box) for this Pattern. - * * @param bbox The new BBox for this Pattern. */ public void setBBox(PDRectangle bbox) @@ -252,24 +231,24 @@ public class PDTilingPatternResources ex /** * This will get the optional Matrix of a Pattern. - * It maps the form space into the user space + * It maps the form space into the user space. * @return the form matrix */ public Matrix getMatrix() { - Matrix retval = null; - COSArray array = (COSArray)getCOSDictionary().getDictionaryObject( COSName.MATRIX ); - if( array != null ) - { - retval = new Matrix(); - retval.setValue(0, 0, ((COSNumber) array.get(0)).floatValue()); - retval.setValue(0, 1, ((COSNumber) array.get(1)).floatValue()); - retval.setValue(1, 0, ((COSNumber) array.get(2)).floatValue()); - retval.setValue(1, 1, ((COSNumber) array.get(3)).floatValue()); - retval.setValue(2, 0, ((COSNumber) array.get(4)).floatValue()); - retval.setValue(2, 1, ((COSNumber) array.get(5)).floatValue()); + Matrix matrix = null; + COSArray array = (COSArray)getCOSDictionary().getDictionaryObject(COSName.MATRIX); + if (array != null) + { + matrix = new Matrix(); + matrix.setValue(0, 0, ((COSNumber) array.get(0)).floatValue()); + matrix.setValue(0, 1, ((COSNumber) array.get(1)).floatValue()); + matrix.setValue(1, 0, ((COSNumber) array.get(2)).floatValue()); + matrix.setValue(1, 1, ((COSNumber) array.get(3)).floatValue()); + matrix.setValue(2, 0, ((COSNumber) array.get(4)).floatValue()); + matrix.setValue(2, 1, ((COSNumber) array.get(5)).floatValue()); } - return retval; + return matrix; } /** Copied: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/tiling/TilingPaint.java (from r1571090, pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/tiling/ColoredTilingPaint.java) URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/tiling/TilingPaint.java?p2=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/tiling/TilingPaint.java&p1=pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/tiling/ColoredTilingPaint.java&r1=1571090&r2=1571482&rev=1571482&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/tiling/ColoredTilingPaint.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/pattern/tiling/TilingPaint.java Mon Feb 24 23:05:20 2014 @@ -16,15 +16,12 @@ */ package org.apache.pdfbox.pdmodel.graphics.pattern.tiling; -import java.awt.Paint; -import java.awt.PaintContext; +import java.awt.Graphics2D; import java.awt.Rectangle; -import java.awt.RenderingHints; +import java.awt.TexturePaint; import java.awt.Transparency; import java.awt.color.ColorSpace; import java.awt.geom.AffineTransform; -import java.awt.geom.Rectangle2D; -import java.awt.image.AffineTransformOp; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.ComponentColorModel; @@ -32,111 +29,88 @@ import java.awt.image.DataBuffer; import java.awt.image.WritableRaster; import java.io.IOException; -import org.apache.pdfbox.cos.COSStream; import org.apache.pdfbox.pdfviewer.PageDrawer; import org.apache.pdfbox.pdmodel.common.PDRectangle; -import org.apache.pdfbox.pdmodel.graphics.pattern.PDTilingPatternResources; +import org.apache.pdfbox.pdmodel.graphics.color.PDColor; +import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace; +import org.apache.pdfbox.pdmodel.graphics.pattern.PDTilingPattern; import org.apache.pdfbox.util.Matrix; /** - * This represents the Paint of an axial shading. - * + * AWT Paint for a tiling pattern, which consists of a small repeating graphical figure. + * @author Andreas Lehmkühler + * @author John Hewson */ -public class ColoredTilingPaint implements Paint +public class TilingPaint extends TexturePaint { - private PDTilingPatternResources patternResources; - private ColorModel outputColorModel; - /** - * Constructor. - * - * @param resources tiling pattern resources - * + * Creates a new colored tiling Paint. + * @param pattern tiling pattern dictionary */ - public ColoredTilingPaint(PDTilingPatternResources resources) + public TilingPaint(PDTilingPattern pattern) throws IOException { - patternResources = resources; + super(getTilingImage(pattern, null ,null), getTransformedRect(pattern)); } /** - * {@inheritDoc} + * Creates a new uncolored tiling Paint. + * @param pattern tiling pattern dictionary + * @param colorSpace color space for this tiling + * @param color color for this tiling */ - public int getTransparency() + public TilingPaint(PDTilingPattern pattern, PDColorSpace colorSpace, PDColor color) + throws IOException { - return Transparency.TRANSLUCENT; + super(getTilingImage(pattern, colorSpace, color), getTransformedRect(pattern)); } - /** - * {@inheritDoc} - */ - public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, - AffineTransform xform, RenderingHints hints) + // gets rect in parent content stream coordinates + private static Rectangle getTransformedRect(PDTilingPattern pattern) { - // get the pattern matrix - Matrix patternMatrix = patternResources.getMatrix(); - AffineTransform patternAT = patternMatrix != null ? patternMatrix.createAffineTransform() : null; - - // get the bounding box - PDRectangle box = patternResources.getBBox(); - Rectangle2D rect = new Rectangle((int) box.getLowerLeftX(), (int) box.getLowerLeftY(), - (int) box.getWidth(), (int) box.getHeight()); - - rect = xform.createTransformedShape(rect).getBounds2D(); - int width = (int) rect.getWidth(); - int height = (int) rect.getHeight(); - - if (patternAT != null) - { - rect = patternAT.createTransformedShape(rect).getBounds2D(); - } - PDRectangle bBox = new PDRectangle((float) rect.getMinX(), (float) rect.getMinY(), (float) rect.getMaxX(), - (float) rect.getMaxY()); - - // xStep + yStep - double[] steps = new double[] { patternResources.getXStep(), patternResources.getYStep() }; - xform.deltaTransform(steps, 0, steps, 0, 1); - if (patternAT != null) - { - patternAT.deltaTransform(steps, 0, steps, 0, 1); - } - int xStep = (int) (steps[0]); - int yStep = (int) (steps[1]); + AffineTransform at = pattern.getMatrix().createAffineTransform(); + Rectangle rect = new Rectangle(pattern.getBBox().createDimension()); + return at.createTransformedShape(rect).getBounds(); + } + // gets image in parent stream coordinates + private static BufferedImage getTilingImage(PDTilingPattern pattern, PDColorSpace colorSpace, + PDColor color) throws IOException + { ColorSpace outputCS = ColorSpace.getInstance(ColorSpace.CS_sRGB); - outputColorModel = new ComponentColorModel(outputCS, true, false, Transparency.TRANSLUCENT, - DataBuffer.TYPE_BYTE); - WritableRaster raster = outputColorModel.createCompatibleWritableRaster(width, height); - - BufferedImage image = new BufferedImage(outputColorModel, raster, false, null); - BufferedImage tilingImage = null; - try - { - PageDrawer drawer = new PageDrawer(); - drawer.drawStream(image.getGraphics(), (COSStream) patternResources.getCOSObject(), - patternResources.getResources(), box); - drawer.dispose(); - } - catch (IOException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - AffineTransform imageTransform = null; - if (patternAT != null && !patternAT.isIdentity()) - { - // get the scaling factor for each dimension - imageTransform = AffineTransform.getScaleInstance(patternMatrix.getXScale(), patternMatrix.getYScale()); - } - else - { - imageTransform = new AffineTransform(); - } - imageTransform.scale(1.0, -1.0); - imageTransform.translate(0, -height); - AffineTransformOp scaleOP = new AffineTransformOp(imageTransform, AffineTransformOp.TYPE_BILINEAR); - tilingImage = scaleOP.filter(image, null); + ColorModel cm = new ComponentColorModel(outputCS, true, false, + Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); + + Rectangle rect = getTransformedRect(pattern); + + // create raster + WritableRaster raster = cm.createCompatibleWritableRaster((int)rect.getWidth(), + (int)rect.getHeight()); + BufferedImage image = new BufferedImage(cm, raster, false, null); + + // TODO xStep and yStep - return new ColoredTilingContext(outputColorModel, tilingImage.getData(), xStep, yStep, bBox); + // undo translation + Matrix matrix = (Matrix)pattern.getMatrix().clone(); + matrix.setValue(2, 0, matrix.getValue(2, 0) - (float)rect.getX()); // tx + matrix.setValue(2, 1, matrix.getValue(2, 1) - (float)rect.getY()); // ty + + int width = (int)rect.getWidth(); + int height = (int)rect.getHeight(); + + PageDrawer drawer = new PageDrawer(); + PDRectangle pdRect = new PDRectangle(0, 0, width, height); + + Graphics2D graphics = image.createGraphics(); + drawer.drawTilingPattern(graphics, pattern, pdRect, matrix, colorSpace, color); + drawer.dispose(); + graphics.dispose(); + + return image; + } + + @Override + public int getTransparency() + { + return Transparency.TRANSLUCENT; } } Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java?rev=1571482&r1=1571481&r2=1571482&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/util/PDFStreamEngine.java Mon Feb 24 23:05:20 2014 @@ -57,10 +57,6 @@ import org.apache.pdfbox.util.operator.O */ public class PDFStreamEngine { - - /** - * Log instance. - */ private static final Log LOG = LogFactory.getLog(PDFStreamEngine.class); /** @@ -187,17 +183,12 @@ public class PDFStreamEngine } /** - * This will process the contents of the stream. - * - * @param resources The location to retrieve resources. - * @param cosStream the Stream to execute. + * Initialises a stream for processing. + * * @param drawingSize the size of the page * @param rotation the page rotation - * - * @throws IOException if there is an error accessing the stream. */ - public void processStream(PDResources resources, COSStream cosStream, PDRectangle drawingSize, int rotation) - throws IOException + protected void initStream(PDRectangle drawingSize, int rotation) { drawingRectangle = drawingSize; pageRotation = rotation; @@ -206,6 +197,22 @@ public class PDFStreamEngine textLineMatrix = null; graphicsStack.clear(); streamResourcesStack.clear(); + } + + /** + * This will initialise and process the contents of the stream. + * + * @param resources The location to retrieve resources. + * @param cosStream the Stream to execute. + * @param drawingSize the size of the page + * @param rotation the page rotation + * + * @throws IOException if there is an error accessing the stream. + */ + public void processStream(PDResources resources, COSStream cosStream, PDRectangle drawingSize, int rotation) + throws IOException + { + initStream(drawingSize, rotation); processSubStream(resources, cosStream); } Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java?rev=1571482&r1=1571481&r2=1571482&view=diff ============================================================================== --- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java (original) +++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/ResourcesValidationProcess.java Mon Feb 24 23:05:20 2014 @@ -40,8 +40,8 @@ import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.cos.COSStream; import org.apache.pdfbox.pdmodel.PDResources; import org.apache.pdfbox.pdmodel.font.PDFont; -import org.apache.pdfbox.pdmodel.graphics.pattern.PDPatternResources; -import org.apache.pdfbox.pdmodel.graphics.pattern.PDTilingPatternResources; +import org.apache.pdfbox.pdmodel.graphics.pattern.PDPatternDictionary; +import org.apache.pdfbox.pdmodel.graphics.pattern.PDTilingPattern; import org.apache.pdfbox.pdmodel.graphics.shading.PDShadingResources; import org.apache.pdfbox.pdmodel.graphics.PDXObject; import org.apache.pdfbox.preflight.PreflightConstants; @@ -152,12 +152,12 @@ public class ResourcesValidationProcess { try { - Map<String, PDPatternResources> patternResources = resources.getPatterns(); + Map<String, PDPatternDictionary> patternResources = resources.getPatterns(); if (patternResources != null) { - for (Entry<String, PDPatternResources> entry : patternResources.entrySet()) + for (Entry<String, PDPatternDictionary> entry : patternResources.entrySet()) { - if (entry.getValue() instanceof PDTilingPatternResources) + if (entry.getValue() instanceof PDTilingPattern) { ContextHelper.validateElement(context, entry.getValue(), TILING_PATTERN_PROCESS); } Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/TilingPatternValidationProcess.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/TilingPatternValidationProcess.java?rev=1571482&r1=1571481&r2=1571482&view=diff ============================================================================== --- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/TilingPatternValidationProcess.java (original) +++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/process/reflect/TilingPatternValidationProcess.java Mon Feb 24 23:05:20 2014 @@ -29,7 +29,7 @@ import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.cos.COSStream; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.PDResources; -import org.apache.pdfbox.pdmodel.graphics.pattern.PDTilingPatternResources; +import org.apache.pdfbox.pdmodel.graphics.pattern.PDTilingPattern; import org.apache.pdfbox.preflight.PreflightConstants; import org.apache.pdfbox.preflight.PreflightContext; import org.apache.pdfbox.preflight.PreflightPath; @@ -48,13 +48,13 @@ public class TilingPatternValidationProc if (vPath.isEmpty()) { return; } - else if (!vPath.isExpectedType(PDTilingPatternResources.class)) + else if (!vPath.isExpectedType(PDTilingPattern.class)) { context.addValidationError(new ValidationError(PreflightConstants.ERROR_GRAPHIC_MISSING_OBJECT, "Tiling pattern validation required at least a PDPage")); } else { - PDTilingPatternResources tilingPattern = (PDTilingPatternResources) vPath.peek(); + PDTilingPattern tilingPattern = (PDTilingPattern) vPath.peek(); PDPage page = vPath.getClosestPathElement(PDPage.class); checkMandatoryFields(context, page, tilingPattern); @@ -63,7 +63,7 @@ public class TilingPatternValidationProc } } - protected void parseResources(PreflightContext context, PDPage page, PDTilingPatternResources pattern) + protected void parseResources(PreflightContext context, PDPage page, PDTilingPattern pattern) throws ValidationException { PDResources resources = pattern.getResources(); @@ -76,7 +76,7 @@ public class TilingPatternValidationProc /** * Validate the Pattern content like Color and Show Text Operators using an instance of ContentStreamWrapper. */ - protected void parsePatternContent(PreflightContext context, PDPage page, PDTilingPatternResources pattern) + protected void parsePatternContent(PreflightContext context, PDPage page, PDTilingPattern pattern) throws ValidationException { ContentStreamWrapper csWrapper = new ContentStreamWrapper(context, page); @@ -86,7 +86,7 @@ public class TilingPatternValidationProc /** * This method checks if required fields are present. */ - protected void checkMandatoryFields(PreflightContext context, PDPage page, PDTilingPatternResources pattern) + protected void checkMandatoryFields(PreflightContext context, PDPage page, PDTilingPattern pattern) { COSDictionary dictionary = pattern.getCOSDictionary(); boolean res = dictionary.getItem(COSName.RESOURCES) != null;