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); } }
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); } }