c# - Error while opening PDF -


i getting "failed load pdf document" in chrome , "the file damaged , not repaired" in ie few files.

the code below:

pdfsteramer:

if (pdf != null) {     response.contenttype = "application/pdf";     response.addheader("content-type", "application/pdf");     response.addheader("content-disposition", "inline");      pdf.renderer.render(pdf, response.outputstream);      response.flush(); } 

and in render class:

using (filestream fs = new filestream(this._parentdocument.document.fullname, filemode.open, fileaccess.read)) {                                                      byte[] buffer = new byte[buffersize];      fs.read(buffer, 0, buffersize);      using (stringreader reader = new stringreader(system.text.asciiencoding.ascii.getstring(buffer)))     {                                 decoder decoder = new uudecoder(stream, "");          string data;          while ((data = reader.readline()) != null)         {             decoder.decodeline(data);         }     } } 

and in decodeline below:

public override bool decodeline(string line) {     try     {                                                                      byte[] data = encoding.utf8.getbytes(line);         //byte[] data = uudecode(line);          outstream.write(data, 0, data.length);                       }     catch (exception ex)     {     }     return false; }     

below throws in firefox:

enter image description here

and on adobe reader:

enter image description here

if pdf stored in physical file, don't need use intermediary streams @ all, use transmitfile method has benefit of not using .net memory (in cases):

   response.addheader("content-type", "application/pdf");    response.addheader("content-disposition", "inline");    response.transmitfile(your pdf path); 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -