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;
                }
            }

如何正确地将类型键转换为迭代器?

在 Java 的源代码中看起来像这样:

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

1 回答 1

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;
            }
        }
于 2013-09-19T08:31:07.543 回答