I have pdf file which is encoded with base64. I created simple script for saving it as pdf file:
import base64
with open('pdf.b64', mode='r') as fpdf:
with open('output.pdf', mode='wb') as output:
base64.decode(fpdf, output)
output.close()
fpdf.close()
After the script runs, I have pdf file as expected, but it's broken. I decided to compare just any correct pdf file with the file I got and noticed that every line in correct pdf file ends with "^M", for example:
Correct pdf file header: %PDF-1.7^M
My pdf file header: %PDF-1.4
So, what am I doing wrong here?
base64.b64decode(...makes any difference.