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 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)); }
private void ReadXRefStream(long offset) { int num3; int num4; int num5; long num6; int num7; XRefEntry entry1; int num8; PDFObject obj1; PDFStream stream1 = (this.ReadDirectFromStream(this.mParser, offset, -1, -1) as PDFStream); if (stream1 == null) { throw new PDFException("Invalid XRef-Stream"); } PDFDict dict1 = stream1.Dict; PDFName name1 = (dict1["Type"] as PDFName); if (name1 == null) { throw new PDFException("Invalid XRef-Stream"); } int[] numArray1 = new int[3]; PDFArray array1 = (dict1["W"] as PDFArray); if (array1 == null) { throw new PDFException("Invalid or missing W entry in XRef stream"); } if (array1.Count != 3) { throw new PDFException("Invalid W entry in XRef stream (wrong number of elements"); } int num1 = 0; foreach (PDFInteger integer1 in array1) { int num9 = num1; num1 = (num9 + 1); numArray1[num1] = integer1.Int32Value; } PDFInteger integer2 = (dict1["Size"] as PDFInteger); if (integer2 == null) { throw new PDFException("Invalid or missing size entry"); } PDFArray array2 = (dict1["Index"] as PDFArray); if (array2 != null) { goto Label_0121; } throw new PDFException("Invalid or missing index entry"); Label_0114: this.mXRef.Add(null); Label_0121: if (((long)this.mXRef.Count) < integer2.Value) { goto Label_0114; } Stream stream2 = stream1.Decode(); byte[] numArray2 = new byte[((numArray1[0] + numArray1[1]) + numArray1[2])]; BitArrayAccessor accessor1 = new BitArrayAccessor(numArray2, 8, false); if (numArray1[1] < 0) { throw new PDFException("Invalid w2 value"); } int num2 = 0; try { while ((num2 < array2.Count)) { num3 = ((PDFInteger)array2[num2]).Int32Value; num4 = (num3 + ((PDFInteger)array2[(num2 + 1)]).Int32Value); num1 = num3; while ((num1 < num4)) { stream2.Read(numArray2, 0, numArray2.Length); if (this.mXRef[num1] != null) { goto Label_02A2; } num5 = ((numArray1[0] == 0) ? 1 : ((int)accessor1.GetBits(((long)0), (numArray1[0] * 8), 1, false, false)[0])); num6 = accessor1.GetBits(((long)(numArray1[0] * 8)), (numArray1[1] * 8), 1, false, false)[0]; if (numArray1[2] == 0) { if (num5 == 1) { num7 = 0; goto Label_023C; } throw new PDFException("Not default value for w3 for this object type"); } num7 = ((int)accessor1.GetBits(((long)((numArray1[0] + numArray1[1]) * 8)), (numArray1[2] * 8), 1, false, false)[0]); Label_023C: entry1 = new XRefEntry(); entry1.type = num5; num8 = num5; switch (num8) { case 0: case 1: { entry1.generation = num7; entry1.offset = num6; goto Label_0293; } case 2: { goto Label_0279; } } goto Label_0293; Label_0279: entry1.generation = 0; entry1.offset = num6; entry1.index = num7; Label_0293: this.mXRef[num1] = entry1; Label_02A2: num1 += 1; } num2 += 2; } } catch (InvalidCastException) { throw new PDFException("Invalid index entry"); } PDFInteger integer3 = (dict1["Prev"] as PDFInteger); if (integer3 != null) { this.ReadXRefStream(integer3.Value); } this.mXRefValid = true; this.mTrailer = new CorePDFDict(); if ((dict1["Root"] != null) && (this.mTrailer["Root"] == null)) { obj1 = dict1["Root"]; this.mTrailer["Root"] = obj1; this.mRoot = ((PDFDict)obj1); } if ((dict1["Info"] is PDFDict) && (this.mTrailer["Info"] == null)) { obj1 = dict1["Info"]; this.mTrailer["Info"] = obj1; this.mInfo = ((PDFDict)obj1); } }
// Methods internal ColorSpaceIndexed(PDFDirect d) : base(d) { PDFString text1; int num2; int num5; byte[] numArray3; int num6; int num7; this.mColors = new ArrayList(); this.Count; PDFObject obj1 = ((PDFArray)d)[3]; byte[] numArray1 = null; int num1 = base.Base.NrOfChannels; if (obj1.PDFType == PDFObjectType.tPDFString) { text1 = ((PDFString)obj1); numArray1 = Encoding.ASCII.GetBytes(text1.Value); for (num2 = 0; (num2 < this.Count); num2 += 1) { this.mColors.Add(new PDFIndexedCSDoubleArrayString(text1, num2, num1, numArray1, (num2 * num1))); } return; } if (obj1.PDFType != PDFObjectType.tPDFStream) { goto Label_01CC; } PDFStream stream1 = ((PDFStream)obj1); Stream stream2 = stream1.Decode(); if (stream2.Length != ((long)-1)) { numArray1 = new byte[((IntPtr)stream2.Length)]; stream2.Read(numArray1, 0, ((int)stream2.Length)); stream2.Close(); goto Label_019B; } ArrayList list1 = new ArrayList(); byte[] numArray2 = new byte[16384]; int num3 = 0; int num4 = 0; goto Label_010A; Label_00F4: num3 += num4; list1.Add(numArray2.Clone()); Label_010A: num4 = stream2.Read(numArray2, 0, numArray2.Length); if (num4 > 0) { goto Label_00F4; } numArray1 = new byte[num3]; for (num5 = 0; (num5 < list1.Count); num5 += 1) { numArray3 = ((byte[])list1[num5]); if (num5 != (list1.Count - 1)) { numArray3.CopyTo(numArray1, (num5 * numArray2.Length)); } else { for (num6 = 0; (num6 < (num3 % numArray2.Length)); num6 += 1) { numArray1[(((num5 * numArray2.Length) * (list1.Count - 1)) + num6)] = numArray3[num6]; } } } Label_019B: num7 = 0; while ((num7 < this.Count)) { this.mColors.Add(new PDFIndexedCSDoubleArrayStream(stream1, num7, num1, numArray1, (num7 * num1))); num7 += 1; } return; Label_01CC: throw new PDFSyntaxException(d, "Invalid Indexed colorsace: Invalid LOOKUP"); }
public Stream GetFontStream() { PDFDict dict1; PDFArray array1; PDFDict dict2; int num1; if (this.IsStandardFont) { return(null); } if (base.GetType().Equals(typeof(FontType0))) { dict1 = ((PDFDict)base.Direct); array1 = (dict1["DescendantFonts"] as PDFArray); if (array1 == null) { throw new ArgumentException("Bad DESCENDANTFONTS entry."); } dict1 = (array1[0] as PDFDict); if (dict1 != null) { goto Label_006E; } throw new ArgumentException("Bad DESCENDANTFONTS entry."); } dict1 = this.Dict; Label_006E: dict2 = (dict1["FontDescriptor"] as PDFDict); if (dict2 == null) { throw new ArgumentException("No FontDescriptor entry for non-standard font."); } PDFStream stream1 = (dict2["FontFile"] as PDFStream); if (stream1 == null) { stream1 = (dict2["FontFile2"] as PDFStream); } if (stream1 == null) { stream1 = (dict2["FontFile3"] as PDFStream); } if (stream1 == null) { return(null); } MemoryStream stream2 = new MemoryStream(); byte[] numArray1 = new byte[65536]; Stream stream3 = stream1.Decode(); goto Label_00F4; Label_00E8: stream2.Write(numArray1, 0, num1); Label_00F4: num1 = stream3.Read(numArray1, 0, 65536); if (num1 != 65536) { return(stream2); } goto Label_00E8; }