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 Radial(PdfColorSpace cs, float x0, float y0, float r0, float[] color0, float x1, float y1, float r1 , float[] color1) : base(new PdfDictionary(), PdfShading.ShadingType.RADIAL, cs.GetPdfObject()) { SetCoords(x0, y0, r0, x1, y1, r1); PdfFunction func = new PdfFunction.Type2(new PdfArray(new float[] { 0, 1 }), null, new PdfArray(color0), new PdfArray(color1), new PdfNumber(1)); SetFunction(func); }
private PdfSpecialCs.Separation CreateCmykColorSpace(float c, float m, float y, float k) { float[] c0 = new float[] { 0, 0, 0, 0 }; float[] c1 = new float[] { c, m, y, k }; PdfFunction pdfFunction = new PdfFunction.Type2(new PdfArray(new float[] { 0, 1 }), null, new PdfArray(c0), new PdfArray(c1), new PdfNumber(1)); PdfSpecialCs.Separation cs = new PdfSpecialCs.Separation("iTextSpotColorCMYK", new DeviceCmyk(c, m, y, k).GetColorSpace(), pdfFunction); return(cs); }
public Axial(PdfColorSpace cs, float x0, float y0, float[] color0, float x1, float y1, float[] color1) : base(new PdfDictionary(), PdfShading.ShadingType.AXIAL, cs.GetPdfObject()) { if (cs is PdfSpecialCs.Pattern) { throw new ArgumentException("colorSpace"); } SetCoords(x0, y0, x1, y1); PdfFunction func = new PdfFunction.Type2(new PdfArray(new float[] { 0, 1 }), null, new PdfArray(color0), new PdfArray(color1), new PdfNumber(1)); SetFunction(func); }
public PdfSpecialCs GetSeparationColorspace(PdfWriter writer, DeviceCmyk cmyk) { PdfDictionary pdfDictionary = new PdfDictionary(); pdfDictionary.Put(PdfName.FunctionType, new PdfNumber(2)); pdfDictionary.Put(PdfName.Domain, new PdfArray(new float[] { 0, 1 })); pdfDictionary.Put(PdfName.C0, new PdfArray(new float[] { 0, 0, 0, 0 })); pdfDictionary.Put(PdfName.C1, new PdfArray(cmyk.GetColorValue())); pdfDictionary.Put(PdfName.N, new PdfNumber(1)); PdfFunction pdfFunction = new PdfFunction.Type2(pdfDictionary); return(new PdfSpecialCs.Separation("mySpotColor", cmyk.GetColorSpace(), pdfFunction)); }
private static PdfFunction.Type3 CreateStitchingCmykShadingFunction() { PdfArray domain0to1 = new PdfArray(new float[] { 0, 1 }); PdfArray range0to1For4n = new PdfArray(new float[] { 0, 1, 0, 1, 0, 1, 0, 1 }); float[] cmykColor0 = new float[] { 0.2f, 0.4f, 0f, 0f }; float[] cmykColor1 = new float[] { 0.2f, 1f, 0f, 0f }; PdfFunction.Type2 function0 = new PdfFunction.Type2(domain0to1, null, new PdfArray(cmykColor0), new PdfArray (cmykColor1), new PdfNumber(1)); PdfFunction.Type2 function1 = new PdfFunction.Type2(domain0to1, null, new PdfArray(cmykColor1), new PdfArray (cmykColor0), new PdfNumber(1)); PdfArray boundForTwoFunctionsSubdomains = new PdfArray(new float[] { 0.5f }); PdfArray encodeStitchingSubdomainToNthFunctionDomain = new PdfArray(new float[] { 0, 1, 0, 1 }); return(new PdfFunction.Type3(domain0to1, range0to1For4n, new List <PdfFunction>(JavaUtil.ArraysAsList(function0 , function1)), boundForTwoFunctionsSubdomains, encodeStitchingSubdomainToNthFunctionDomain)); }
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(); }