Example #1
0
 public SpotColor(PdfSpotColor spot, float tint) : 
     base(TYPE_SEPARATION,
         ((float)spot.AlternativeCS.R / 255f - 1f) * tint + 1,
         ((float)spot.AlternativeCS.G / 255f - 1f) * tint + 1,
         ((float)spot.AlternativeCS.B / 255f - 1f) * tint + 1) {
     this.spot = spot;
     this.tint = tint;
 }
 public SpotColor(PdfSpotColor spot, float tint) :
     base(TYPE_SEPARATION,
          ((float)spot.AlternativeCS.R / 255f - 1f) * tint + 1,
          ((float)spot.AlternativeCS.G / 255f - 1f) * tint + 1,
          ((float)spot.AlternativeCS.B / 255f - 1f) * tint + 1)
 {
     this.spot = spot;
     this.tint = tint;
 }
        public override bool Equals(Object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (!(o is PdfSpotColor))
            {
                return(false);
            }

            PdfSpotColor spotColor = (PdfSpotColor)o;

            if (!altcs.Equals(spotColor.altcs))
            {
                return(false);
            }
            if (!name.Equals(spotColor.name))
            {
                return(false);
            }

            return(true);
        }
Example #4
0
 public override void SetColorStroke(PdfSpotColor sp, float tint)
 {
     ThrowError();
 }
        public virtual void LabSpotBasedGradient() {
            // step 1
            Document document = new Document(PageSize.A3);
            // step 2
            String dest_file = DEST_FOLDER + "/lab_spot_based_gradient.pdf";
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(dest_file, FileMode.Create));
            // step 3
            document.Open();
            // step 4
            PdfContentByte canvas = writer.DirectContent;
            PdfLabColor pdfLabColor = new PdfLabColor(new float[] {0.9505f, 1.0f, 1.0890f}, new float[] {0f, 0.5f, 1.5f},
                new float[] {-10, 100, -10, 100});
            PdfDeviceNColor pdfDeviceNNChannelColor =
                new PdfDeviceNColor(new PdfSpotColor[] {
                    new PdfSpotColor("lab3", pdfLabColor.Rgb2lab(new BaseColor(0, 217, 83))),
                    new PdfSpotColor("labBlue", pdfLabColor.Rgb2lab(new BaseColor(0, 0, 255)))
                });
            PdfSpotColor psc_lab3 = new PdfSpotColor("lab3", pdfLabColor.Rgb2lab(new BaseColor(0, 217, 83)));
            PdfSpotColor psc_lab2 = new PdfSpotColor("lab2", pdfLabColor.Rgb2lab(new BaseColor(70, 138, 96)));
            PdfSpotColor psc_lab1 = new PdfSpotColor("lab1", pdfLabColor.Rgb2lab(new BaseColor(255, 0, 0)));
            PdfSpotColor psc_lab_blue = new PdfSpotColor("labBlue", new BaseColor(0, 0, 100));

            PdfDeviceNColor pdfDeviceNNChannelColor2 = new PdfDeviceNColor(new PdfSpotColor[]{psc_lab_blue, psc_lab2, psc_lab1});

            ColorRectangle(canvas, pdfLabColor.Rgb2lab(new BaseColor(0, 0, 255)), 36, 878, 36, 36);
            ColorRectangle(canvas, pdfLabColor.Rgb2lab(new BaseColor(70, 138, 96)), 90, 878, 36, 36);
            ColorRectangle(canvas, pdfLabColor.Rgb2lab(new BaseColor(0, 217, 83)), 144, 878, 36, 36);
            ColorRectangle(canvas, pdfLabColor.Rgb2lab(new BaseColor(0, 50, 50)), 198, 878, 36, 36);

            ColorRectangle(canvas, pdfLabColor.Rgb2lab(new BaseColor(0, 0, 255)).ToRgb(), 36, 824, 36, 36);
            ColorRectangle(canvas, pdfLabColor.Rgb2lab(new BaseColor(70, 138, 96)).ToRgb(), 90, 824, 36, 36);
            ColorRectangle(canvas, pdfLabColor.Rgb2lab(new BaseColor(0, 217, 83)).ToRgb(), 144, 824, 36, 36);
            ColorRectangle(canvas, pdfLabColor.Rgb2lab(new BaseColor(0, 50, 50)).ToRgb(), 198, 824, 36, 36);


            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("lab1", pdfLabColor.Rgb2lab(new BaseColor(255, 0, 0))), 1f), 36, 986, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("lab1", pdfLabColor.Rgb2lab(new BaseColor(255, 0, 0))), 0.8f), 90, 986, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("lab1", pdfLabColor.Rgb2lab(new BaseColor(255, 0, 0))), 0.6f), 144, 986, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("lab1", pdfLabColor.Rgb2lab(new BaseColor(255, 0, 0))), 0.2f), 198, 986, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("lab2", pdfLabColor.Rgb2lab(new BaseColor(70, 138, 96))), 1f), 252, 986, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("lab2", pdfLabColor.Rgb2lab(new BaseColor(70, 138, 96))), 0.8f), 306, 986, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("lab2", pdfLabColor.Rgb2lab(new BaseColor(70, 138, 96))), 0.6f), 360, 986, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("lab2", pdfLabColor.Rgb2lab(new BaseColor(70, 138, 96))), 0.2f), 416, 986, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("lab3", pdfLabColor.Rgb2lab(new BaseColor(0, 217, 83))), 1.0f), 470, 986, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("lab3", pdfLabColor.Rgb2lab(new BaseColor(0, 217, 83))), 0.8f), 524, 986, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("lab3", pdfLabColor.Rgb2lab(new BaseColor(0, 217, 83))), 0.6f), 578, 986, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("lab3", pdfLabColor.Rgb2lab(new BaseColor(0, 217, 83))), 0.2f), 634, 986, 36, 36);

            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("rgb1", new BaseColor(255, 0, 0)), 1f), 36, 932, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("rgb1", new BaseColor(255, 0, 0)), 0.8f), 90, 932, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("rgb1", new BaseColor(255, 0, 0)), 0.6f), 144, 932, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("rgb1", new BaseColor(255, 0, 0)), 0.2f), 198, 932, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("rgb2", new BaseColor(70, 138, 96)), 1f), 252, 932, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("rgb2", new BaseColor(70, 138, 96)), 0.8f), 306, 932, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("rgb2", new BaseColor(70, 138, 96)), 0.6f), 360, 932, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("rgb2", new BaseColor(70, 138, 96)), 0.2f), 416, 932, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("rgb3", new BaseColor(0, 217, 83)), 1.0f), 470, 932, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("rgb3", new BaseColor(0, 217, 83)), 0.8f), 524, 932, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("rgb3", new BaseColor(0, 217, 83)), 0.6f), 578, 932, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("rgb3", new BaseColor(0, 217, 83)), 0.2f), 634, 932, 36, 36);

            ColorRectangle(canvas, new DeviceNColor(new PdfDeviceNColor(new PdfSpotColor[]{psc_lab2, psc_lab_blue, psc_lab1}), new float[]{0, 0.0f, 1}), 36, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[]{0.1f, 0.1f}), 90, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[]{0.2f, 0.2f}), 144, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[]{0.3f, 0.3f}), 198, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[]{0.4f, 0.4f}), 252, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(new PdfDeviceNColor(new PdfSpotColor[]{psc_lab2, psc_lab_blue, psc_lab1, psc_lab3}), new float[]{0.5f, 0.5f, 1, 0.5f}), 306, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor2, new float[]{0.6f, 0.1f, 0.5f}), 360, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[]{0.7f, 0.7f}), 416, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[]{0.8f, 0.8f}), 470, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(new PdfDeviceNColor(new PdfSpotColor[]{psc_lab2, psc_lab_blue, psc_lab1}), new float[]{0.9f, 0.9f, 1}), 524, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[]{1, 1}), 578, 770, 36, 36);

            canvas.SaveState();
            canvas.Rectangle(418, 412, -329, 189);
            canvas.Clip();
            canvas.NewPath();
            canvas.SaveState();
            canvas.ConcatCTM(329f, 0f, 0f, -329f, 89f, 506.5f);
            canvas.PaintShading(PdfShading.SimpleAxial(writer, 0, 0, 1, 0, new DeviceNColor(pdfDeviceNNChannelColor, new float[]{1, 0}), new DeviceNColor(pdfDeviceNNChannelColor, new float[]{ 0, 1})));
            canvas.RestoreState();
            canvas.RestoreState();
            canvas.SetColorStroke(new DeviceNColor(pdfDeviceNNChannelColor, new float[]{1, 1}));
            canvas.Rectangle(418, 412, -329, 189);
            canvas.Stroke();

            // step 5
            document.Close();

            CompareTool compareTool = new CompareTool();
            String error = compareTool.Compare(dest_file, TEST_RESOURCES_PATH +  "cmp_lab_spot_based_gradient.pdf", DEST_FOLDER, "diff");
            if (error != null) {
                Assert.Fail(error);
            }
        }
Example #6
0
 public SpotColor(PdfSpotColor spot)
     : this(spot, spot.Tint)
 {
 }
Example #7
0
 public override void setColorFill(PdfSpotColor sp, float tint)
 {
     checkNoColor();
     base.setColorFill(sp, tint);
 }
 public SpotColor(PdfSpotColor spot) : this(spot, spot.Tint)
 {
 }
Example #9
0
        public virtual PdfObject GetPdfObject(PdfWriter writer)
        {
            PdfArray array = new PdfArray(PdfName.DEVICEN);

            PdfArray colorants = new PdfArray();

            float[]       colorantsRanges = new float[spotColors.Length * 2];
            PdfDictionary colorantsDict   = new PdfDictionary();
            String        psFunFooter     = "";

            int numberOfColorants = spotColors.Length;

            float[,] CMYK = new float[4, numberOfColorants];
            int i = 0;

            for (; i < numberOfColorants; i++)
            {
                PdfSpotColor spotColorant = spotColors[i];
                colorantsRanges[2 * i]     = 0;
                colorantsRanges[2 * i + 1] = 1;
                colorants.Add(spotColorant.Name);
                if (colorantsDict.Get(spotColorant.Name) != null)
                {
                    throw new Exception(MessageLocalization.GetComposedMessage("devicen.component.names.shall.be.different"));
                }
                if (colorantsDetails != null)
                {
                    colorantsDict.Put(spotColorant.Name, colorantsDetails[i].IndirectReference);
                }
                else
                {
                    colorantsDict.Put(spotColorant.Name, spotColorant.GetPdfObject(writer));
                }
                BaseColor color = spotColorant.AlternativeCS;
                if (color is ExtendedColor)
                {
                    int type = ((ExtendedColor)color).Type;
                    switch (type)
                    {
                    case ExtendedColor.TYPE_GRAY:
                        CMYK[0, i] = 0;
                        CMYK[1, i] = 0;
                        CMYK[2, i] = 0;
                        CMYK[3, i] = 1 - ((GrayColor)color).Gray;
                        break;

                    case ExtendedColor.TYPE_CMYK:
                        CMYK[0, i] = ((CMYKColor)color).Cyan;
                        CMYK[1, i] = ((CMYKColor)color).Magenta;
                        CMYK[2, i] = ((CMYKColor)color).Yellow;
                        CMYK[3, i] = ((CMYKColor)color).Black;
                        break;

                    case ExtendedColor.TYPE_LAB:
                        CMYKColor cmyk = ((LabColor)color).ToCmyk();
                        CMYK[0, i] = cmyk.Cyan;
                        CMYK[1, i] = cmyk.Magenta;
                        CMYK[2, i] = cmyk.Yellow;
                        CMYK[3, i] = cmyk.Black;
                        break;

                    default:
                        throw new Exception(
                                  MessageLocalization.GetComposedMessage(
                                      "only.rgb.gray.and.cmyk.are.supported.as.alternative.color.spaces"));
                    }
                }
                else
                {
                    float r = color.R;
                    float g = color.G;
                    float b = color.B;
                    float computedC = 0, computedM = 0, computedY = 0, computedK = 0;

                    // BLACK
                    if (r == 0 && g == 0 && b == 0)
                    {
                        computedK = 1;
                    }
                    else
                    {
                        computedC = 1 - (r / 255);
                        computedM = 1 - (g / 255);
                        computedY = 1 - (b / 255);

                        float minCMY = Math.Min(computedC,
                                                Math.Min(computedM, computedY));
                        computedC = (computedC - minCMY) / (1 - minCMY);
                        computedM = (computedM - minCMY) / (1 - minCMY);
                        computedY = (computedY - minCMY) / (1 - minCMY);
                        computedK = minCMY;
                    }
                    CMYK[0, i] = computedC;
                    CMYK[1, i] = computedM;
                    CMYK[2, i] = computedY;
                    CMYK[3, i] = computedK;
                }
                psFunFooter += "pop ";
            }
            array.Add(colorants);

            String psFunHeader = String.Format(NumberFormatInfo.InvariantInfo, "1.000000 {0} 1 roll ", numberOfColorants + 1);

            array.Add(PdfName.DEVICECMYK);
            psFunHeader = psFunHeader + psFunHeader + psFunHeader + psFunHeader;
            String psFun = "";

            i = numberOfColorants + 4;
            for (; i > numberOfColorants; i--)
            {
                psFun += String.Format(NumberFormatInfo.InvariantInfo, "{0} -1 roll ", i);
                for (int j = numberOfColorants; j > 0; j--)
                {
                    psFun += String.Format(NumberFormatInfo.InvariantInfo, "{0} index {1} mul 1.000000 cvr exch sub mul ", j,
                                           CMYK[numberOfColorants + 4 - i, numberOfColorants - j]);
                }
                psFun += String.Format(NumberFormatInfo.InvariantInfo, "1.000000 cvr exch sub {0} 1 roll ", i);
            }

            PdfFunction func = PdfFunction.Type4(writer, colorantsRanges, new float[] { 0, 1, 0, 1, 0, 1, 0, 1 },
                                                 "{ " + psFunHeader + psFun + psFunFooter + "}");

            array.Add(func.Reference);

            PdfDictionary attr = new PdfDictionary();

            attr.Put(PdfName.SUBTYPE, PdfName.NCHANNEL);
            attr.Put(PdfName.COLORANTS, colorantsDict);
            array.Add(attr);

            return(array);
        }
 /** Sets the stroke color to a spot color.
  * @param sp the spot color
  * @param tint the tint for the spot color. 0 is no color and 1
  * is 100% color
  */
 public virtual void SetColorStroke(PdfSpotColor sp, float tint)
 {
     CheckWriter();
     state.colorDetails = writer.AddSimple(sp);
     PageResources prs = PageResources;
     PdfName name = state.colorDetails.ColorName;
     name = prs.AddColor(name, state.colorDetails.IndirectReference);
     content.Append(name.GetBytes()).Append(" CS ").Append(tint).Append(" SCN").Append_i(separator);
 }
Example #11
0
 /** Each spot color used in a document has an instance of this class.
  * @param colorName the color name
  * @param indirectReference the indirect reference to the font
  * @param scolor the <CODE>PDfSpotColor</CODE>
  */
 internal ColorDetails(PdfName colorName, PdfIndirectReference indirectReference, PdfSpotColor scolor) {
     this.colorName = colorName;
     this.indirectReference = indirectReference;
     this.spotcolor = scolor;
 }
Example #12
0
 public override void setColorFill(PdfSpotColor sp, float tint)
 {
     throwError();
 }
 /**
 * @see com.lowagie.text.pdf.PdfContentByte#setColorStroke(com.lowagie.text.pdf.PdfSpotColor, float)
 */
 public override void SetColorStroke(PdfSpotColor sp, float tint) {
     CheckNoColor();
     base.SetColorStroke(sp, tint);
 }
Example #14
0
// ===========================================================================
    public override void Write(Stream stream) {
      // step 1
      using (Document document = new Document()) {
        // step 2
        PdfWriter writer = PdfWriter.GetInstance(document, stream);
        // step 3
        document.Open();
        // step 4
        PdfContentByte canvas = writer.DirectContent;
        PdfSpotColor psc_g = new PdfSpotColor(
          "iTextSpotColorGray", new GrayColor(0.9f)
        );
        PdfSpotColor psc_rgb = new PdfSpotColor(
          "iTextSpotColorRGB", new BaseColor(0x64, 0x95, 0xed)
        );
        PdfSpotColor psc_cmyk = new PdfSpotColor(
          "iTextSpotColorCMYK", new CMYKColor(0.3f, .9f, .3f, .1f)
        );
        ColorRectangle(canvas, new SpotColor(psc_g, 0.5f), 
          36, 770, 36, 36
        );
        ColorRectangle(canvas, new SpotColor(psc_rgb, 0.1f), 
          90, 770, 36, 36
        );
        ColorRectangle(canvas, new SpotColor(psc_rgb, 0.2f), 
          144, 770, 36, 36
        ); 
        ColorRectangle(canvas, new SpotColor(psc_rgb, 0.3f), 
          198, 770, 36, 36
        ); 
        ColorRectangle(canvas, new SpotColor(psc_rgb, 0.4f), 
          252, 770, 36, 36
        ); 
        ColorRectangle(canvas, new SpotColor(psc_rgb, 0.5f), 
          306, 770, 36, 36
        ); 
        ColorRectangle(canvas, new SpotColor(psc_rgb, 0.6f), 
          360, 770, 36, 36
        ); 
        ColorRectangle(canvas, new SpotColor(psc_rgb, 0.7f), 
          416, 770, 36, 36
        ); 
        ColorRectangle(canvas, new SpotColor(psc_cmyk, 0.25f), 
          470, 770, 36, 36
        );
        canvas.SetColorFill(psc_g, 0.5f);
        canvas.Rectangle(36, 716, 36, 36);
        canvas.FillStroke();
        canvas.SetColorFill(psc_g, 0.9f);
        canvas.Rectangle(90, 716, 36, 36);
        canvas.FillStroke();
        canvas.SetColorFill(psc_rgb, 0.5f);
        canvas.Rectangle(144, 716, 36, 36);
        canvas.FillStroke();
        canvas.SetColorFill(psc_rgb, 0.9f);
        canvas.Rectangle(198, 716, 36, 36);
        canvas.FillStroke();
        canvas.SetColorFill(psc_cmyk, 0.5f);
        canvas.Rectangle(252, 716, 36, 36);
        canvas.FillStroke();
        canvas.SetColorFill(psc_cmyk, 0.9f);
        canvas.Rectangle(306, 716, 36, 36);
        canvas.FillStroke();
      }
    }
 public override void SetColorStroke(PdfSpotColor sp, float tint) {
     ThrowError();
 }
Example #16
0
 /** Each spot color used in a document has an instance of this class.
  * @param colorName the color name
  * @param indirectReference the indirect reference to the font
  * @param scolor the <CODE>PDfSpotColor</CODE>
  */
 internal ColorDetails(PdfName colorName, PdfIndirectReference indirectReference, PdfSpotColor scolor)
 {
     this.colorName         = colorName;
     this.indirectReference = indirectReference;
     this.spotcolor         = scolor;
 }
        public virtual void DeviceNCmykRedRgbBlueGradient() {
            Document document = new Document();
            // step 2
            String dest_file = DEST_FOLDER + "/device_n_gradient_CmykRedRgbBlue.pdf";
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(dest_file, FileMode.Create));
            // step 3
            document.Open();
            // step 4
            PdfContentByte canvas = writer.DirectContent;
            PdfSpotColor psc_red = new PdfSpotColor("Spot Red", new CMYKColor(0f, 1f, 1f, 0f));
            PdfSpotColor psc_blue = new PdfSpotColor("Spot Blue", new BaseColor(0, 0, 255));
            PdfDeviceNColor deviceNColor = new PdfDeviceNColor(new PdfSpotColor[] {psc_red, psc_blue});

            canvas.SaveState();
            canvas.Rectangle(418, 412, -329, 189);
            canvas.Clip();
            canvas.NewPath();
            canvas.SaveState();
            canvas.ConcatCTM(329f, 0f, 0f, -329f, 89f, 506.5f);
            canvas.PaintShading(PdfShading.SimpleAxial(writer, 0, 0, 1, 0, new DeviceNColor(deviceNColor, new float[] {1, 0}),
                new DeviceNColor(deviceNColor, new float[] {0, 1})));
            canvas.RestoreState();
            canvas.RestoreState();
            canvas.SetCMYKColorStroke(0, 0, 0, 0xFF);
            canvas.Rectangle(418, 412, -329, 189);
            canvas.Stroke();
            document.Close();

            CompareTool compareTool = new CompareTool();
            String error = compareTool.Compare(dest_file, TEST_RESOURCES_PATH + "cmp_device_n_gradient_CmykRedRgbBlue.pdf", DEST_FOLDER, "diff_");
            if (error != null) {
                Assert.Fail(error);
            }
        }
Example #18
0
 /**
  * @see com.lowagie.text.pdf.PdfContentByte#setColorStroke(com.lowagie.text.pdf.PdfSpotColor, float)
  */
 public override void SetColorStroke(PdfSpotColor sp, float tint)
 {
     CheckNoColor();
     base.SetColorStroke(sp, tint);
 }
        public virtual void DeviceNSpotBasedGradient() {
            // step 1
            Document document = new Document(PageSize.A3);
            // step 2
            String dest_file = DEST_FOLDER + "/device_n_gradient_base.pdf";
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(dest_file, FileMode.Create));
            // step 3
            document.Open();
            // step 4
            PdfContentByte canvas = writer.DirectContent;
            PdfSpotColor psc_gray = new PdfSpotColor("iTextGray", new GrayColor(0f));
            PdfSpotColor psc_cmyk_yell = new PdfSpotColor("iTextYellow", new CMYKColor(0f, 0f, 1f, 0f));
            PdfSpotColor psc_cmyk_magen = new PdfSpotColor("iTextMagenta", new CMYKColor(0f, 1f, 0f, 0f));
            PdfSpotColor psc_rgb_blue = new PdfSpotColor("iTextBlue", new BaseColor(0, 0, 255));

            PdfDeviceNColor pdfDeviceNNChannelColor =
                new PdfDeviceNColor(new PdfSpotColor[] {psc_cmyk_yell, psc_cmyk_magen, psc_rgb_blue});
            PdfDeviceNColor pdfDeviceNNChannelColor2 =
                new PdfDeviceNColor(new PdfSpotColor[] {psc_cmyk_magen, psc_cmyk_yell, psc_rgb_blue});

            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("iTextGray", new GrayColor(0f)), 0.8f), 36, 824, 36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("iTextYellow", new CMYKColor(0f, 0f, 1f, 0f)), 0.8f), 90, 824,
                36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("iTextMagenta", new CMYKColor(0f, 1f, 0f, 0f)), 0.4f), 144, 824,
                36, 36);
            ColorRectangle(canvas, new SpotColor(new PdfSpotColor("iTextBlue", new BaseColor(0, 0, 255)), 0.7f), 198, 824, 36, 36);

            ColorRectangle(canvas,
                new DeviceNColor(new PdfDeviceNColor(new PdfSpotColor[] {psc_cmyk_yell, psc_cmyk_magen, psc_rgb_blue}),
                    new float[] {0, 0.0f, 1}), 36, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[] {0.1f, 0.1f, 1}), 90, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[] {0.2f, 0.2f, 1}), 144, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[] {0.3f, 0.3f, 1}), 198, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[] {0.4f, 0.4f, 1}), 252, 770, 36, 36);
            ColorRectangle(canvas,
                new DeviceNColor(new PdfDeviceNColor(new PdfSpotColor[] {psc_cmyk_yell, psc_cmyk_magen, psc_rgb_blue, psc_gray}),
                    new float[] {0.5f, 0.5f, 1, 0.5f}), 306, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor2, new float[] {0.6f, 0.1f, 1}), 360, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[] {0.7f, 0.7f, 1}), 416, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[] {0.8f, 0.8f, 1}), 470, 770, 36, 36);
            ColorRectangle(canvas,
                new DeviceNColor(new PdfDeviceNColor(new PdfSpotColor[] {psc_cmyk_yell, psc_cmyk_magen, psc_rgb_blue}),
                    new float[] {0.9f, 0.9f, 1}), 524, 770, 36, 36);
            ColorRectangle(canvas, new DeviceNColor(pdfDeviceNNChannelColor, new float[] {1, 1, 1}), 578, 770, 36, 36);

            PdfDeviceNColor pdfDeviceNColor = new PdfDeviceNColor(new PdfSpotColor[] {psc_cmyk_yell, psc_cmyk_magen, psc_rgb_blue});
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0, 0, 1}));
            canvas.Rectangle(36, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.1f, 0.1f, 1}));
            canvas.Rectangle(90, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.2f, 0.2f, 1}));
            canvas.Rectangle(144, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.3f, 0.3f, 1}));
            canvas.Rectangle(198, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.4f, 0.4f, 1}));
            canvas.Rectangle(252, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.5f, 0.5f, 1}));
            canvas.Rectangle(306, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.6f, 0.1f, 1}));
            canvas.Rectangle(360, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.7f, 0.7f, 1}));
            canvas.Rectangle(416, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.8f, 0.8f, 1}));
            canvas.Rectangle(470, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {0.9f, 0.9f, 1}));
            canvas.Rectangle(524, 716, 36, 36);
            canvas.FillStroke();
            canvas.SetColorFill(new DeviceNColor(pdfDeviceNColor, new float[] {1, 1, 1}));
            canvas.Rectangle(578, 716, 36, 36);
            canvas.FillStroke();

            canvas.SaveState();
            canvas.Rectangle(418, 412, -329, 189);
            canvas.Clip();
            canvas.NewPath();
            canvas.SaveState();
            canvas.ConcatCTM(329f, 0f, 0f, -329f, 89f, 506.5f);
            canvas.PaintShading(PdfShading.SimpleAxial(writer, 0, 0, 1, 0,
                new DeviceNColor(pdfDeviceNNChannelColor, new float[] {1, 1, 0}),
                new DeviceNColor(pdfDeviceNNChannelColor, new float[] {0, 0, 1})));
            canvas.RestoreState();
            canvas.RestoreState();
            canvas.SetColorStroke(new DeviceNColor(pdfDeviceNNChannelColor, new float[] {1, 1, 1}));
            canvas.Rectangle(418, 412, -329, 189);
            canvas.Stroke();

            // step 5
            document.Close();

            CompareTool compareTool = new CompareTool();
            String error = compareTool.Compare(dest_file, TEST_RESOURCES_PATH + "cmp_device_n_gradient_base.pdf", DEST_FOLDER, "diff_");
            if (error != null) {
                Assert.Fail(error);
            }
        }
Example #20
0
 /** Sets the fill color to a spot color.
  * @param sp the spot color
  * @param tint the tint for the spot color. 0 is no color and 1
  * is 100% color
  */    
 public virtual void SetColorFill(PdfSpotColor sp, float tint) {
     CheckWriter();
     state.colorDetails = writer.AddSimple(sp);
     PageResources prs = PageResources;
     PdfName name = state.colorDetails.ColorSpaceName;
     name = prs.AddColor(name, state.colorDetails.IndirectReference);
     SaveColor(new SpotColor(sp, tint), true);
     content.Append(name.GetBytes()).Append(" cs ").Append(tint).Append(" scn").Append_i(separator);
 }
 public PdfDeviceNColor(PdfSpotColor[] spotColors) {
     this.spotColors = spotColors;
 }
Example #22
0
 /**
 * 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;
 }
Example #23
0
 public override void setColorStroke(PdfSpotColor sp, float tint)
 {
     state.colorDetails = writer.addSimple(sp);
     colorDictionary.put(state.colorDetails.ColorName, state.colorDetails.IndirectReference);
     content.Append(state.colorDetails.ColorName.toPdf(null)).Append(" CS ").Append(tint).Append(" SCN").Append_i(separator);
 }