/** * This method check the Shading entry of the resource dictionary if exists. * * @param context * @param resources * @throws ValidationException */ protected void validateShadingPattern(PreflightContext context, PDResources resources) throws ValidationException { try { for (COSName name : resources.getShadingNames()) { PDShading shading = resources.getShading(name); ContextHelper.validateElement(context, shading, SHADING_PATTERN_PROCESS); } } catch (IOException e) { context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID_PATTERN_DEFINITION, e.getMessage(), e)); } }
@Override public void shadingFill(COSName shadingName) throws IOException PDShading shading = getResources().getShading(shadingName); if (shading == null)
/** * This method check the Shading entry of the resource dictionary if exists. * * @param context * @param resources * @throws ValidationException */ protected void validateShadingPattern(PreflightContext context, PDResources resources) throws ValidationException { try { for (COSName name : resources.getShadingNames()) { PDShading shading = resources.getShading(name); ContextHelper.validateElement(context, shading, SHADING_PATTERN_PROCESS); } } catch (IOException e) { context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID_PATTERN_DEFINITION, e.getMessage(), e)); } }
public PDShading getShading(COSName name) throws IOException { PDShading shading = this.currentResources.getShading(name); if (shading != null) { return shading; } shading = this.inheritedResources.getShading(name); if (shading != null) { shading.setInherited(true); return shading; } return null; }
/** * This method check the Shading entry of the resource dictionary if exists. * * @param context * @param resources * @throws ValidationException */ protected void validateShadingPattern(PreflightContext context, PDResources resources) throws ValidationException { try { for (COSName name : resources.getShadingNames()) { PDShading shading = resources.getShading(name); ContextHelper.validateElement(context, shading, SHADING_PATTERN_PROCESS); } } catch (IOException e) { context.addValidationError(new ValidationError(ERROR_GRAPHIC_INVALID_PATTERN_DEFINITION, e.getMessage(), e)); } }
@Override public void shadingFill(COSName shadingName) throws IOException { PDShading shading = getResources().getShading(shadingName); if (shading == null) { LOG.error("shading " + shadingName + " does not exist in resources dictionary"); return; } Matrix ctm = getGraphicsState().getCurrentTransformationMatrix(); Paint paint = shading.toPaint(ctm); paint = applySoftMaskToPaint(paint, getGraphicsState().getSoftMask()); graphics.setComposite(getGraphicsState().getNonStrokingJavaComposite()); graphics.setPaint(paint); graphics.setClip(null); lastClip = null; // get the transformed BBox and intersect with current clipping path // need to do it here and not in shading getRaster() because it may have been rotated PDRectangle bbox = shading.getBBox(); if (bbox != null) { Area bboxArea = new Area(bbox.transform(ctm)); bboxArea.intersect(getGraphicsState().getCurrentClippingPath()); graphics.fill(bboxArea); } else { graphics.fill(getGraphicsState().getCurrentClippingPath()); } }
private Set<String> parseShadingFromResource(PDResources resources) { if (resources == null || resources.getShadingNames() == null) { return null; } Set<String> shadingIDs = new HashSet<>(); for (COSName name : resources.getShadingNames()) { COSDictionary dict = (COSDictionary) resources.getCOSObject().getDictionaryObject(COSName.SHADING); COSBase base = dict.getItem(name); String id = getId(base, FeatureObjectType.SHADING); shadingIDs.add(id); if (checkIDBeforeProcess(id)) { try { PDShading shading = resources.getShading(name); parseShading(shading, id); } catch (IOException e) { LOGGER.info(e); shadingCreationProblem(id, e.getMessage()); } } } return shadingIDs; }
@Override public void shadingFill(COSName shadingName) throws IOException { PDShading shading = getResources().getShading(shadingName); if (shading == null) { LOG.error("shading " + shadingName + " does not exist in resources dictionary"); return; } Matrix ctm = getGraphicsState().getCurrentTransformationMatrix(); Paint paint = shading.toPaint(ctm); paint = applySoftMaskToPaint(paint, getGraphicsState().getSoftMask()); graphics.setComposite(getGraphicsState().getNonStrokingJavaComposite()); graphics.setPaint(paint); graphics.setClip(null); lastClip = null; // get the transformed BBox and intersect with current clipping path // need to do it here and not in shading getRaster() because it may have been rotated PDRectangle bbox = shading.getBBox(); if (bbox != null) { Area bboxArea = new Area(bbox.transform(ctm)); bboxArea.intersect(getGraphicsState().getCurrentClippingPath()); graphics.fill(bboxArea); } else { graphics.fill(getGraphicsState().getCurrentClippingPath()); } }