2012-09-21 53 views
0
PdfReader reader = new PdfReader(path); 
    for (int i = 0; i < reader.XrefSize; i++) 
     { 
     PdfObject pdfobj = reader.GetPdfObject(i); 
     if (pdfobj == null || !pdfobj.IsStream()) 
     { 
      continue; 
     } 
     PdfStream stream = (PdfStream) pdfobj; 
    for (TernaryTree.Iterator it = (TernaryTree.Iterator)stream.Keys; it.HasMoreElements();)// Error 
      { 
       PdfName name = (PdfName)it.NextElement(); 
       PdfObject pdobj = stream.Get(name); 
       if (pdobj is PRIndirectReference) 
       { 
        PRIndirectReference inref = (PRIndirectReference)pdobj; 
       } 
      } 

如何正確地將類型轉換爲迭代器的鍵?C#中的Itextsharp TernaryTree.Iterator

在Java的源代碼

看起來是這樣的:

for (Iterator it = stream.getKeys().iterator(); it.hasNext();) 

回答

0

試試這個:

 PdfReader reader = new PdfReader(inputFileName); 
     for (int i = 0; i < reader.XrefSize; i++) 
     { 
      PdfObject pdfobj = reader.GetPdfObject(i); 
      if (pdfobj == null || !pdfobj.IsStream()) 
       continue; 

      PdfStream stream = (PdfStream)pdfobj; 
      foreach (KeyValuePair<PdfName, PdfObject> kv in stream) 
      { 
       PdfName name = kv.Key; 
       PdfObject pdobj = stream.Get(name); 
       if (pdobj is PRIndirectReference) 
        PRIndirectReference inref = (PRIndirectReference)pdobj; 
      } 
     }