Ejemplo n.º 1
0
 private static void smethod_1(PdfContentByte pdfContentByte_0, Graphics graphics_0, int int_0, int int_1, int int_2, int int_3, string string_0, System.Drawing.Font font_0, System.Drawing.Color color_0)
 {
     try
     {
         PdfSpotColor sp = new PdfSpotColor("PANTONE 147", 0.9f, new iTextSharp.text.Color(color_0.R, color_0.G, color_0.B));
         pdfContentByte_0.SetColorStroke(sp, 1f);
         pdfContentByte_0.SetColorFill(sp, 1f);
         int style = 0;
         if (font_0.Bold)
         {
             style++;
         }
         if (font_0.Italic)
         {
             style += 2;
         }
         if (font_0.Underline)
         {
             style += 4;
         }
         iTextSharp.text.Font font = new iTextSharp.text.Font(getBaseFont(font_0.Name), font_0.Size, style);
         ColumnText           text = new ColumnText(pdfContentByte_0);
         Phrase phrase             = new Phrase(string_0, font);
         text.SetSimpleColumn(phrase, (float)int_0, (float)int_1, (float)(int_2 + 100), (float)int_3, 0f, 0);
         text.Go();
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception.Message);
     }
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 public SpotColor(PdfSpotColor spot, float tint) :
     base(TYPE_SEPARATION,
          (spot.AlternativeCs.R / 255f - 1f) * tint + 1,
          (spot.AlternativeCs.G / 255f - 1f) * tint + 1,
          (spot.AlternativeCs.B / 255f - 1f) * tint + 1)
 {
     PdfSpotColor = spot;
     Tint         = tint;
 }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
Archivo: PdfCell.cs Proyecto: ikvm/test
        private void method_3(PdfContentByte pdfContentByte_0, Graphics graphics_0, int int_6, int int_7, int int_8, int int_9)
        {
            object obj2 = this.cellSet_0.getPropertyValue(this.int_0, this.int_1, 713);

            if ((obj2 != null) && ((int)obj2 != -1))
            {
                System.Drawing.Color color = System.Drawing.Color.FromArgb(int.Parse(obj2.ToString()));
                try
                {
                    byte         red   = color.R;
                    byte         green = color.G;
                    PdfSpotColor sp    = new PdfSpotColor("PANTONE 147", 0.9f, new iTextSharp.text.Color(red, green, color.B));
                    pdfContentByte_0.SetColorFill(sp, sp.Tint);
                    pdfContentByte_0.Rectangle((float)int_6, (float)int_7, (float)(int_8 - int_6), (float)(int_9 - int_7));
                    pdfContentByte_0.Fill();
                    pdfContentByte_0.ResetRGBColorFill();
                }
                catch (Exception exception)
                {
                    SupportClass.WriteStackTrace(exception, Console.Out);
                }
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Each spot color used in a document has an instance of this class.
 /// </summary>
 /// <param name="colorName">the color name</param>
 /// <param name="indirectReference">the indirect reference to the font</param>
 /// <param name="scolor">the  PDfSpotColor </param>
 internal ColorDetails(PdfName colorName, PdfIndirectReference indirectReference, PdfSpotColor scolor)
 {
     _colorName         = colorName;
     _indirectReference = indirectReference;
     _spotcolor         = scolor;
 }
Ejemplo n.º 7
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();
            }
        }
Ejemplo n.º 8
0
        public Chap1013()
        {
            Console.WriteLine("Chapter 10 Example 13: Spot Color");

            // step 1: creation of a document-object
            Document document = new Document();

            try
            {
                // step 2:
                // we create a writer that listens to the document
                // and directs a PDF-stream to a file
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("Chap1013.pdf", FileMode.Create));
                BaseFont  bf     = BaseFont.CreateFont("Helvetica", "winansi", BaseFont.NOT_EMBEDDED);

                // step 3: we open the document
                document.Open();

                // step 4: we add some content
                PdfContentByte cb = writer.DirectContent;

                // Note: I made up these names unless someone give me a PANTONE swatch as gift ([email protected])
                PdfSpotColor spc_cmyk = new PdfSpotColor("PANTONE 280 CV", 0.25f, new CMYKColor(0.9f, .2f, .3f, .1f));
                PdfSpotColor spc_rgb  = new PdfSpotColor("PANTONE 147", 0.9f, new Color(114, 94, 38));
                PdfSpotColor spc_g    = new PdfSpotColor("PANTONE 100 CV", 0.5f, new GrayColor(0.9f));

                // Stroke a rectangle with CMYK alternate
                cb.SetColorStroke(spc_cmyk, .5f);
                cb.SetLineWidth(10f);
                // draw a rectangle
                cb.Rectangle(100, 700, 100, 100);
                // add the diagonal
                cb.MoveTo(100, 700);
                cb.LineTo(200, 800);
                // stroke the lines
                cb.Stroke();

                // Fill a rectangle with CMYK alternate
                cb.SetColorFill(spc_cmyk, spc_cmyk.Tint);
                cb.Rectangle(250, 700, 100, 100);
                cb.Fill();

                // Stroke a circle with RGB alternate
                cb.SetColorStroke(spc_rgb, spc_rgb.Tint);
                cb.SetLineWidth(5f);
                cb.Circle(150f, 500f, 100f);
                cb.Stroke();

                // Fill the circle with RGB alternate
                cb.SetColorFill(spc_rgb, spc_rgb.Tint);
                cb.Circle(150f, 500f, 50f);
                cb.Fill();

                // example with colorfill
                cb.SetColorFill(spc_g, spc_g.Tint);
                cb.MoveTo(100f, 200f);
                cb.LineTo(200f, 250f);
                cb.LineTo(400f, 150f);
                cb.Fill();
                document.NewPage();
                String text = "Some text to show";
                document.Add(new Paragraph(text, FontFactory.GetFont(FontFactory.HELVETICA, 24, Font.NORMAL, new SpotColor(spc_cmyk))));
                document.Add(new Paragraph(text, FontFactory.GetFont(FontFactory.HELVETICA, 24, Font.NORMAL, new SpotColor(spc_cmyk, 0.5f))));

                // example with template
                PdfTemplate t = cb.CreateTemplate(500f, 500f);
                // Stroke a rectangle with CMYK alternate
                t.SetColorStroke(new SpotColor(spc_cmyk, .5f));
                t.SetLineWidth(10f);
                // draw a rectangle
                t.Rectangle(100, 10, 100, 100);
                // add the diagonal
                t.MoveTo(100, 10);
                t.LineTo(200, 100);
                // stroke the lines
                t.Stroke();

                // Fill a rectangle with CMYK alternate
                t.SetColorFill(spc_g, spc_g.Tint);
                t.Rectangle(100, 125, 100, 100);
                t.Fill();
                t.BeginText();
                t.SetFontAndSize(bf, 20f);
                t.SetTextMatrix(1f, 0f, 0f, 1f, 10f, 10f);
                t.ShowText("Template text upside down");
                t.EndText();
                t.Rectangle(0, 0, 499, 499);
                t.Stroke();
                cb.AddTemplate(t, -1.0f, 0.00f, 0.00f, -1.0f, 550f, 550f);
            }
            catch (Exception de)
            {
                Console.Error.WriteLine(de.Message);
                Console.Error.WriteLine(de.StackTrace);
            }

            // step 5: we close the document
            document.Close();
        }
Ejemplo n.º 9
0
        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);
            }
        }
Ejemplo n.º 10
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 = (ColorDetails)documentColors[spc];
     if (ret == null) {
         ret = new ColorDetails(GetColorspaceName(), body.PdfIndirectReference, spc);
         documentColors[spc] = ret;
     }
     return ret;
 }
Ejemplo n.º 11
0
 public SpotColor(PdfSpotColor spot) : this(spot, spot.Tint)
 {
 }
Ejemplo n.º 12
0
 public override void SetColorStroke(PdfSpotColor sp, float tint)
 {
     ThrowError();
 }
Ejemplo n.º 13
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;
 }
Ejemplo n.º 14
0
        public Chap1014()
        {
            Console.WriteLine("Chapter 10 Example 14: colored patterns");

            // step 1: creation of a document-object
            Document document = new Document(PageSize.A4, 50, 50, 50, 50);

            Document.Compress = false;
            try
            {
                // step 2:
                // we create a writer that listens to the document
                // and directs a PDF-stream to a file
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("Chap1014.pdf", FileMode.Create));

                // step 3: we open the document
                document.Open();

                // step 4: we add some content
                PdfContentByte    cb  = writer.DirectContent;
                PdfTemplate       tp  = cb.CreateTemplate(400, 300);
                PdfPatternPainter pat = cb.CreatePattern(15, 15, null);
                pat.Rectangle(5, 5, 5, 5);
                pat.Fill();
                PdfSpotColor spc_cmyk = new PdfSpotColor("PANTONE 280 CV", 0.25f, new CMYKColor(0.9f, .2f, .3f, .1f));
                SpotColor    spot     = new SpotColor(spc_cmyk);
                tp.SetPatternFill(pat, spot, .9f);
                tp.Rectangle(0, 0, 400, 300);
                tp.Fill();
                cb.AddTemplate(tp, 50, 50);
                PdfPatternPainter pat2 = cb.CreatePattern(10, 10, null);
                pat2.SetLineWidth(2);
                pat2.MoveTo(-5, 0);
                pat2.LineTo(10, 15);
                pat2.Stroke();
                pat2.MoveTo(0, -5);
                pat2.LineTo(15, 10);
                pat2.Stroke();
                cb.SetLineWidth(1);
                cb.SetColorStroke(new Color(System.Drawing.Color.Black));
                cb.SetPatternFill(pat2, new Color(System.Drawing.Color.Red));
                cb.Rectangle(100, 400, 30, 210);
                cb.FillStroke();
                cb.SetPatternFill(pat2, new Color(System.Drawing.Color.LightGreen));
                cb.Rectangle(150, 400, 30, 100);
                cb.FillStroke();
                cb.SetPatternFill(pat2, new Color(System.Drawing.Color.Blue));
                cb.Rectangle(200, 400, 30, 130);
                cb.FillStroke();
                cb.SetPatternFill(pat2, new GrayColor(0.5f));
                cb.Rectangle(250, 400, 30, 80);
                cb.FillStroke();
                cb.SetPatternFill(pat2, new GrayColor(0.7f));
                cb.Rectangle(300, 400, 30, 170);
                cb.FillStroke();
                cb.SetPatternFill(pat2, new GrayColor(0.9f));
                cb.Rectangle(350, 400, 30, 40);
                cb.FillStroke();
            }
            catch (Exception de)
            {
                Console.Error.WriteLine(de.Message);
                Console.Error.WriteLine(de.StackTrace);
            }
            // step 5: we close the document
            document.Close();
        }
Ejemplo n.º 15
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);
 }
Ejemplo n.º 16
0
        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);
            }
        }
Ejemplo n.º 17
0
 public SpotColor(PdfSpotColor spot)
     : this(spot, spot.Tint)
 {
 }
Ejemplo n.º 18
0
        private void method_0(Graphics graphics_1, int int_4, int int_5, int int_6, int int_7, int int_8, int int_9, int int_10, int int_11)
        {
            PdfSpotColor color;
            short        key  = 0;
            short        num2 = 0;
            short        num3 = 0;

            switch (int_8)
            {
            case 1:
                key  = 708;
                num2 = 707;
                num3 = 709;
                break;

            case 2:
                key  = 711;
                num2 = 710;
                num3 = 712;
                break;

            case 3:
                key  = 702;
                num2 = 701;
                num3 = 703;
                break;

            case 4:
                key  = 705;
                num2 = 704;
                num3 = 706;
                break;
            }
            object obj3 = this.parser_0.getPropertyValue(int_10, int_11, key);
            object obj2 = this.parser_0.getPropertyValue(int_10, int_11, num2);
            object obj4 = this.parser_0.getPropertyValue(int_10, int_11, num3);

            if (obj4 != null)
            {
                System.Drawing.Color color2 = System.Drawing.Color.FromArgb(int.Parse(obj4.ToString()));
                byte red   = color2.R;
                byte green = color2.G;
                color = new PdfSpotColor("PANTONE 147", 0.9f, new iTextSharp.text.Color(red, green, color2.B));
            }
            else
            {
                color = new PdfSpotColor("PANTONE 147", 0.9f, new iTextSharp.text.Color(System.Drawing.Color.LightGray.R, System.Drawing.Color.LightGray.G, System.Drawing.Color.LightGray.B));
            }
            this.pdfContentByte_0.SetColorStroke(color, 0.5f);
            float num7 = 0.5f;

            if (obj3 != null)
            {
                num7 = float.Parse(obj3.ToString());
            }
            this.pdfContentByte_0.SetLineWidth(num7);
            int num5 = -1;

            if (obj2 != null)
            {
                num5 = int.Parse(obj2.ToString());
                if ((num5 == PropertyDefine.CBS_NONE) && !this.bool_0)
                {
                    return;
                }
                if (num5 == PropertyDefine.CBS_DASHED)
                {
                    float[] array = new float[] { 5f, 3f };
                    this.pdfContentByte_0.SetLineDash(array, num7);
                }
                if (num5 == PropertyDefine.CBS_DOTTED)
                {
                    float[] numArray3 = new float[] { 10f, 3f, 2f, 3f };
                    this.pdfContentByte_0.SetLineDash(numArray3, num7);
                }
                if (num5 == PropertyDefine.CBS_NOTMODIFIED)
                {
                    num7 = 2f;
                    float[] numArray2 = new float[] { 1f, 1f };
                    this.pdfContentByte_0.SetLineDash(numArray2, num7);
                }
            }
            else if (!this.bool_0)
            {
                return;
            }
            if (num5 == PropertyDefine.CBS_DOUBLE)
            {
                switch (int_8)
                {
                case 1:
                    if (this.Boolean_2)
                    {
                        int_5++;
                        int_7++;
                    }
                    int_5++;
                    int_7++;
                    if (this.method_1(int_10, int_11, 3) && ((int_9 == 0) || ((1 & int_9) != 0)))
                    {
                        int_4++;
                        if (this.Boolean_3)
                        {
                            int_4++;
                        }
                    }
                    if (this.method_1(int_10, int_11, 4) && ((int_9 == 0) || ((2 & int_9) != 0)))
                    {
                        int_6--;
                        if (this.Boolean_1)
                        {
                            int_6--;
                        }
                    }
                    break;

                case 2:
                    if (this.Boolean_0)
                    {
                        int_5--;
                        int_7--;
                    }
                    int_5--;
                    int_7--;
                    if (this.method_1(int_10, int_11, 3) && ((int_9 == 0) || ((4 & int_9) != 0)))
                    {
                        int_4++;
                        if (this.Boolean_3)
                        {
                            int_4++;
                        }
                    }
                    if (this.method_1(int_10, int_11, 4) && ((int_9 == 0) || ((8 & int_9) != 0)))
                    {
                        int_6--;
                        if (this.Boolean_1)
                        {
                            int_6--;
                        }
                    }
                    break;

                case 3:
                    if (this.Boolean_3)
                    {
                        int_4++;
                        int_6++;
                    }
                    int_4++;
                    int_6++;
                    if (this.method_1(int_10, int_11, 1) && ((int_9 == 0) || ((1 & int_9) != 0)))
                    {
                        int_5++;
                        if (this.Boolean_2)
                        {
                            int_5++;
                        }
                    }
                    if (this.method_1(int_10, int_11, 2) && ((int_9 == 0) || ((4 & int_9) != 0)))
                    {
                        int_7--;
                        if (this.Boolean_0)
                        {
                            int_7--;
                        }
                    }
                    break;

                case 4:
                    if (this.Boolean_1)
                    {
                        int_4--;
                        int_6--;
                    }
                    int_4--;
                    int_6--;
                    if (this.method_1(int_10, int_11, 1) && ((int_9 == 0) || ((2 & int_9) != 0)))
                    {
                        int_5++;
                        if (this.Boolean_2)
                        {
                            int_5++;
                        }
                    }
                    if (this.method_1(int_10, int_11, 2) && ((int_9 == 0) || ((8 & int_9) != 0)))
                    {
                        int_7--;
                        if (this.Boolean_0)
                        {
                            int_7--;
                        }
                    }
                    break;
                }
            }
            this.pdfContentByte_0.MoveTo((float)int_4, (float)int_5);
            this.pdfContentByte_0.LineTo((float)int_6, (float)int_7);
            this.pdfContentByte_0.Stroke();
        }
Ejemplo n.º 19
0
 public override int GetHashCode()
 {
     return(PdfSpotColor.GetHashCode() ^ Tint.GetHashCode());
 }