Last post Feb 23, 2017 10:09 AM by rashmi.padia
Jul 29, 2015 03:43 PM|AndyMoireASP|LINK
Jul 30, 2015 10:31 PM|Candy Zhou|LINK
Based on your description and code, you want to open the PDF successfully. I think you can refer to the following links:
Jul 31, 2015 01:31 AM|cnranasinghe|LINK
I tested below code and it worked fine for me.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"URL to the PDF");
request.ContentType = "application/pdf;charset=UTF-8";
request.Method = "GET";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
BinaryReader bin = new BinaryReader(response.GetResponseStream());
byte buffer = bin.ReadBytes((Int32)response.ContentLength);
using (Stream writer = File.Create("d:\\MyPDF.pdf"))
writer.Write(buffer, 0, buffer.Length);
I could successfully open the document.
Feb 22, 2017 06:06 PM|ZyronAlex|LINK
Did you try this code locally or remotely because I've even got a problem with a code like that, when I'm testing locally it works fine, but when it's published to the server, I can not open the file.
Did you have idea why ?
Feb 23, 2017 10:09 AM|rashmi.padia|LINK
Based on your description and code, you want to open the PDF successfully from web api.
I think you can refer to the following links: