I am making a script that batch converts pdf from 1.5 or above to 1.4
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
"There was an error while reading this Stream"
But when I do it manually wherein I open the pdf with Notepad++ and paste the headers manually, it works just fine.
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.
Upon doing so, there seems to be a lot of changes that were made when I just pasted the header like
/CreationDate(D:20200728024434+08'00')
/ModDate(D:20200728024434+08'00')
/ID [<BCBBEC32B429CF4C4EC06D5317B6B1FE><BCBBEC32B429CF4C4EC06D5317B6B1FE>]
to
/CreationDate(D:20200728024353+08'00')
/ModDate(D:20200728024353+08'00')
/ID [<8C36C8F0530094A4C7058CC0845A2FDC><8C36C8F0530094A4C7058CC0845A2FDC>]
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.
EDIT: 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?
In my python code, what I do is
content = f.read()
f.seek(0, 0)
f.write(header1 + header2 + content)
f.close()`
I found this way to add the headers in this article