title: Getting Dictionary of values from PDF's Internals using iTextSharp and PDFsharp
body: <p>I have a project in which I need to split very large PDF files containing between 150 and 200 thousand pages each. I am currently using the iTextSharp DLL to split some of the PDFs which have the "standard" bookmarks that can be created by Adobe Reader. I am also using PDFsharp to extract text from the PDFs that don't have these "standard" bookmarks, whereupon I parse them for keywords from a database and split them into smaller PDFs. As opposed to the first method, however, this is <strong>extremely</strong> slow. </p>
  
  <hr>
  
  <p>The PDFs that don't have the "standard" bookmarks do, however, have indexes/bookmarks. 
  The problem is that these are created by SOLindexer(<a href="http://www.solimarsystems.com/SOLindexer_Overview.php" rel="nofollow">Link to product page</a>). I was able to find these indexes/bookmarks in the internal COS tree. The path within the internal structure of the PDF to the place I want to get to is "trailer/Info/SSEDictionary/Document_MemberStatements".  Within this directory (if it could be called that) I am able to click on -DATA- and open a notepad file which contains all of the account numbers, names, things I need (of course the format is weird, but readable), and I believe that these are the values that I could put in a dictionary. </p>
  
  <hr>
  
  <p>In iTextSharp and PDFsharp you're able to access the Info section by doing, for example, <code>var stuff = reader.Info.Values</code> or perhaps <code>var stuff = reader.Info.Keys</code>, but those seemed to be dead ends as I could not do anything to get the SSEDictionary contents from there. iTextSharp also allows you to look at the trailer, and I was able to get the keys from there, but past that I could not drill down to the lowest level. I am aware that there is a way to get things from the internals using PDFsharp like so: </p>
  
  <pre><code>PdfSharp.Pdf.PdfDocument inputDocument = PdfSharp.Pdf.IO.PdfReader.Open(MapPath("PDFs/Member Statements/06-2012.pdf"), PdfDocumentOpenMode.ReadOnly);
  PdfSharp.Pdf.PdfDictionary dictionary = (PdfSharp.Pdf.PdfDictionary)inputDocument.Internals.Catalog.Elements.GetObject("/Outlines"); 
  </code></pre>
  
  <hr>
  
  <p>However, I have not been able to figure out how to adapt this to my current situation and the path to the stuff I need.Moreover, I am not quite sure how exactly to do this in iTextSharp (my favorite of the two libraries). Thus, my question would be: how exactly would you get a dictionary (which I believe all of the stuff in the text file I opened up is) in code? Also, what would that code look like? I have a decent understanding of the internal structure of the PDF, but I just don't quite know how to get there. Thanks!</p>