public virtual void ColourSpaceTest03() { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "" , "http://www.color.org", "sRGB IEC61966-2.1", @is)); PdfPage page = doc.AddNewPage(); PdfColorSpace alternateSpace = new PdfDeviceCs.Rgb(); //Tint transformation function is a dictionary PdfArray domain = new PdfArray(new float[] { 0, 1 }); PdfArray range = new PdfArray(new float[] { 0, 1, 0, 1, 0, 1 }); PdfArray C0 = new PdfArray(new float[] { 0, 0, 0 }); PdfArray C1 = new PdfArray(new float[] { 1, 1, 1 }); PdfNumber n = new PdfNumber(1); PdfFunction.Type2 type2 = new PdfFunction.Type2(domain, range, C0, C1, n); PdfCanvas canvas = new PdfCanvas(page); String separationName = "separationTest"; canvas.SetColor(new Separation(separationName, alternateSpace, type2, 0.5f), true); PdfDictionary attributes = new PdfDictionary(); PdfDictionary colorantsDict = new PdfDictionary(); colorantsDict.Put(new PdfName(separationName), new PdfSpecialCs.Separation(separationName, alternateSpace, type2).GetPdfObject()); attributes.Put(PdfName.Colorants, colorantsDict); DeviceN deviceN = new DeviceN(new PdfSpecialCs.NChannel(JavaCollectionsUtil.SingletonList(separationName), alternateSpace, type2, attributes), new float[] { 0.5f }); canvas.SetColor(deviceN, true); doc.Close(); }
public virtual void ColorTest02() { PdfWriter writer = new PdfWriter(destinationFolder + "colorTest02.pdf"); writer.SetCompressionLevel(CompressionConstants.NO_COMPRESSION); PdfDocument document = new PdfDocument(writer); PdfPage page = document.AddNewPage(); PdfCanvas canvas = new PdfCanvas(page); PdfDeviceCs.Rgb rgb = new PdfDeviceCs.Rgb(); Color red = Color.MakeColor(rgb, new float[] { 1, 0, 0 }); Color green = Color.MakeColor(rgb, new float[] { 0, 1, 0 }); Color blue = Color.MakeColor(rgb, new float[] { 0, 0, 1 }); PdfDeviceCs.Cmyk cmyk = new PdfDeviceCs.Cmyk(); Color cyan = Color.MakeColor(cmyk, new float[] { 1, 0, 0, 0 }); Color magenta = Color.MakeColor(cmyk, new float[] { 0, 1, 0, 0 }); Color yellow = Color.MakeColor(cmyk, new float[] { 0, 0, 1, 0 }); Color black = Color.MakeColor(cmyk, new float[] { 0, 0, 0, 1 }); canvas.SetFillColor(red).Rectangle(50, 500, 50, 50).Fill(); canvas.SetFillColor(green).Rectangle(150, 500, 50, 50).Fill(); canvas.SetFillColor(blue).Rectangle(250, 500, 50, 50).Fill(); canvas.SetLineWidth(5); canvas.SetStrokeColor(cyan).Rectangle(50, 400, 50, 50).Stroke(); canvas.SetStrokeColor(magenta).Rectangle(150, 400, 50, 50).Stroke(); canvas.SetStrokeColor(yellow).Rectangle(250, 400, 50, 50).Stroke(); canvas.SetStrokeColor(black).Rectangle(350, 400, 50, 50).Stroke(); canvas.Release(); document.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + "colorTest02.pdf", sourceFolder + "cmp_colorTest02.pdf", destinationFolder, "diff_")); }
public virtual void ColourSpaceTest02() { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "" , "http://www.color.org", "sRGB IEC61966-2.1", @is)); PdfPage page = doc.AddNewPage(); PdfColorSpace alternateSpace = new PdfDeviceCs.Rgb(); //Tint transformation function is a dictionary PdfArray domain = new PdfArray(new float[] { 0, 1 }); PdfArray range = new PdfArray(new float[] { 0, 1, 0, 1, 0, 1 }); PdfArray C0 = new PdfArray(new float[] { 0, 0, 0 }); PdfArray C1 = new PdfArray(new float[] { 1, 1, 1 }); PdfNumber n = new PdfNumber(1); PdfFunction.Type2 type2 = new PdfFunction.Type2(domain, range, C0, C1, n); PdfColorSpace separationColourSpace = new PdfSpecialCs.Separation("separationTestFunction2", alternateSpace , type2); //Add to document page.GetResources().AddColorSpace(separationColourSpace); doc.Close(); }
public virtual void ColourSpaceTest01() { PdfWriter writer = new PdfWriter(new ByteArrayOutputStream()); Stream @is = new FileStream(sourceFolder + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read); PdfADocument doc = new PdfADocument(writer, PdfAConformanceLevel.PDF_A_2B, new PdfOutputIntent("Custom", "" , "http://www.color.org", "sRGB IEC61966-2.1", @is)); PdfPage page = doc.AddNewPage(); PdfColorSpace alternateSpace = new PdfDeviceCs.Rgb(); //Tint transformation function is a stream byte[] samples = new byte[] { 0x00, 0x00, 0x00, 0x01, 0x01, 0x01 }; PdfArray domain = new PdfArray(new float[] { 0, 1 }); PdfArray range = new PdfArray(new float[] { 0, 1, 0, 1, 0, 1 }); PdfArray size = new PdfArray(new float[] { 2 }); PdfNumber bitsPerSample = new PdfNumber(8); PdfFunction.Type0 type0 = new PdfFunction.Type0(domain, range, size, bitsPerSample, samples); PdfColorSpace separationColourSpace = new PdfSpecialCs.Separation("separationTestFunction0", alternateSpace , type0); //Add to document page.GetResources().AddColorSpace(separationColourSpace); doc.Close(); }