-1

The pdf is getting generated in local but it is corrupted .The message is 'adobe reader could not open because it is either not supported or damaged'.Below is the code i am using .The binary content is a pdf content for sure .Please help ......

string path= "E:/J/test1.pdf";

byte[] binrydata = System.Convert.FromBase64String(content);
binrydata = Encoding.ASCII.GetBytes(content)

System.IO.FileStream stream = new System.IO.FileStream(path, System.IO.FileMode.Create);
stream.Write(binrydata, 0, binrydata.Length);
stream.Close();
joe
  • 7,264
  • 7
  • 45
  • 73
Joe
  • 11
  • 2
  • 1
    possible duplicate of [convert base64Binary to pdf](http://stackoverflow.com/questions/1626982/convert-base64binary-to-pdf) – Joshua Sep 29 '15 at 17:34

1 Answers1

0

Assuming content really is a base64 encoded PDF,

string path= "E:/J/test1.pdf";

byte[] binrydata = System.Convert.FromBase64String(content);
//Don't do this. Oops.
//binrydata = Encoding.ASCII.GetBytes(content)

System.IO.FileStream stream = new System.IO.FileStream(path, System.IO.FileMode.Create);
stream.Write(binrydata, 0, binrydata.Length);
stream.Close();
Joshua
  • 34,237
  • 6
  • 59
  • 120