title: Adding a header to pdf in Python
body: <p>I am making a script that batch converts pdf from 1.5 or above to 1.4</p>
  <p>After conversion, I need to prepend header tags that were previously there.
  Whenever I do this through the Python script I wrote, the pdf returns an error</p>
  <p><strong>&quot;There was an error while reading this Stream&quot;</strong></p>
  <p>But when I do it manually wherein I open the pdf with Notepad++ and paste the headers manually, it works just fine.</p>
  <p>What I've done to figure out the problem was to compare the ones that were manually added and the one where the script added the header.</p>
  <p>Upon doing so, there seems to be a lot of changes that were made when I just pasted the header like</p>
  <pre><code>/CreationDate(D:20200728024434+08'00')
  /ModDate(D:20200728024434+08'00')
  /ID [&lt;BCBBEC32B429CF4C4EC06D5317B6B1FE&gt;&lt;BCBBEC32B429CF4C4EC06D5317B6B1FE&gt;]
  </code></pre>
  <p>to</p>
  <pre><code>/CreationDate(D:20200728024353+08'00')
  /ModDate(D:20200728024353+08'00')
  /ID [&lt;8C36C8F0530094A4C7058CC0845A2FDC&gt;&lt;8C36C8F0530094A4C7058CC0845A2FDC&gt;] 
  </code></pre>
  <p>Is there some sort of fix that Notepad++ do whenever I edit the file and is there a way I can do the same automatically through my script so that I won't have to paste the headers manually.</p>
  <p><strong>EDIT</strong>: I made a mistake and Notepad++ wasn't really doing anything to the pdf. Is there a way that I can paste the headers automatically without it being corrupted?</p>
  <p>In my python code, what I do is</p>
  <pre><code>    content = f.read()
      f.seek(0, 0)
      f.write(header1 + header2 + content)
      f.close()`
  
  </code></pre>
  <p>I found this way to add the headers in this <a href="https://stackoverflow.com/questions/5914627/prepend-line-to-beginning-of-a-file/5917395">article</a></p>