title: How to convert a pdf bytes to an image byte
body: <p>I have uploaded a PDF file and I convert it to byte format and save it in the database. On fetching the PDF byte array, I need to convert them  to image format so that I can insert the image into a new PDF report</p>
  
  <pre><code>SqlCommand objCmd = new SqlCommand(sTSQL, con);
              objCmd.CommandType = CommandType.Text;
              object result = objCmd.ExecuteScalar();
  
  
  byte[] byteArray;
                  BinaryFormatter bf = new BinaryFormatter();
                  MemoryStream ms = new MemoryStream();
                  bf.Serialize(ms, result);
                  byteArray = ms.ToArray(); // Byte Array
                  ms.Close();
  
                  ms = new MemoryStream(byteArray, 0, byteArray.Length);
                  ms.Seek(0, SeekOrigin.Begin);
                  System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);`enter code here`
  </code></pre>
  
  <p>Error Statement : "Parameter is not valid"</p>