public static PdfFunction Type0(PdfWriter writer, float[] domain, float[] range, int[] size, int bitsPerSample, int order, float[] encode, float[] decode, byte[] stream) { PdfFunction func = new PdfFunction(writer); func.dictionary = new PdfStream(stream); ((PdfStream)func.dictionary).FlateCompress(writer.CompressionLevel); func.dictionary.Put(PdfName.FUNCTIONTYPE, new PdfNumber(0)); func.dictionary.Put(PdfName.DOMAIN, new PdfArray(domain)); func.dictionary.Put(PdfName.RANGE, new PdfArray(range)); func.dictionary.Put(PdfName.SIZE, new PdfArray(size)); func.dictionary.Put(PdfName.BITSPERSAMPLE, new PdfNumber(bitsPerSample)); if (order != 1) { func.dictionary.Put(PdfName.ORDER, new PdfNumber(order)); } if (encode != null) { func.dictionary.Put(PdfName.ENCODE, new PdfArray(encode)); } if (decode != null) { func.dictionary.Put(PdfName.DECODE, new PdfArray(decode)); } return(func); }
public static PdfShading SimpleRadial(PdfWriter writer, float x0, float y0, float r0, float x1, float y1, float r1, Color startColor, Color endColor, bool extendStart, bool extendEnd) { CheckCompatibleColors(startColor, endColor); PdfFunction function = PdfFunction.Type2(writer, new float[] { 0, 1 }, null, GetColorArray(startColor), GetColorArray(endColor), 1); return(Type3(writer, startColor, new float[] { x0, y0, r0, x1, y1, r1 }, null, function, new bool[] { extendStart, extendEnd })); }
public static PdfFunction Type4(PdfWriter writer, float[] domain, float[] range, string postscript) { byte[] b = new byte[postscript.Length]; for (int k = 0; k < b.Length; ++k) { b[k] = (byte)postscript[k]; } PdfFunction func = new PdfFunction(writer); func.dictionary = new PdfStream(b); ((PdfStream)func.dictionary).FlateCompress(writer.CompressionLevel); func.dictionary.Put(PdfName.FUNCTIONTYPE, new PdfNumber(4)); func.dictionary.Put(PdfName.DOMAIN, new PdfArray(domain)); func.dictionary.Put(PdfName.RANGE, new PdfArray(range)); return(func); }
public static PdfFunction Type3(PdfWriter writer, float[] domain, float[] range, PdfFunction[] functions, float[] bounds, float[] encode) { PdfFunction func = new PdfFunction(writer); func.dictionary = new PdfDictionary(); func.dictionary.Put(PdfName.FUNCTIONTYPE, new PdfNumber(3)); func.dictionary.Put(PdfName.DOMAIN, new PdfArray(domain)); if (range != null) { func.dictionary.Put(PdfName.RANGE, new PdfArray(range)); } PdfArray array = new PdfArray(); for (int k = 0; k < functions.Length; ++k) { array.Add(functions[k].Reference); } func.dictionary.Put(PdfName.FUNCTIONS, array); func.dictionary.Put(PdfName.BOUNDS, new PdfArray(bounds)); func.dictionary.Put(PdfName.ENCODE, new PdfArray(encode)); return(func); }
public static PdfFunction Type2(PdfWriter writer, float[] domain, float[] range, float[] c0, float[] c1, float n) { PdfFunction func = new PdfFunction(writer); func.dictionary = new PdfDictionary(); func.dictionary.Put(PdfName.FUNCTIONTYPE, new PdfNumber(2)); func.dictionary.Put(PdfName.DOMAIN, new PdfArray(domain)); if (range != null) { func.dictionary.Put(PdfName.RANGE, new PdfArray(range)); } if (c0 != null) { func.dictionary.Put(PdfName.C0, new PdfArray(c0)); } if (c1 != null) { func.dictionary.Put(PdfName.C1, new PdfArray(c1)); } func.dictionary.Put(PdfName.N, new PdfNumber(n)); return(func); }
protected internal PdfObject GetSpotObject(PdfWriter writer) { PdfArray array = new PdfArray(PdfName.SEPARATION); array.Add(name); PdfFunction func = null; if (altcs is ExtendedColor) { int type = ((ExtendedColor)altcs).Type; switch (type) { case ExtendedColor.TYPE_GRAY: array.Add(PdfName.DEVICEGRAY); func = PdfFunction.Type2(writer, new float[] { 0, 1 }, null, new float[] { 0 }, new float[] { ((GrayColor)altcs).Gray }, 1); break; case ExtendedColor.TYPE_CMYK: array.Add(PdfName.DEVICECMYK); CMYKColor cmyk = (CMYKColor)altcs; func = PdfFunction.Type2(writer, new float[] { 0, 1 }, null, new float[] { 0, 0, 0, 0 }, new float[] { cmyk.Cyan, cmyk.Magenta, cmyk.Yellow, cmyk.Black }, 1); break; default: throw new Exception("Only RGB, Gray and CMYK are supported as alternative color spaces."); } } else { array.Add(PdfName.DEVICERGB); func = PdfFunction.Type2(writer, new float[] { 0, 1 }, null, new float[] { 1, 1, 1 }, new float[] { (float)altcs.R / 255, (float)altcs.G / 255, (float)altcs.B / 255 }, 1); } array.Add(func.Reference); return(array); }
public static PdfFunction Type0(PdfWriter writer, float[] domain, float[] range, int[] size, int bitsPerSample, int order, float[] encode, float[] decode, byte[] stream) { PdfFunction func = new PdfFunction(writer); func.dictionary = new PdfStream(stream); ((PdfStream)func.dictionary).FlateCompress(writer.CompressionLevel); func.dictionary.Put(PdfName.FUNCTIONTYPE, new PdfNumber(0)); func.dictionary.Put(PdfName.DOMAIN, new PdfArray(domain)); func.dictionary.Put(PdfName.RANGE, new PdfArray(range)); func.dictionary.Put(PdfName.SIZE, new PdfArray(size)); func.dictionary.Put(PdfName.BITSPERSAMPLE, new PdfNumber(bitsPerSample)); if (order != 1) func.dictionary.Put(PdfName.ORDER, new PdfNumber(order)); if (encode != null) func.dictionary.Put(PdfName.ENCODE, new PdfArray(encode)); if (decode != null) func.dictionary.Put(PdfName.DECODE, new PdfArray(decode)); return func; }
public static PdfFunction Type4(PdfWriter writer, float[] domain, float[] range, string postscript) { byte[] b = new byte[postscript.Length]; for (int k = 0; k < b.Length; ++k) b[k] = (byte)postscript[k]; PdfFunction func = new PdfFunction(writer); func.dictionary = new PdfStream(b); ((PdfStream)func.dictionary).FlateCompress(writer.CompressionLevel); func.dictionary.Put(PdfName.FUNCTIONTYPE, new PdfNumber(4)); func.dictionary.Put(PdfName.DOMAIN, new PdfArray(domain)); func.dictionary.Put(PdfName.RANGE, new PdfArray(range)); return func; }
public static PdfFunction Type3(PdfWriter writer, float[] domain, float[] range, PdfFunction[] functions, float[] bounds, float[] encode) { PdfFunction func = new PdfFunction(writer); func.dictionary = new PdfDictionary(); func.dictionary.Put(PdfName.FUNCTIONTYPE, new PdfNumber(3)); func.dictionary.Put(PdfName.DOMAIN, new PdfArray(domain)); if (range != null) func.dictionary.Put(PdfName.RANGE, new PdfArray(range)); PdfArray array = new PdfArray(); for (int k = 0; k < functions.Length; ++k) array.Add(functions[k].Reference); func.dictionary.Put(PdfName.FUNCTIONS, array); func.dictionary.Put(PdfName.BOUNDS, new PdfArray(bounds)); func.dictionary.Put(PdfName.ENCODE, new PdfArray(encode)); return func; }
public static PdfFunction Type2(PdfWriter writer, float[] domain, float[] range, float[] c0, float[] c1, float n) { PdfFunction func = new PdfFunction(writer); func.dictionary = new PdfDictionary(); func.dictionary.Put(PdfName.FUNCTIONTYPE, new PdfNumber(2)); func.dictionary.Put(PdfName.DOMAIN, new PdfArray(domain)); if (range != null) func.dictionary.Put(PdfName.RANGE, new PdfArray(range)); if (c0 != null) func.dictionary.Put(PdfName.C0, new PdfArray(c0)); if (c1 != null) func.dictionary.Put(PdfName.C1, new PdfArray(c1)); func.dictionary.Put(PdfName.N, new PdfNumber(n)); return func; }
public static PdfShading Type3(PdfWriter writer, Color colorSpace, float[] coords, float[] domain, PdfFunction function, bool[] extend) { PdfShading sp = Type2(writer, colorSpace, coords, domain, function, extend); sp.shadingType = 3; sp.shading.Put(PdfName.SHADINGTYPE, new PdfNumber(sp.shadingType)); return(sp); }
public static PdfShading Type2(PdfWriter writer, Color colorSpace, float[] coords, float[] domain, PdfFunction function, bool[] extend) { PdfShading sp = new PdfShading(writer); sp.shading = new PdfDictionary(); sp.shadingType = 2; sp.shading.Put(PdfName.SHADINGTYPE, new PdfNumber(sp.shadingType)); sp.SetColorSpace(colorSpace); sp.shading.Put(PdfName.COORDS, new PdfArray(coords)); if (domain != null) { sp.shading.Put(PdfName.DOMAIN, new PdfArray(domain)); } sp.shading.Put(PdfName.FUNCTION, function.Reference); if (extend != null && (extend[0] || extend[1])) { PdfArray array = new PdfArray(extend[0] ? PdfBoolean.PDFTRUE : PdfBoolean.PDFFALSE); array.Add(extend[1] ? PdfBoolean.PDFTRUE : PdfBoolean.PDFFALSE); sp.shading.Put(PdfName.EXTEND, array); } return(sp); }
public static PdfShading Type1(PdfWriter writer, Color colorSpace, float[] domain, float[] tMatrix, PdfFunction function) { PdfShading sp = new PdfShading(writer); sp.shading = new PdfDictionary(); sp.shadingType = 1; sp.shading.Put(PdfName.SHADINGTYPE, new PdfNumber(sp.shadingType)); sp.SetColorSpace(colorSpace); if (domain != null) { sp.shading.Put(PdfName.DOMAIN, new PdfArray(domain)); } if (tMatrix != null) { sp.shading.Put(PdfName.MATRIX, new PdfArray(tMatrix)); } sp.shading.Put(PdfName.FUNCTION, function.Reference); return(sp); }