I have a PDF of url and I want to serve PDF in my page viewer.
I can successfully recover the PDF file (I think) then when I answer. BinaryWrite () I get the "File is damaged and can not be repaired" error from Adobe Reader.
Here I have the code:
Protected Zero Page_Old (object sender, eventarges e) {if (asspackback) {byte [output] output = doork (" // localhost / test.pdf "); Response.Clear (); Response.ContentType = "Apps / PDF"; Response.AddHeader ("Content-Properties", "Inline; File Name = MyPDF.PDF"); Response.AddHeader ("Content-Length", Output. Length: Toastring ()); Response.BinaryWrite (Production); Response.End (); }} Public Byte [] DoWork (String Request URL) {Byte [] Feedback; HttpWebRequest req = faucet; HttpWebResponse resp = Null; Streamreader SRM Reader = Faucet; Try {req = (HttpWebRequest) WebRequest.Create (requestUrl); (Resp = (HttpWebResponse) using req.GetResponse ()) {byte [buffer = new byte] [resp.ContentLength]; Binaryreader Reader = New Binary Reader (resp.GetResponsestream ()); Reader Read (buffer, 0, buffer lang); Feedbackdata = buffer; }} Finally {if (req! = Null) {req = null; } If (resp! = Null) {resp.Close (); Resp = null; }} Return feedback data; }
Apparently, I need to use ReadBytes () to create a URL From PDF, you do not receive all the requested bits.
Protected Zero Page_load (Object Sender, EventAgMS E) {if (IsPostBack) {Byte [] Output = DeWork ("http: //localhost/test.pdf"); Response.Clear (); Response.ContentType = "Apps / PDF"; Response.AddHeader ("content-effect", "attachment"); Response.AddHeader ("Content-Length", Output. Length: Toastring ()); Response.BinaryWrite (Production); Response.End (); }} Public Byte [] DoWork (String Request URL) {Byte [] Feedback; HttpWebRequest req = faucet; HttpWebResponse resp = Null; Streamreader SRM Reader = Faucet; Try {req = (HttpWebRequest) WebRequest.Create (requestUrl); (Resp = (HttpWebResponse) using req.GetResponse ()) {byte [buffer = new byte] [resp.ContentLength]; (Binary Reader Reader = Using the new binary reader (resp.GetResponsestream ()) (buffer = reader .rebibs); reader.Close ();} responseData = buffer;}} Finally {if ( Req! = Null) {req = null;} if (resp! = Null) {resp.Close (); Resp = null;}} Return reaction data;}
Comments
Post a Comment