public void Add_Test() { PDFArray target = new PDFArray(); IFileObject item = new PDFNumber(1); target.Add(item); Assert.AreEqual(1, target.Count); target.Add(item); Assert.AreEqual(2, target.Count, "Entries not added to array"); }
// Methods internal PDFInt64Array(PDFArray arr) : base(arr.Count) { int num2; int num3; this.mPDFArr = null; this.mPDFFix = null; this.mParent = null; this.mKeyName = null; this.mAsFixed = false; this.mPDFArr = arr; int num1 = arr.Count; if (arr.Count != num1) { arr.Clear(); for (num2 = 0; (num2 < num1); num2 += 1) { arr.Add(Library.CreateFixed(0f)); } } for (num3 = 0; (num3 < num1); num3 += 1) { this.mArr[num3] = ((PDFInteger)arr[num3]).Value; } }
private static void AddResource(ref PDFArray arr, DocResourceSet res) { foreach (Resource resource1 in res) { arr.Add(resource1.Direct); if (resource1.Dict["OPI"] != null) { arr.Add(resource1.Dict["OPI"].Direct); } if (resource1.Resources == null) { continue; } ObjectCollection.AddResource(arr, resource1.Resources); } }
public void AddLinkAnnotation(double left, double bottom, double right, double top, PDFObject uri_action) { PDFDict dict1 = Library.CreateDict(); dict1["Type"] = Library.CreateName("Annot"); dict1["Subtype"] = Library.CreateName("Link"); PDFDict dict2 = Library.CreateDict(); dict2["W"] = Library.CreateInteger(((long)0)); dict1["BS"] = dict2; PDFArray array1 = Library.CreateArray(0); array1.Add(Library.CreateFixed(0f)); array1.Add(Library.CreateFixed(0f)); array1.Add(Library.CreateFixed(0f)); dict1["Border"] = array1; PDFArray array2 = Library.CreateArray(0); array2.Add(Library.CreateFixed(left)); array2.Add(Library.CreateFixed(bottom)); array2.Add(Library.CreateFixed(right)); array2.Add(Library.CreateFixed(top)); dict1["Rect"] = array2; if (uri_action != null) { dict1["A"] = uri_action; } Document document1 = this.mPage.Dict.Doc; PDFIndirect indirect1 = document1.Indirects.New(dict1); PDFArray array3 = null; PDFObject obj1 = this.mPage.Dict["Annots"]; if ((obj1 != null) && (obj1.PDFType == PDFObjectType.tPDFArray)) { array3 = ((PDFArray)obj1.Direct); } else { array3 = Library.CreateArray(0); this.mPage.Dict["Annots"] = array3; } array3.Add(indirect1); }
public void Add_Test1() { IFileObject[] all = new IFileObject[] { new PDFNumber(1), new PDFNumber(2), new PDFNumber(3) }; IObjectContainer target = new PDFArray(all); IFileObject obj = new PDFNumber(4); target.Add(obj); Assert.AreEqual(4, ((PDFArray)target).Count); }
public void Add(XObjectImage img) { PDFArray array1 = (this.mParent.Dict["Alternates"] as PDFArray); if (array1 == null) { array1 = Library.CreateArray(0); this.mParent.Dict["Alternates"] = array1; } array1.Add(img.Direct); }
public static IndexList Create(int[] list) { int num1; PDFArray array1 = Library.CreateArray(0); for (num1 = 0; (num1 < list.Length); num1 += 1) { array1.Add(Library.CreateInteger(((long)list[num1]))); } return(new IndexList(array1)); }
public static ObjectCollection Create(Page page) { PDFArray array1 = Library.CreateArray(0); foreach (PDFStream stream1 in page.Contents) { array1.Add(stream1.Direct); } ObjectCollection.AddResource(ref array1, page.Resources); return(new ObjectCollection(array1)); }
/// <summary> /// Adds a reference to a page object /// </summary> /// <param name="refToPage">The reference to the page object</param> /// <returns>True is sucess</returns> public bool AddPageRef(Reference refToPage) { if (refToPage.ReferredObject.ReferredObject is Page) { _arrkids.Add(refToPage); return(true); } else { return(false); } }
private void SetArraySize(int size) { PDFArray array1 = (base.Direct as PDFArray); while ((size < array1.Count)) { array1.RemoveAt((array1.Count - 1)); } while ((size > array1.Count)) { array1.Add(Library.CreateNull()); } }
public void Count_Test() { IFileObject[] all = new IFileObject[] { new PDFNumber(1), new PDFNumber(2), new PDFNumber(3) }; PDFArray target = new PDFArray(all); int expected = all.Length; int actual = target.Count; Assert.AreEqual(expected, actual, "PDFArray.Count returned the incorrect value"); target.Add(new PDFNumber(4)); expected += 1; actual = target.Count; Assert.AreEqual(expected, actual, "PDFArray.Count returned the incorrect value"); }
private PDFDict SplitNode(PDFDict curr, int index, PDFDict splinter) { PDFDict dict1; PDFArray array2; int num1; PDFArray array3; PDFArray array4; PDFArray array1 = (curr["Kids"] as PDFArray); if (index == (array1.Count - 1)) { array1.Add(splinter); } else { array1.Insert((index + 1), splinter); } if (array1.Count > this.mMaxKids) { dict1 = Library.CreateDict(); Library.CreateIndirect(dict1); array2 = Library.CreateArray(); dict1["Kids"] = array2; num1 = (array1.Count / 2); while ((array1.Count > num1)) { array2.Insert(0, array1.RemoveAt((array1.Count - 1))); } array3 = Library.CreateArray(2); dict1["Limits"] = array3; array3[0] = ((array2[0] as PDFDict)["Limits"] as PDFArray)[0]; array3[1] = ((array2[(array2.Count - 1)] as PDFDict)["Limits"] as PDFArray)[1]; array4 = Library.CreateArray(2); array4[0] = ((array1[0] as PDFDict)["Limits"] as PDFArray)[0]; array4[1] = ((array1[(array1.Count - 1)] as PDFDict)["Limits"] as PDFArray)[1]; curr["Limits"] = array4; return(dict1); } return(null); }
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 static Altsoft.PDFO.Font EmbedFont(Document doc, Stream fontstream, string encoding, bool embedFontFile, bool isVertical) { int num2; PDFArray array2; int num10; Altsoft.FTMB.Font font1 = Altsoft.FTMB.Font.OpenFont(fontstream); if ((font1.FontType != FontType.TrueTypeFontT) || (encoding != "Unicode")) { return(null); } TrueTypeFont font2 = (font1 as TrueTypeFont); double num1 = ((double)font2.UnitsPerEm); PDFDict dict1 = Library.CreateDict(); dict1["Type"] = Library.CreateName("Font"); dict1["Subtype"] = Library.CreateName("CIDFontType2"); dict1["BaseFont"] = Library.CreateName(font2.FontName); PDFDict dict2 = Library.CreateDict(); dict2["Registry"] = Library.CreateString("Adobe"); dict2["Ordering"] = Library.CreateString("Identity"); dict2["Supplement"] = Library.CreateInteger(((long)0)); dict1["CIDSystemInfo"] = dict2; TTEncoding encoding1 = null; for (num2 = 0; ((num2 < font2.Encodings.Count) && (encoding1 == null)); num2 += 1) { encoding1 = ((TTEncoding)font2.Encodings[num2]); if ((encoding1.platformID != 3) || ((encoding1.specificID != 1) && (encoding1.specificID != 0))) { encoding1 = null; } } if (encoding1 == null) { return(null); } dict1["DW"] = Library.CreateInteger(((long)((((double)font2.GetWidth(encoding1.GetGID(0))) * 1000f) / num1))); int num3 = 0; int num4 = encoding1.GetLastCharCode(ref num3); int num5 = encoding1.GetFirstCharCode(ref num3); PDFArray array1 = Library.CreateArray(0); if (num5 != 0) { array1.Add(Library.CreateInteger(((long)0))); array2 = Library.CreateArray(0); array2.Add(Library.CreateInteger(((long)((((double)font2.GetWidth(0, 3, 1)) * 1000f) / num1)))); array1.Add(array2); } array1.Add(Library.CreateInteger(((long)num5))); array2 = Library.CreateArray(0); array2.Add(Library.CreateInteger(((long)((((double)font2.GetWidth(num3)) * 1000f) / num1)))); int num6 = num5; while ((num5 != num4)) { num5 = encoding1.GetNextCharCode(num5, ref num3); if (num5 != (num6 + 1)) { array1.Add(array2); array1.Add(Library.CreateInteger(((long)num5))); array2 = Library.CreateArray(0); } num6 = num5; array2.Add(Library.CreateInteger(((long)((((double)font2.GetWidth(num3)) * 1000f) / num1)))); } array1.Add(array2); dict1["W"] = array1; Stream stream1 = new MemoryStream(); int num7 = encoding1.GetFirstCharCode(ref num3); int num8 = 0; while ((num8 < num7)) { stream1.WriteByte(0); stream1.WriteByte(0); num8 += 1; } stream1.WriteByte(((byte)(num3 / 256))); stream1.WriteByte(((byte)(num3 % 256))); num8 += 1; int num9 = encoding1.GetLastCharCode(ref num3); do { num7 = encoding1.GetNextCharCode(num7, ref num3); while ((num8 < num7)) { stream1.WriteByte(0); stream1.WriteByte(0); num8 += 1; } stream1.WriteByte(((byte)(num3 / 256))); stream1.WriteByte(((byte)(num3 % 256))); num8 += 1; }while ((num7 != num9)); stream1.Position = ((long)0); PDFDict dict3 = Library.CreateDict(); dict3["Filter"] = Library.CreateName("FlateDecode"); PDFStream stream2 = Library.CreateStream(stream1, dict3); dict1["CIDToGIDMap"] = doc.Indirects.New(stream2); PDFDict dict4 = Library.CreateDict(); dict4["Type"] = Library.CreateName("FontDescriptor"); dict4["FontName"] = Library.CreateName(font2.FontName); dict4["Flags"] = Library.CreateInteger(((long)4)); PDFArray array3 = Library.CreateArray(4); for (num10 = 0; (num10 < 4); num10 += 1) { array3[num10] = Library.CreateInteger(((long)font2.FontBBox[num10])); } dict4["FontBBox"] = array3; dict4["ItalicAngle"] = Library.CreateFixed(font2.ItalicAngle); dict4["Ascent"] = Library.CreateInteger(((long)font2.FontBBox[3])); dict4["Descent"] = Library.CreateInteger(((long)font2.FontBBox[1])); dict4["CapHeight"] = Library.CreateInteger(((long)font2.FontBBox[3])); dict4["StemV"] = Library.CreateInteger(((long)0)); if (((font2.EmbeddingRights == 0) || ((font2.EmbeddingRights & 8) != 0)) && embedFontFile) { font2.FontStream.Position = ((long)0); dict3 = Library.CreateDict(); dict3["Filter"] = Library.CreateName("FlateDecode"); dict3["Length1"] = Library.CreateInteger(font2.FontStream.Length); dict4["FontFile2"] = doc.Indirects.New(Library.CreateStream(font2.FontStream, dict3)); } dict1["FontDescriptor"] = doc.Indirects.New(dict4); PDFDict dict5 = Library.CreateDict(); dict5["Type"] = Library.CreateName("Font"); dict5["Subtype"] = Library.CreateName("Type0"); dict5["BaseFont"] = Library.CreateName(font2.FontName); if (!isVertical) { dict5["Encoding"] = Library.CreateName("Identity-H"); } else { dict5["Encoding"] = Library.CreateName("Identity-V"); } PDFArray array4 = Library.CreateArray(1); array4[0] = doc.Indirects.New(dict1); dict5["DescendantFonts"] = array4; return(new FontType0(dict5)); }