So here are the details:
Firefox: update 12
AdobeReader: 11
Input: Convert.FromBase64String(string)=> byte[]
Task: to display the pdf within the browser
PDF is stored in a database.
I've read and tried a lot of possible solutions and fixes for this error. But I got no joy.
Is it possible to know if the converted string to byte[] is corrupted? And is it possible for the value being converted to byte[] to be damaged in the process?
The value of the pdfFile, data type byte[], is from a web service.
Here is the generic handler that I made:
public partial class ProcessPDFRequest : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
try
byte[] currentBillPDF = proxy.GetPdf(refNum, date);
using (MemoryStream ms = new MemoryStream(currentBillPDF))
{
context.Response.Clear();
context.Response.ContentType = "application/pdf";
if(isInline!="true")
context.Response.AddHeader("content-disposition", "attachment;filename=PDF_CurrentBill.pdf");
else
context.Response.AddHeader("content-disposition", "inline;filename=PDF_CurrentBill.pdf");
context.Response.Buffer = true;
ms.WriteTo(context.Response.OutputStream);
context.Response.End(); ;
}
EDIT
I use context.Response.Flush(); context.Response.End();
PDF was successfully displayed when I created another web application. However when I used the converted string to byte[] in the original solution, the error stated in the title is persisting. I already checked the bytes and compared it in notepad, both them showed %PDF-
Is there something I'm missing? the original solution is a sharepoint web application.