title: How to write the parsed contents of PDF file to text file?
body: <p>I wanted to copy the content of PDFs file into a text file using PowerShell. I was able to parse the contents of PDFs using the below code, but I don't know how to copy the parsed data into text file. </p>
  
  <pre class="lang-psh prettyprint-override"><code>Add-Type -Path .\itextsharp.dll
  $reader = New-Object iTextSharp.text.pdf.pdfreader -ArgumentList "$pwd\test.pdf".
  
  for ($page = 1; $page -le $reader.NumberOfPages; $page++) {
    $lines = [char[]]$reader.GetPageContent($page) -join "" -split "`n"
    foreach ($line in $lines) {
      if ($line -match "^\[") {   
        $line = $line -replace "\\([\S])", $matches[1]
        $line -replace "^\[\(|\)\]TJ$", "" -split "\)\-?\d+\.?\d*\(" -join ""
      }
    }
  }
  </code></pre>