Convert byte array to pdf using asp.net

Posted by Krishnasamy2008 under ASP.NET on 2/1/2011 | Points: 10 | Views : 13980 | Status : [Member] | Replies : 7
Hi Friends,
How to convert byte array to pdf using asp.net.I have stored byte array values on database.I want to select all byte array values and then convert to PDF.Finally i want to attach that converted PDF file to send mail(Attached more than one file).

Thanks and Regards,
Krishnasamy.K




Responses

Posted by: Prabhakar on: 2/1/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
hi Krishnasamy2008

this code working for u . .

Response.Clear();
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "inline;filename=data.pdf");
Response.BufferOutput = true;
byte[] pdf;
Response.AddHeader("Content-Length", response.Length.ToString());
Response.BinaryWrite(pdf);
Response.End();


Best Regard's
Prabhakar

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/1/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi use this

Response.Clear();
MemoryStream ms = new MemoryStream(pdfByte);
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=labtest.pdf");
Response.Buffer = true;
ms.WriteTo(Response.OutputStream);
Response.End();

One it creates save it a folder and send mail using the below code

http://www.dotnetfunda.com/codes/code1181-send-mail-using-smtp-server-in-csharp.aspx

Thanks
Karthik
www.f5Debug.net

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 2/2/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Karthikanbarasan

in ur code i am not understand what the pdfbyte .. that's the Arry ..

Best Regard's
Prabhakar

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/2/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Yes its the array object

Thanks
Karthik
www.f5Debug.net

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 2/2/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
hi Karthikanbarasan

ok .. . Thankku for replying ..

Best Regard's
Prabhakar

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 2/2/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Sure prabhakar.!!!

Thanks
Karthik
www.f5Debug.net

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: duraipandy2008-23392 on: 8/13/2013 [Member] Starter | Points: 25

Up
0
Down
hi Karthik

i have to show the PDF while the click event. is there any possible to open the pdf in new window to show ?

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response