title: Reading a part of PDF file in c#
body: <p>I have many large size PDF files that I need to only read a part of them. I want to start reading the PDF file and write it to another file like a txt file, or any other type of files.
  However, I want to make a limitation on the size of the file that I am writing in. When the size of txt file is about 15 MB, I should stop reading the PDF document and then I keep the created txt file for my purpose.
  Does anyone can help me how can I do this in C#?</p>
  
  <p>Thanks for your help in advance.</p>
  
  <p>Here is the code that I use for reading the whole file; (image content is not important for me)</p>
  
  <pre><code>using (StreamReader sr = new StreamReader(@"F:\1.pdf"))
          {
              using (StreamWriter sw = new StreamWriter(@"F:\test.txt"))
              {
                  while (!sr.EndOfStream)
                  {
                      string line = sr.ReadLine();                       
                      sw.WriteLine(line);
                      sw.Flush(); 
                  }
  
              }
          }
  </code></pre>