pass byte array from C# to Javascript and convert that byte array to PDF and save it in client machine.

1. I get blob data in C#.
2. I convert that blob data to byte[] array.
3. I want to pass that byte[] array to javascript.
4. I want the javascript to write that byte array as PDF in client machine.

If the above can be done, Please let me know how i can code the 3 and 4th steps.
salinigayathriAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crisco96Commented:
JavaScript can't just save a file to a client machine otherwise that would open the door to all kinds of hacking such as writing a virus to a user just for going to a website.

An alternative way to give the user a pdf (but not writing it directly to their computer) is with the code below
//set the conttent type of the file to be downloaded
System.Web.HttpContext.Current.Response.ContentType = "application/pdf";

//add the response headers
System.Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=\"somepdf.pdf");

//add the contents of the result set to the response stream
System.Web.HttpContext.Current.Response.BinaryWrite(byteArray);

//end the http response
System.Web.HttpContext.Current.Response.End();

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.