Click here to Skip to main content
15,919,245 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to show pdf file ,first i convert the pdf file to binary then i saved in database ,now i want to convert binary to pdf file .

my code is given below


SqlConnection con =new SqlConnection(ObjDb.consrtring);
con.Open();
SqlCommand cm=con.CreateCommand();

//string Query = ObjDb.GetDataField("Select DocImage from tblPdoc where ID=" + picID, "DocImage");

cm.CommandText="Select DocImage from tblPdoc where ID=" + picID;
//cm = new SqlCommand(Query, con);
// cm.CommandText = Query;
// string qq = Query;
byte[] binaryData = (byte[])cm.ExecuteScalar();

File.WriteAllBytes(".pdf",binaryData);

string s =Encoding.UTF8.GetString(binaryData);






this.axAcroPDF1.LoadFile(s);

con.Close();
return s;

after encoding the file is showing in this formate and pdf file is not showing



UDb��@�\~�� �R�&������V�wF�b"�f��FW"�f�FTFV6�FS��7G&VЧ��Qƺ��U L P� ��v���t��ZW�5ڑ�'�([b$�O���ύ�����ǽ�R�֮K��7��c�}��RMUn��^<�u����� ����Cy��ߖ�2h��1����}���
«;�Ƣ:a�1Ic�]k����r烙�����������N��Y%3En��4���֬Z��}I7
��%��vA��6��U�]�Ժ;���}%%L�}��� %����:�RB�b/���\@M���1i���/?�f�����:;�ź�L�N���w�/|�}Mha�m&� /eػ�&Tz�a�Yi7U��VFp����


kindly tell me what should i do?
Posted
Comments
Richard MacCutchan 25-Sep-14 7:12am    
Why are you encoding it? That changes the content from the original. If you save the file's content as binary then you should not be encoding it to some other form.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900