private PDFObject GetWidths(GlyphTypeface glyphTypeface, IIndirectObjectCreator creator, IDictionary <int, ushort> cmap) { PDFArray widths = creator.CreateIndirectArray(); IDictionary <ushort, double> advWidths = glyphTypeface.AdvanceWidths; for (char ch = (char)firstChar; ch <= lastChar; ch++) { int width = 0; if (subsetCharacters.Contains(ch)) { ushort gid; if (cmap.TryGetValue((int)ch, out gid)) { double widthDouble; if (advWidths.TryGetValue(gid, out widthDouble)) { width = (int)(1000 * widthDouble); } } } widths.Array.Add(new PDFInt(width)); } return(widths); }
public void WriteData_Test() { IFileObject[] all = new IFileObject[] { new PDFNumber(1), new PDFNumber(2), new PDFNumber(3) }; PDFArray target = new PDFArray(all); string actual; using (System.IO.MemoryStream stream = new System.IO.MemoryStream()) { using (PDFWriter writer = new PDFWriter14(stream, new Scryber.Logging.DoNothingTraceLog(TraceRecordLevel.Diagnostic))) { target.WriteData(writer); writer.InnerStream.Flush(); } stream.Position = 0; using (System.IO.StreamReader sr = new System.IO.StreamReader(stream)) { actual = sr.ReadToEnd(); } } PDFArray parsed = PDFArray.Parse(actual.Trim()); Assert.AreEqual(parsed.Count, target.Count); Assert.AreEqual(parsed[0], target[0]); Assert.AreEqual(parsed[1], target[1]); Assert.AreEqual(parsed[2], target[2]); }
// Methods public FontType3(PDFDirect d) : base(d) { int num1; PDFNumeric numeric1; PDFArray array1 = (this.Dict["FontMatrix"] as PDFArray); if (array1 == null) { throw new ArgumentException("No FontMatrix entry for the Type3 font."); } if (6 != array1.Count) { throw new ArgumentException("Incorrect FontMatrix entry for the Type3 font. Must have 6 positions."); } double[] numArray1 = new double[6]; for (num1 = 0; (num1 < 6); num1 += 1) { numeric1 = (array1[num1] as PDFNumeric); if (numeric1 == null) { throw new ArgumentException("Incorrect datatype for the entry of FontMatrix array."); } numArray1[num1] = numeric1.DoubleValue; } this.mMatrix = new CTM(numArray1); }
public static TreeNode addArrayItemToTree(PDFArray array, int i, TreeNode parentNode) { string type, value; TreeNode curr = null; if (GetObjectTypeAndValue(array.Get(i), out type, out value)) { if (parentNode.Nodes.Count > i) { parentNode.Nodes.RemoveAt(i); } curr = parentNode.Nodes.Insert(i, value); curr.Tag = array.Get(i); curr.ImageKey = GetObjectIconName((PDFObject)curr.Tag); curr.SelectedImageKey = curr.ImageKey; // If it's an indirect object, append the ID and Generation numbers if ((curr.Tag != null) && ((curr.Tag as PDFObject).Indirect)) { curr.Text += (" [ID: " + (curr.Tag as PDFObject).ID + ", Gen: " + (curr.Tag as PDFObject).Generation + "]"); } } else { throw new IndexOutOfRangeException(); } return(curr); }
// 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; } }
public PDFArray CreateIndirectArray(params double[] realValues) { PDFArray array = new PDFArray(GetNextObjectNumber(), realValues); indirectObjects.Add(array); return(array); }
private void addRadioButton(Field field) { PDFDictionary dict = findRadioButtonGroup(field.Name); if (dict == null) { dict = createRadioButtonGroup(field.Name); } PDFArray kids = dict["Kids"] as PDFArray; if (kids == null) { kids = new PDFArray(); dict.AddItem("Kids", kids); } if (field is RadioButton && (field as RadioButton).Checked == true) { dict.AddItem("V", new PDFName((field as RadioButton).ExportValue)); dict.AddItem("DV", new PDFName((field as RadioButton).ExportValue)); } kids.AddItem(field.Dictionary); field.Dictionary.AddItem("Parent", dict); field.Dictionary.RemoveItem("T"); }
public void Delete(int nr) { PDFDict dict3; PDFDict dict1 = this[nr].Dict; PDFDict dict2 = ((PDFDict)dict1["Parent"]); PDFArray array1 = ((PDFArray)dict2["Kids"]); int num1 = 0; while ((num1 < array1.Count)) { if (array1[num1].Indirect.Id == dict1.Indirect.Id) { break; } num1 += 1; } if (num1 == array1.Count) { throw new PDFException(string.Format("Invalid page tree - invalid parent pointer in page {0}", nr)); } array1.RemoveAt(num1); for (dict3 = dict2; (dict3 != null); dict3 = ((PDFDict)dict3["Parent"])) { PDFInteger integer1 = ((PDFInteger)dict2["Count"]); ((PDFInteger)dict2["Count"]).Value = (integer1.Value - ((long)1)); } }
public PDFArray CreateIndirectArray(params int[] intValues) { PDFArray array = new PDFArray(GetNextObjectNumber(), intValues); indirectObjects.Add(array); return(array); }
/// <summary> /// Gets the value from the index in the /Opt array. /// </summary> protected string ValueInOptArray(int index) { PDFArray opt = Elements.GetArray(Keys.Opt); if (opt != null) { int count = opt.Elements.Count; if (index < 0 || index >= count) { throw new ArgumentOutOfRangeException("index"); } PDFItem item = opt.Elements[index]; if (item is PDFString) { return(item.ToString()); } if (item is PDFArray array) { if (array.Elements.Count != 0) { return(array.Elements[0].ToString()); } } } return(""); }
public void CopyTo_Test() { IFileObject[] all = new IFileObject[] { new PDFNumber(1), new PDFNumber(2), new PDFNumber(3) }; PDFArray target = new PDFArray(all); IFileObject[] array = new IFileObject[all.Length]; int arrayIndex = 0; target.CopyTo(array, arrayIndex); Assert.AreEqual(all[0], array[0]); Assert.AreEqual(all[1], array[1]); Assert.AreEqual(all[2], array[2]); array = new IFileObject[all.Length + 2]; arrayIndex = 2; target.CopyTo(array, arrayIndex); Assert.IsNull(array[0]); Assert.IsNull(array[1]); Assert.AreEqual(all[0], array[2]); Assert.AreEqual(all[1], array[3]); Assert.AreEqual(all[2], array[4]); }
public static PDFArray CreateArray(bool treatStringAsName, object _array) { Array array2; int num1; PDFArray array1 = null; if (_array.GetType().IsArray) { array2 = (_array as Array); array1 = Library.CreateArray(array2.Length); for (num1 = 0; (num1 < array2.Length); num1 += 1) { array1[num1] = Library.CreateObject(treatStringAsName, array2.GetValue(num1)); } return(array1); } if (!(_array is ICollection)) { return(array1); } ICollection collection1 = (_array as ICollection); array1 = Library.CreateArray(collection1.Count); int num2 = 0; foreach (object obj1 in collection1) { int num3 = num2; num2 = (num3 + 1); array1[num2] = Library.CreateObject(treatStringAsName, obj1); } return(array1); }
public static PDFArray PDFColorToPDFArray(DeviceColor value) { PDFArray color = new PDFArray(); switch (value.Colorspace.N) { case 1: color.AddItem(new PDFNumber((value as ColorGray).G * 1.0f / 255)); break; case 3: color.AddItem(new PDFNumber((value as ColorRGB).R * 1.0f / 255)); color.AddItem(new PDFNumber((value as ColorRGB).G * 1.0f / 255)); color.AddItem(new PDFNumber((value as ColorRGB).B * 1.0f / 255)); break; case 4: color.AddItem(new PDFNumber((value as ColorCMYK).C * 1.0f / 255)); color.AddItem(new PDFNumber((value as ColorCMYK).M * 1.0f / 255)); color.AddItem(new PDFNumber((value as ColorCMYK).Y * 1.0f / 255)); color.AddItem(new PDFNumber((value as ColorCMYK).K * 1.0f / 255)); break; } return(color); }
public static void AddDefaultRGB(Document doc) { int num1; if (doc == null) { return; } PDFDict dict1 = Library.CreateDict(); double[] numArray1 = new double[3] { 0.95045f, 1f, 1.08905f }; double[] numArray2 = new double[3] { 2.2f, 2.2f, 2.2f }; double[] numArray3 = new double[9] { 0.4124f, 0.2126f, 0.0193f, 0.3576f, 0.7152f, 0.1192f, 0.1805f, 0.0722f, 0.9505f }; dict1["WhitePoint"] = PDF.O(numArray1); dict1["Gamma"] = PDF.O(numArray2); dict1["Matrix"] = PDF.O(numArray3); PDFArray array1 = Library.CreateArray(2); array1[0] = Library.CreateName("CalRGB"); array1[1] = dict1; PDFIndirect indirect1 = doc.Indirects.New(array1); Resource resource1 = doc.Resources[indirect1, typeof(ColorSpace)]; for (num1 = 0; (num1 < doc.Pages.Count); num1 += 1) { doc.Pages[num1].Resources.Add("DefaultRGB", resource1); } }
private bool containsField(string fieldName, PDFArray fields) { if (fields == null) { return(false); } for (int i = 0; i < fields.Count; ++i) { PDFDictionary dict = fields[i] as PDFDictionary; if (dict != null) { PDFString name = dict["T"] as PDFString; if (name != null && name.GetValue() == fieldName) { return(true); } PDFArray kids = dict["Kids"] as PDFArray; if (kids != null) { return(containsField(fieldName, kids)); } } } return(false); }
public PDFArray CreateIndirectArray() { PDFArray array = new PDFArray(GetNextObjectNumber()); indirectObjects.Add(array); return(array); }
internal static PDFDictionary Copy(PDFDictionary dict) { PDFDictionary result = new PDFDictionary(); string[] keys = { "Type", "Subtype", "R", "CYX", "O" }; for (int i = 0; i < keys.Length; ++i) { IPDFObject obj = dict[keys[i]]; if (obj != null) { result.AddItem(keys[i], obj.Clone()); } } string[] numberFormat = { "X", "Y", "D", "A", "T", "S" }; for (int i = 0; i < numberFormat.Length; ++i) { PDFArray arr = dict[numberFormat[i]] as PDFArray; if (arr != null) { PDFArray newArr = new PDFArray(); for (int j = 0; j < arr.Count; ++i) { PDFDictionary d = arr[i] as PDFDictionary; if (d != null) { newArr.AddItem(NumberFormat.Copy(d)); } } result.AddItem(numberFormat[i], newArr); } } return(result); }
public static ChoiceOptItem Create(string item) { PDFArray array1 = Library.CreateArray(2); array1[0] = Library.CreateString(item); array1[1] = Library.CreateString(item); return(new ChoiceOptItem(array1)); }
public void Clear_Test() { PDFArray target = new PDFArray(new IFileObject[] { new PDFNumber(1), new PDFNumber(2) }); Assert.AreEqual(2, target.Count); target.Clear(); Assert.AreEqual(0, target.Count, "Entries not cleared from array"); }
private void editSelectedArray(PDFArray selectedArray) { string indexString = selectedCell.OwningRow.Cells[0].Value.ToString(); editSelectedArrayValue(selectedArray, int.Parse(indexString.Substring(1, indexString.Length - 2)), selectedCell.Value); selectedNodeBeforeEdit.Tag = selectedArray; docWasModified = true; }
public static LinkDestinationExplicit Create(int page_number) { PDFArray array1 = Library.CreateArray(2); array1[0] = Library.CreateInteger(((long)page_number)); array1[1] = Library.CreateName("Fit"); return(Resources.Get(array1, typeof(LinkDestinationExplicit)) as LinkDestinationExplicit); }
public static LinkDestinationExplicit Create(Page page) { PDFArray array1 = Library.CreateArray(2); array1[0] = page.Dict; array1[1] = Library.CreateName("Fit"); return(Resources.Get(array1, typeof(LinkDestinationExplicit)) as LinkDestinationExplicit); }
private void editSelectedArrayValue(PDFArray selectedArray, int index, object newValue) { PDFObject newPDFObject = createNewValueForSelectedScalar(selectedArray.Get(index), newValue.ToString()); updateArrayValue(selectedArray, index, newPDFObject); //refresh the tree mainWindow.addArrayItemToTree(selectedArray, index, selectedNodeBeforeEdit); mainWindow.expandNode(selectedNodeBeforeEdit); }
public void IsReadOnly_Test() { PDFArray target = new PDFArray(); bool expected = false; bool actual; actual = target.IsReadOnly; Assert.AreEqual(expected, actual, "PDFArray.IsReadOnly returned true - which is wrong"); }
public void WriteArray(PDFArray val) { this.WriteOpenArray(); foreach (object obj1 in val) { this.WriteSp(obj1); } this.WriteCloseArray(); }
// Methods internal PDFCTM(PDFArray arr) { int num1; this.mArr = new PDFDoubleArray(arr, 6); for (num1 = 0; (num1 < 6); num1 += 1) { base[(num1 % 3), (num1 / 2)] = this.mArr[num1]; } }
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 Type_Test() { PDFArray target = new PDFArray(); PDFObjectType actual; actual = target.Type; PDFObjectType expected = PDFObjectTypes.Array; Assert.AreEqual(expected, actual); }
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 ColorSpaceIntensity Create(double[] arr) { int num1; PDFArray array1 = Library.CreateArray(arr.Length); for (num1 = 0; (num1 < arr.Length); num1 += 1) { array1[num1] = Library.CreateFixed(arr[num1]); } return(new ColorSpaceIntensity(array1)); }