title: byte array to pdf
body: <p>I am trying to convert content of a file stored in a sql column to a pdf.</p>
  
  <p>I use the following piece of code:</p>
  
  <pre><code>byte[] bytes;
  BinaryFormatter bf = new BinaryFormatter();
  MemoryStream ms = new MemoryStream();
  bf.Serialize(ms, fileContent);
  bytes = ms.ToArray();
  System.IO.File.WriteAllBytes("hello.pdf", bytes);
  </code></pre>
  
  <p>The pdf generated is corrupt in the sense that when I open the pdf in notepad++, I see some junk header (which is same irrespective of the fileContent). The junk header is NUL SOH NUL NUL NUL .... </p>