c#
how we can create a pdf file from byte array?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
chellappan pandiarajanPosted Jan 8, 2013, 10:37 AM
System.IO.File.WriteAllBytes("Sample.pdf", bytes);
Thanks,
Pandian
Santhosh Kumar JayaramanPosted Jan 8, 2013, 10:33 AM
File.WriteAllBytes(@"C:\testpdf.pdf", byteArray);
Dont forget to add reference /name space System.IO
If you are using asp.net
then you can also try this to ask user to download instead of writing to a specific folder
private void ShowDocument(string fileName, byte[] fileContent)
{
//Split the string by character . to get file extension type
string[] stringParts = fileName.Split(new char[] { '.' });
string strType = stringParts[1];
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
//Set the content type as file extension type
Response.ContentType = strType;
//Write the file content
this.Response.BinaryWrite(fileContent);
this.Response.End();
}
Check my article for more http://www.c-sharpcorner.com/UploadFile/1a81c5/convert-file-to-byte-array-and-byte-array-to-files/