I am using Gmail API's to download email with attachments I am saving all the attachment by decoding base64 string that API provides file_data = base64.urlsafe_b64decode(base64data.encode('UTF-8')) with open(<filePath>, 'w') as f: f.write(file_data) All type of attachments are downloaded properly and code works fine on both the platform (*nix and windows). but PDF attachment works on *nix but fails on windows PDF on Windows File is decoded and saved with correct name and extension, but when I try to open the pdf with reader(tried Adobe reader/Foxit reader), it fails with the random font encoding issue what I have noticed and I think potential issue is, under document properties, font section of decoded pdf and font section of original pdf, downloaded via gmail web inerface is different ( difference being in former decoded file font's information is missing or not right) I do not have much knowledge on decoding PDF's with custom fonts can someone point me in to right direction as to how can i decode base64 with custom fonts? Continue reading...