title: split huge 40000 page pdf into single pages, itextsharp, outofmemoryexception
body: <p>I am getting huge PDF files with lots of data. The current PDF is 350 MB and has about 40000 pages. It would of course have been nice to get smaller PDFs, but this is what I have to work with now :-(</p>
  
  <p>I can open it in acrobat reader with some delay when loading but after that acrobat reader is quick.</p>
  
  <p>Now I need to split the huge file into single pages, then try to read some recipient data from the pdf pages, and then send the one or two pages that each recipient should get to each particular recipient.</p>
  
  <p>Here is my very small code so far using itextsharp:</p>
  
  <pre><code>var inFileName = @"huge350MB40000pages.pdf";
  PdfReader reader = new PdfReader(inFileName);
  var nbrPages = reader.NumberOfPages;
  reader.Close();
  </code></pre>
  
  <p>What happens is it comes to the second line "new PdfReader" then stays there for perhaps 10 minutes, the process gets to about 1.7 GB in size, and then I get an OutOfMemoryException.</p>
  
  <p>I think the "new PdfReader" attempts to read the entire PDF into memory.</p>
  
  <p>Is there some other/better way to do this?
  For example, can I somehow read only a part of a PDF file into memory instead of all of it at once?
  Could it work better using some other library than itextsharp?</p>