public static OutlineItem Create() { PDFDict dict1 = Library.CreateDict(); dict1["Type"] = PDF.N("Outlines"); dict1["Count"] = PDF.O(0); Library.CreateIndirect(dict1); return(Resources.Get(dict1, typeof(OutlineItem)) as OutlineItem); }
public void Clear() { if (base.Direct == null) { throw new PDFException("Attempt to remove from non-existing outline collection"); } this.Dict.Remove("First"); this.Dict.Remove("Last"); this.Dict["Count"] = PDF.O(0); }
public PDFDict CreateEncryptionDict(Document doc) { PDFDict dict1 = Library.CreateDict(); this.mDocId = doc.Id1; dict1["V"] = PDF.O(2); dict1["O"] = PDF.S(this.OEntry); dict1["U"] = PDF.S(this.UEntry); dict1["R"] = PDF.O(this.Rev); dict1["P"] = PDF.O(this.UserPermissions); dict1["Length"] = PDF.O(this.KeyLength); dict1["Filter"] = PDF.N("Standard"); return(dict1); }
public static ColorSpaceIndexed Create(bool indirect, ColorSpace baseCS) { PDFArray array1 = Library.CreateArray(4); array1[0] = PDF.N("Indexed"); array1[1] = baseCS.Direct; array1[2] = PDF.O(0); array1[3] = PDF.O(""); ColorSpaceIndexed indexed1 = (Resources.Get(array1, typeof(ColorSpaceIndexed)) as ColorSpaceIndexed); if (indirect) { Library.CreateIndirect(indexed1.Direct); } return(indexed1); }
public static ColorSpaceCalRGB Create(bool indirect, double[] whitePoint) { PDFArray array1 = Library.CreateArray(2); array1[0] = PDF.N("CalRGB"); PDFDict dict1 = Library.CreateDict(); array1[1] = dict1; dict1["WhitePoint"] = PDF.O(whitePoint); ColorSpaceCalRGB lrgb1 = (Resources.Get(array1, typeof(ColorSpaceCalRGB)) as ColorSpaceCalRGB); if (indirect) { Library.CreateIndirect(array1); } return(lrgb1); }
public PDFObject this[string index] { get { return this[index, 0]; } set { PDFArray array1; PDFDict dict3; PDFArray array2; if (this.mParentDict == null) { throw new InvalidOperationException("Attempt to modify non-existing nametree"); } PDFDict dict1 = (this.mParentDict[this.mParentKey] as PDFDict); if (dict1 == null) { dict1 = Library.CreateDict(); this.mParentDict[this.mParentKey] = Library.CreateIndirect(dict1); array1 = Library.CreateArray(2); dict1["Names"] = array1; array1[0] = PDF.O(index); array1[1] = value; return; } PDFDict dict2 = this.SetItem(dict1, index, value); if (dict2 != null) { dict3 = Library.CreateDict(); Library.CreateIndirect(dict3); array2 = Library.CreateArray(2); array2[0] = dict1; array2[1] = dict2; dict3["Kids"] = array2; this.mParentDict[this.mParentKey] = dict3; } } }
public static EncryptionPKCS Create(X509Certificate[] certs, UserAccessPermissions[] perms, int keyLength) { int num1; Random random1 = new Random(); EncryptionPKCS npkcs1 = new EncryptionPKCS(); npkcs1.mSeed = new byte[20]; random1.NextBytes(npkcs1.mSeed); npkcs1.mDict = Library.CreateDict(); npkcs1.mDict["V"] = PDF.O(2); npkcs1.mDict["R"] = PDF.O(1); PDFArray array1 = Library.CreateArray(); npkcs1.mDict["Recipients"] = array1; for (num1 = 0; (num1 < certs.Length); num1 += 1) { array1.Add(npkcs1.CreateRecipientString(certs[num1], perms[num1], keyLength)); } npkcs1.mDict["Length"] = PDF.O(keyLength); npkcs1.mDict["Filter"] = PDF.N("Adobe.PubSec"); return(npkcs1); }
private PDFDict SetItem(PDFDict curr, string index, PDFObject value) { bool flag1; int num1; PDFString text1; PDFArray array3; int num2; PDFArray array4; PDFDict dict1; PDFArray array5; PDFArray array6; int num3; PDFDict dict2; PDFArray array7; PDFString text2; PDFString text3; PDFDict dict3; PDFArray array8; PDFObject obj1; PDFArray array1 = (curr["Names"] as PDFArray); PDFArray array2 = (curr["Kids"] as PDFArray); if (array1 != null) { if ((array1.Count % 2) != 0) { throw new InvalidOperationException("Attempt to manipulate invalid name tree"); } flag1 = true; for (num1 = 0; (num1 < (array1.Count / 2)); num1 += 1) { text1 = (array1[(2 * num1)] as PDFString); if (text1 == null) { throw new InvalidOperationException("Attempt to manipulate invalid name tree"); } if (text1.Value == index) { array1[((2 * num1) + 1)] = value; return null; } if (string.Compare(text1.Value, index, false) > 0) { array1.Insert((2 * num1), value); array1.Insert((2 * num1), PDF.O(index)); flag1 = false; break; } } if (flag1) { array1.Add(PDF.O(index)); array1.Add(value); array3 = (curr["Limits"] as PDFArray); if (array3 != null) { ((PDFString) array3[1]).Value = index; } } if ((array1.Count / 2) > this.mMaxKids) { num2 = (array1.Count / 2); array4 = Library.CreateArray(0); dict1 = Library.CreateDict(); Library.CreateIndirect(dict1); while ((array1.Count > num2)) { array4.Insert(0, array1.RemoveAt((array1.Count - 1))); array4.Insert(0, array1.RemoveAt((array1.Count - 1))); } array5 = Library.CreateArray(1); array5[0] = array1[0]; array5[1] = array1[(array1.Count - 2)]; curr["Limits"] = array5; dict1["Names"] = array4; array6 = Library.CreateArray(0); array6[0] = array4[0]; array6[1] = array4[(array4.Count - 2)]; dict1["Limits"] = array6; return dict1; } return null; } if (array2 != null) { for (num3 = 0; (num3 < array2.Count); num3 += 1) { dict2 = (array2[num3] as PDFDict); if (dict2 == null) { throw new InvalidOperationException("Attempt to manipulate invalid name tree"); } array7 = (dict2["Limits"] as PDFArray); if (array7.Count != 2) { throw new InvalidOperationException("Attempt to manipulate invalid name tree"); } text2 = (array7[0] as PDFString); text3 = (array7[1] as PDFString); if ((text2 == null) || (text3 == null)) { throw new InvalidOperationException("Attempt to manipulate invalid name tree"); } if (((string.Compare(index, text2.Value) < 0) || (string.Compare(index, text3.Value) < 0)) || ((num3 + 1) == array2.Count)) { dict3 = this.SetItem(dict2, index, value); if (string.Compare(index, text2.Value) < 0) { array7[0] = PDF.O(index); } if (dict3 != null) { return this.SplitNode(curr, num3, dict3); } return null; } } } else { array1 = Library.CreateArray(2); curr["Names"] = array1; array8 = Library.CreateArray(2); obj1 = PDF.O(index); array1[0] = obj1; obj1 = obj1; array8[1] = obj1; array8[0] = obj1; array1[1] = value; } return null; }
public Page Insert(int nr, PDFObject page) { PDFDict dict1; PDFArray array1; int num1; PDFDict dict2; PDFDict dict3; PDFDict dict4; PDFIndirect indirect1; PDFArray array2; int num2; int num3; PDFDict dict5; int num4; PDFDict dict6; PDFArray array3; PDFDict dict7; PDFArray array4; int num5; Page page1; Page page2; PDFDict dict8; PDFObject obj1; try { if (nr > this.Count) { throw new ArgumentOutOfRangeException("nr", nr, "New page number should be less or equal to page count"); } if (this.mPagesDict == null) { dict8 = Library.CreateDict(); this.mPagesDict = dict8; this.mDoc.Root["Pages"] = Library.CreateIndirect(dict8); } dict1 = null; array1 = null; num1 = 0; if (this.Count == 0) { dict1 = this.mPagesDict; array1 = ((PDFArray)dict1["Kids"]); if (array1 == null) { obj1 = Library.CreateArray(0); dict1["Kids"] = obj1; array1 = ((PDFArray)obj1); } dict1["Count"] = PDF.O(0); } else { dict2 = this[((nr > 0) ? (nr - 1) : 0)].Dict; dict1 = ((PDFDict)dict2["Parent"]); array1 = ((PDFArray)dict1["Kids"]); if (nr > 0) { num1 = 0; while ((num1 < array1.Count)) { if (array1[num1].Indirect.Id == dict2.Indirect.Id) { break; } num1 += 1; } if (num1 == array1.Count) { throw new PDFException(string.Format("Invalid page tree - invalid parent pointer in page {0}", nr)); } num1 += 1; } else { num1 = 0; } } array1.Insert(num1, page); ((PDFDict)page.Direct)["Parent"] = dict1.Indirect; for (dict3 = dict1; (dict3 != null); dict3 = ((PDFDict)dict3["Parent"])) { PDFInteger integer1 = ((PDFInteger)dict3["Count"]); ((PDFInteger)dict3["Count"]).Value = (integer1.Value + ((long)1)); } while ((array1.Count > PagesCollection.MaxKids)) { dict4 = Library.CreateDict(); indirect1 = this.mDoc.Indirects.New(dict4); dict4["Type"] = Library.CreateName("Pages"); obj1 = Library.CreateArray(0); dict4["Kids"] = obj1; array2 = ((PDFArray)obj1); num2 = ((PDFNumeric)dict1["Count"]).Int32Value; num3 = 0; while ((array1.Count > (PagesCollection.MaxKids / 2))) { dict5 = ((PDFDict)array1[(PagesCollection.MaxKids / 2)]); array1.RemoveAt((PagesCollection.MaxKids / 2)); dict5["Parent"] = dict4.Indirect; num4 = 0; if (((PDFName)dict5["Type"]).Value.Equals("Pages")) { num4 = ((PDFNumeric)dict5["Count"]).Int32Value; } else { num4 = 1; } num2 -= num4; num3 += num4; array2.Add(dict5.Indirect); } ((PDFInteger)dict1["Count"]).Value = ((long)num2); dict4["Count"] = Library.CreateInteger(((long)num3)); if (dict1["Parent"] == null) { dict6 = Library.CreateDict(); this.mDoc.Indirects.New(dict6); dict6["Type"] = Library.CreateName("Pages"); dict6["Count"] = Library.CreateInteger(((long)(num3 + num2))); obj1 = Library.CreateArray(0); dict6["Kids"] = obj1; array3 = ((PDFArray)obj1); array3.Add(dict1.Indirect); array3.Add(dict4.Indirect); dict1["Parent"] = dict6.Indirect; dict4["Parent"] = dict6.Indirect; this.mDoc.Root["Pages"] = dict6.Indirect; dict1 = dict6; } else { dict4["Parent"] = dict1["Parent"].Indirect; dict7 = ((PDFDict)dict1["Parent"]); array4 = ((PDFArray)dict7["Kids"]); num5 = 0; while ((num5 < array4.Count)) { if (array4[num5].Indirect.Id == dict1.Indirect.Id) { break; } num5 += 1; } if (num5 == array4.Count) { throw new PDFException("Invalid page tree - invalid parent pointer"); } array4.Insert((num5 + 1), indirect1); dict1 = dict7; } array1 = ((PDFArray)dict1["Kids"]); } page1 = (Resources.Get(page, typeof(Page)) as Page); this.mPagesColl.Insert(nr, page); return(page1); } catch (InvalidCastException) { throw new PDFSyntaxException("Invalid PDF page tree"); } return(page2); }
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); }