public PDFStream InsertStream(Stream s, int nr) { PDFStream stream1 = Library.CreateStream(); this.InsertStream(stream1, nr); stream1.Encode(s); return(stream1); }
public PDFStream AppendStream(Stream s_before, Stream s_after, int nr) { Stream stream2; InputStreamArray array1; Stream[] streamArray1; if (this.Count == 0) { this.AddStream(Stream.Null); } PDFStream stream1 = this.GetPDFStream(nr); if (stream1 == null) { return(null); } if ((s_before == null) && (s_after == null)) { return(stream1); } if (stream1.Dict["Filter"] != null) { stream2 = stream1.Decode(); stream1.Dict.Remove("Filter"); stream1.Dict.Remove("DecodeParms"); stream1.Encode(stream2); } if (s_before != null) { if (s_after != null) { streamArray1 = new Stream[3]; streamArray1[0] = s_before; streamArray1[1] = this.GetPDFStream(nr).Decode(); streamArray1[2] = s_after; array1 = new InputStreamArray(streamArray1); } else { streamArray1 = new Stream[2]; streamArray1[0] = s_before; streamArray1[1] = this.GetPDFStream(nr).Decode(); array1 = new InputStreamArray(streamArray1); } } else { streamArray1 = new Stream[2]; streamArray1[0] = this.GetPDFStream(nr).Decode(); streamArray1[1] = s_after; array1 = new InputStreamArray(streamArray1); } this.GetPDFStream(nr).Encode(array1); return(this.GetPDFStream(nr)); }
public PDFStream AppendStream(string s, int nr) { Stream stream2; PDFStream stream1 = this.GetPDFStream(nr); if (stream1.Dict["Filter"] != null) { stream2 = stream1.Decode(); stream1.Dict.Remove("Filter"); stream1.Dict.Remove("DecodeParms"); stream1.Encode(stream2); } return(this.AppendStream(new MemoryStream(Utils.StringToBytes(s)), nr)); }
public static ColorSpaceICCBased Create(Document doc, bool indirect, Stream profile, params string[] encoding) { PDFArray array2; int num2; PDFArray array1 = Library.CreateArray(2); array1[0] = PDF.N("ICCBased"); PDFStream stream1 = Library.CreateStream(); byte[] numArray1 = new byte[30]; profile.Position = ((long)0); int num1 = profile.Read(numArray1, 0, 30); if (num1 == 0) { throw new Exception("Empty ICC profile"); } string text1 = Utils.BytesToString(numArray1); if (text1.IndexOf("GRAY") != -1) { stream1.Dict["N"] = Library.CreateInteger(((long)1)); } if (text1.IndexOf("RGB") != -1) { stream1.Dict["N"] = Library.CreateInteger(((long)3)); } if (text1.IndexOf("CMYK") != -1) { stream1.Dict["N"] = Library.CreateInteger(((long)4)); } if ((encoding != null) && (encoding.Length > 0)) { array2 = Library.CreateArray(encoding.Length); stream1.Dict["Filter"] = array2; for (num2 = 0; (num2 < encoding.Length); num2 += 1) { array2[num2] = PDF.N(encoding[num2]); } } stream1.Encode(profile); array1[1] = doc.Indirects.New(stream1); ColorSpaceICCBased based1 = (Resources.Get(array1, typeof(ColorSpaceICCBased)) as ColorSpaceICCBased); if (indirect) { doc.Indirects.New(array1); } return(based1); }
public PDFStream AppendStream(PDFStream s, int nr) { Stream stream2; if (this.Count == 0) { this.AddStream(Stream.Null); } PDFStream stream1 = this.GetPDFStream(nr); if (stream1.Dict["Filter"] != null) { stream2 = stream1.Decode(); stream1.Dict.Remove("Filter"); stream1.Dict.Remove("DecodeParms"); stream1.Encode(stream2); } return(this.AppendStream(s.Decode(), nr)); }
public PDFStream AppendStream(Stream s, int nr) { Stream stream2; if (this.Count == 0) { this.AddStream(Stream.Null); } PDFStream stream1 = this.GetPDFStream(nr); if (stream1.Dict["Filter"] != null) { stream2 = stream1.Decode(); stream1.Dict.Remove("Filter"); stream1.Dict.Remove("DecodeParms"); stream1.Encode(stream2); } Stream[] streamArray1 = new Stream[2]; streamArray1[0] = this.GetPDFStream(nr).Decode(); streamArray1[1] = s; this.GetPDFStream(nr).Encode(new InputStreamArray(streamArray1)); return(this.GetPDFStream(nr)); }
public static XObjectImage Create(Document doc, Bitmap img, params string[] encoding) { int num3; int num4; int num5; Color color1; int num6; PDFArray array1; int num7; int num8; PDFStream stream1 = Library.CreateStream(); PDFDict dict1 = stream1.Dict; dict1["Width"] = PDF.O(img.Width); dict1["Height"] = PDF.O(img.Height); dict1["Subtype"] = PDF.N("Image"); dict1["Type"] = PDF.N("XObject"); byte[] numArray1 = null; BitArrayAccessor accessor1 = null; int num1 = 0; int num2 = 0; if (doc == null) { doc = Library.Resources.Doc; } XObjectImage image1 = ((XObjectImage)doc.Resources[doc.Indirects.New(stream1), typeof(XObjectImage)]); image1.ColorSpace = ColorSpaceDeviceRGB.Create(); numArray1 = new byte[((3 * img.Width) * img.Height)]; num1 = 8; num2 = (3 * img.Width); dict1["BitsPerComponent"] = PDF.O(8); for (num3 = 0; (num3 < img.Height); num3 += 1) { num4 = 0; accessor1 = new BitArrayAccessor(numArray1, ((num3 * num2) * 8), num1, false); for (num5 = 0; (num5 < img.Width); num5 += 1) { color1 = img.GetPixel(num5, num3); num6 = 0; while ((num6 < 3)) { num8 = num6; switch (num8) { case 0: { int num9 = num4; num4 = (num9 + 1); accessor1[num4] = ((long)((ulong)color1.R)); goto Label_0180; } case 1: { int num10 = num4; num4 = (num10 + 1); accessor1[num4] = ((long)((ulong)color1.G)); goto Label_0180; } case 2: { goto Label_016B; } } goto Label_0180; Label_016B: int num11 = num4; num4 = (num11 + 1); accessor1[num4] = ((long)((ulong)color1.B)); Label_0180: num6 += 1; } } } MemoryStream stream2 = new MemoryStream(numArray1); if (encoding.Length > 0) { array1 = Library.CreateArray(encoding.Length); stream1.Dict["Filter"] = array1; for (num7 = 0; (num7 < encoding.Length); num7 += 1) { array1[num7] = PDF.N(encoding[num7]); } } stream1.Encode(stream2); return(image1); }