public virtual ColorDetails[] GetColorantDetails(PdfWriter writer) { if (altColorDetails == null && this.altcs is ExtendedColor && ((ExtendedColor) this.altcs).Type == ExtendedColor.TYPE_LAB) { altColorDetails = writer.AddSimple(((LabColor) altcs).LabColorSpace); } return new ColorDetails[] {altColorDetails}; }
public virtual ColorDetails[] GetColorantDetails(PdfWriter writer) { if (altColorDetails == null && this.altcs is ExtendedColor && ((ExtendedColor)this.altcs).Type == ExtendedColor.TYPE_LAB) { altColorDetails = writer.AddSimple(((LabColor)altcs).LabColorSpace); } return(new ColorDetails[] { altColorDetails }); }
public override void paintShading(PdfShading shading) { writer.addSimpleShading(shading); shadingDictionary.put(shading.ShadingName, shading.ShadingReference); content.Append(shading.ShadingName.toPdf(null)).Append(" sh").Append_i(separator); ColorDetails details = shading.ColorDetails; if (details != null) { colorDictionary.put(details.ColorName, details.IndirectReference); } }
public override void setPatternStroke(PdfPatternPainter p, Color color, float tint) { checkWriter(); if (!p.isStencil()) { throw new RuntimeException("An uncolored pattern was expected."); } PdfName name = writer.addSimplePattern(p); patternDictionary.put(name, p.IndirectReference); ColorDetails csDetail = writer.addSimplePatternColorspace(color); colorDictionary.put(csDetail.ColorName, csDetail.IndirectReference); content.Append(csDetail.ColorName.toPdf(null)).Append(" CS").Append_i(separator); outputColorNumbers(color, tint); content.Append(' ').Append(name.toPdf(null)).Append(" SCN").Append_i(separator); }
virtual protected void SetColorSpace(BaseColor color) { cspace = color; int type = ExtendedColor.GetType(color); PdfObject colorSpace = null; switch (type) { case ExtendedColor.TYPE_GRAY: { colorSpace = PdfName.DEVICEGRAY; break; } case ExtendedColor.TYPE_CMYK: { colorSpace = PdfName.DEVICECMYK; break; } case ExtendedColor.TYPE_SEPARATION: { SpotColor spot = (SpotColor)color; colorDetails = writer.AddSimple(spot.PdfSpotColor); colorSpace = colorDetails.IndirectReference; break; } case ExtendedColor.TYPE_DEVICEN: { DeviceNColor deviceNColor = (DeviceNColor)color; colorDetails = writer.AddSimple(deviceNColor.PdfDeviceNColor); colorSpace = colorDetails.IndirectReference; break; } case ExtendedColor.TYPE_PATTERN: case ExtendedColor.TYPE_SHADING: { ThrowColorSpaceError(); break; } default: colorSpace = PdfName.DEVICERGB; break; } shading.Put(PdfName.COLORSPACE, colorSpace); }
protected void SetColorSpace(BaseColor color) { ColorSpace = color; int type = ExtendedColor.GetType(color); PdfObject colorSpace = null; switch (type) { case ExtendedColor.TYPE_GRAY: { colorSpace = PdfName.Devicegray; break; } case ExtendedColor.TYPE_CMYK: { colorSpace = PdfName.Devicecmyk; break; } case ExtendedColor.TYPE_SEPARATION: { SpotColor spot = (SpotColor)color; colorDetails = writer.AddSimple(spot.PdfSpotColor); colorSpace = colorDetails.IndirectReference; break; } case ExtendedColor.TYPE_PATTERN: case ExtendedColor.TYPE_SHADING: { ThrowColorSpaceError(); break; } default: colorSpace = PdfName.Devicergb; break; } Shading.Put(PdfName.Colorspace, colorSpace); }
protected void setColorSpace(Color color) { int type = ExtendedColor.getType(color); PdfObject colorSpace = null; switch (type) { case ExtendedColor.TYPE_GRAY: { colorSpace = PdfName.DEVICEGRAY; break; } case ExtendedColor.TYPE_CMYK: { colorSpace = PdfName.DEVICECMYK; break; } case ExtendedColor.TYPE_SEPARATION: { SpotColor spot = (SpotColor)color; colorDetails = writer.addSimple(spot.getPdfSpotColor()); colorSpace = colorDetails.IndirectReference; break; } case ExtendedColor.TYPE_PATTERN: case ExtendedColor.TYPE_SHADING: { throwColorSpaceError(); break; } default: colorSpace = PdfName.DEVICERGB; break; } shading.put(PdfName.COLORSPACE, colorSpace); }
internal ColorDetails AddSimplePatternColorspace(BaseColor color) { int type = ExtendedColor.GetType(color); if (type == ExtendedColor.TYPE_PATTERN || type == ExtendedColor.TYPE_SHADING) throw new Exception(MessageLocalization.GetComposedMessage("an.uncolored.tile.pattern.can.not.have.another.pattern.or.shading.as.color")); switch (type) { case ExtendedColor.TYPE_RGB: if (patternColorspaceRGB == null) { patternColorspaceRGB = new ColorDetails(GetColorspaceName(), body.PdfIndirectReference, null); PdfArray array = new PdfArray(PdfName.PATTERN); array.Add(PdfName.DEVICERGB); AddToBody(array, patternColorspaceRGB.IndirectReference); } return patternColorspaceRGB; case ExtendedColor.TYPE_CMYK: if (patternColorspaceCMYK == null) { patternColorspaceCMYK = new ColorDetails(GetColorspaceName(), body.PdfIndirectReference, null); PdfArray array = new PdfArray(PdfName.PATTERN); array.Add(PdfName.DEVICECMYK); AddToBody(array, patternColorspaceCMYK.IndirectReference); } return patternColorspaceCMYK; case ExtendedColor.TYPE_GRAY: if (patternColorspaceGRAY == null) { patternColorspaceGRAY = new ColorDetails(GetColorspaceName(), body.PdfIndirectReference, null); PdfArray array = new PdfArray(PdfName.PATTERN); array.Add(PdfName.DEVICEGRAY); AddToBody(array, patternColorspaceGRAY.IndirectReference); } return patternColorspaceGRAY; case ExtendedColor.TYPE_SEPARATION: { ColorDetails details = AddSimple(((SpotColor)color).PdfSpotColor); ColorDetails patternDetails; documentSpotPatterns.TryGetValue(details, out patternDetails); if (patternDetails == null) { patternDetails = new ColorDetails(GetColorspaceName(), body.PdfIndirectReference, null); PdfArray array = new PdfArray(PdfName.PATTERN); array.Add(details.IndirectReference); AddToBody(array, patternDetails.IndirectReference); documentSpotPatterns[details] = patternDetails; } return patternDetails; } default: throw new Exception(MessageLocalization.GetComposedMessage("invalid.color.type")); } }
/** * Adds a <CODE>SpotColor</CODE> to the document but not to the page resources. * @param spc the <CODE>SpotColor</CODE> to add * @return an <CODE>Object[]</CODE> where position 0 is a <CODE>PdfName</CODE> * and position 1 is an <CODE>PdfIndirectReference</CODE> */ internal ColorDetails AddSimple(PdfSpotColor spc) { ColorDetails ret; documentColors.TryGetValue(spc, out ret); if (ret == null) { ret = new ColorDetails(GetColorspaceName(), body.PdfIndirectReference, spc); documentColors[spc] = ret; } return ret; }
internal GraphicState(GraphicState cp) { fontDetails = cp.fontDetails; colorDetails = cp.colorDetails; size = cp.size; xTLM = cp.xTLM; yTLM = cp.yTLM; aTLM = cp.aTLM; bTLM = cp.bTLM; cTLM = cp.cTLM; dTLM = cp.dTLM; tx = cp.tx; leading = cp.leading; scale = cp.scale; charSpace = cp.charSpace; wordSpace = cp.wordSpace; }
internal void CopyParameters(GraphicState cp) { fontDetails = cp.fontDetails; colorDetails = cp.colorDetails; size = cp.size; xTLM = cp.xTLM; yTLM = cp.yTLM; aTLM = cp.aTLM; bTLM = cp.bTLM; cTLM = cp.cTLM; dTLM = cp.dTLM; tx = cp.tx; leading = cp.leading; scale = cp.scale; charSpace = cp.charSpace; wordSpace = cp.wordSpace; textColorFill = cp.textColorFill; colorFill = cp.colorFill; textColorStroke = cp.textColorStroke; colorStroke = cp.colorStroke; CTM = (AffineTransform)cp.CTM.Clone(); textRenderMode = cp.textRenderMode; extGState = cp.extGState; }
protected void SetColorSpace(BaseColor color) { cspace = color; int type = ExtendedColor.GetType(color); PdfObject colorSpace = null; switch (type) { case ExtendedColor.TYPE_GRAY: { colorSpace = PdfName.DEVICEGRAY; break; } case ExtendedColor.TYPE_CMYK: { colorSpace = PdfName.DEVICECMYK; break; } case ExtendedColor.TYPE_SEPARATION: { SpotColor spot = (SpotColor)color; colorDetails = writer.AddSimple(spot.PdfSpotColor); colorSpace = colorDetails.IndirectReference; break; } case ExtendedColor.TYPE_PATTERN: case ExtendedColor.TYPE_SHADING: { ThrowColorSpaceError(); break; } default: colorSpace = PdfName.DEVICERGB; break; } shading.Put(PdfName.COLORSPACE, colorSpace); }
internal ColorDetails AddSimplePatternColorspace(Color color) { int type = ExtendedColor.GetType(color); if (type == ExtendedColor.TYPE_PATTERN || type == ExtendedColor.TYPE_SHADING) throw new Exception("An uncolored tile pattern can not have another pattern or shading as color."); switch (type) { case ExtendedColor.TYPE_RGB: if (patternColorspaceRGB == null) { patternColorspaceRGB = new ColorDetails(GetColorspaceName(), body.PdfIndirectReference, null); PdfArray array = new PdfArray(PdfName.PATTERN); array.Add(PdfName.DEVICERGB); AddToBody(array, patternColorspaceRGB.IndirectReference); } return patternColorspaceRGB; case ExtendedColor.TYPE_CMYK: if (patternColorspaceCMYK == null) { patternColorspaceCMYK = new ColorDetails(GetColorspaceName(), body.PdfIndirectReference, null); PdfArray array = new PdfArray(PdfName.PATTERN); array.Add(PdfName.DEVICECMYK); AddToBody(array, patternColorspaceCMYK.IndirectReference); } return patternColorspaceCMYK; case ExtendedColor.TYPE_GRAY: if (patternColorspaceGRAY == null) { patternColorspaceGRAY = new ColorDetails(GetColorspaceName(), body.PdfIndirectReference, null); PdfArray array = new PdfArray(PdfName.PATTERN); array.Add(PdfName.DEVICEGRAY); AddToBody(array, patternColorspaceGRAY.IndirectReference); } return patternColorspaceGRAY; case ExtendedColor.TYPE_SEPARATION: { ColorDetails details = AddSimple(((SpotColor)color).PdfSpotColor); ColorDetails patternDetails = (ColorDetails)documentSpotPatterns[details]; if (patternDetails == null) { patternDetails = new ColorDetails(GetColorspaceName(), body.PdfIndirectReference, null); PdfArray array = new PdfArray(PdfName.PATTERN); array.Add(details.IndirectReference); AddToBody(array, patternDetails.IndirectReference); documentSpotPatterns[details] = patternDetails; } return patternDetails; } default: throw new Exception("Invalid color type in PdfWriter.AddSimplePatternColorspace()."); } }
/** * Adds a <CODE>SpotColor</CODE> to the document but not to the page resources. * @param spc the <CODE>SpotColor</CODE> to add * @return an <CODE>Object[]</CODE> where position 0 is a <CODE>PdfName</CODE> * and position 1 is an <CODE>PdfIndirectReference</CODE> */ internal virtual ColorDetails AddSimple(ICachedColorSpace spc) { ColorDetails ret; documentColors.TryGetValue(spc, out ret); if (ret == null) { ret = new ColorDetails(GetColorspaceName(), body.PdfIndirectReference, spc); if (spc is IPdfSpecialColorSpace) { ((IPdfSpecialColorSpace)spc).GetColorantDetails(this); } documentColors[spc] = ret; } return ret; }
internal void CopyParameters(GraphicState cp) { fontDetails = cp.fontDetails; colorDetails = cp.colorDetails; size = cp.size; xTLM = cp.xTLM; yTLM = cp.yTLM; aTLM = cp.aTLM; bTLM = cp.bTLM; cTLM = cp.cTLM; dTLM = cp.dTLM; tx = cp.tx; leading = cp.leading; scale = cp.scale; charSpace = cp.charSpace; wordSpace = cp.wordSpace; textColorFill = cp.textColorFill; graphicsColorFill = cp.graphicsColorFill; textColorStroke = cp.textColorStroke; graphicsColorStroke = cp.graphicsColorStroke; CTM = cp.CTM.Clone(); }