iTextSharp.text.pdf.IntHashtable.GetKeys C# (CSharp) Метод

GetKeys() публичный Метод

public GetKeys ( ) : int[]
Результат int[]
        public int[] GetKeys() {
            int[] res = new int[count];
            int ptr = 0;
            int index = table.Length;
            IntHashtableEntry entry = null;
            while (true) {
                if (entry == null)
                    while ((index-- > 0) && ((entry = table[index]) == null));
                if (entry == null)
                    break;
                IntHashtableEntry e = entry;
                entry = e.next;
                res[ptr++] = e.key;
            }
            return res;
        }
    

Usage Example

Пример #1
0
 /**
 * @param fdf
 * @throws IOException
 */
 virtual public void AddComments(FdfReader fdf) {
     if (readers2intrefs.ContainsKey(fdf))
         return;
     PdfDictionary catalog = fdf.Catalog;
     catalog = catalog.GetAsDict(PdfName.FDF);
     if (catalog == null)
         return;
     PdfArray annots = catalog.GetAsArray(PdfName.ANNOTS);
     if (annots == null || annots.Size == 0)
         return;
     RegisterReader(fdf, false);
     IntHashtable hits = new IntHashtable();
     Dictionary<String, PdfObject> irt = new Dictionary<string,PdfObject>();
     List<PdfObject> an = new List<PdfObject>();
     for (int k = 0; k < annots.Size; ++k) {
         PdfObject obj = annots[k];
         PdfDictionary annot = (PdfDictionary)PdfReader.GetPdfObject(obj);
         PdfNumber page = annot.GetAsNumber(PdfName.PAGE);
         if (page == null || page.IntValue >= reader.NumberOfPages)
             continue;
         FindAllObjects(fdf, obj, hits);
         an.Add(obj);
         if (obj.Type == PdfObject.INDIRECT) {
             PdfObject nm = PdfReader.GetPdfObject(annot.Get(PdfName.NM));
             if (nm != null && nm.Type == PdfObject.STRING)
                 irt[nm.ToString()] = obj;
         }
     }
     int[] arhits = hits.GetKeys();
     for (int k = 0; k < arhits.Length; ++k) {
         int n = arhits[k];
         PdfObject obj = fdf.GetPdfObject(n);
         if (obj.Type == PdfObject.DICTIONARY) {
             PdfObject str = PdfReader.GetPdfObject(((PdfDictionary)obj).Get(PdfName.IRT));
             if (str != null && str.Type == PdfObject.STRING) {
                 PdfObject i;
                 irt.TryGetValue(str.ToString(), out i);
                 if (i != null) {
                     PdfDictionary dic2 = new PdfDictionary();
                     dic2.Merge((PdfDictionary)obj);
                     dic2.Put(PdfName.IRT, i);
                     obj = dic2;
                 }
             }
         }
         AddToBody(obj, GetNewObjectNumber(fdf, n, 0));
     }
     for (int k = 0; k < an.Count; ++k) {
         PdfObject obj = an[k];
         PdfDictionary annot = (PdfDictionary)PdfReader.GetPdfObject(obj);
         PdfNumber page = annot.GetAsNumber(PdfName.PAGE);
         PdfDictionary dic = reader.GetPageN(page.IntValue + 1);
         PdfArray annotsp = (PdfArray)PdfReader.GetPdfObject(dic.Get(PdfName.ANNOTS), dic);
         if (annotsp == null) {
             annotsp = new PdfArray();
             dic.Put(PdfName.ANNOTS, annotsp);
             MarkUsed(dic);
         }
         MarkUsed(annotsp);
         annotsp.Add(obj);
     }
 }