Hello when i try to decode image like this
"example_label.b64" file is here (http://ge.tt/27odGly/v/0)
i see corrupted pdf, looks like base64 decoding corrupt this file.
Can you help me?
Here code example.
import base64
with open('example_label.b64','r+') as f:
data = f.read()
f.close()
# data = data.decode('base64')
#or
data = base64.b64decode(data)
with open('example_label.pdf','w+') as f:
f.write(data)
f.close()
Thank you.
Your write mode should specify binary or else you risk newline conversion depending on your platform. That is
open('example_label.pdf', 'wb')
The file decodes just fine on my system yielding checksums of
$ md5sum example_label.pdf
bd9a4e16d45fe01bfc77a2af6afe1b8b example_label.pdf
$ sha1sum example_label.pdf
a9b77217793ef05f212b0619248480411f6ed4a1 example_label.pdf
and is a US postal service label with dummy addresses in it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With