Failed to load response data in Chrome response headers

Return pdf in memory stream using MVC

MemoryStream ms = new MemoryStream();
pdf1.Save(ms);
string downloadname = “filename.pdf”;

Response.AppendHeader(“Content-Disposition”, string.Format(“ATTACHMENT;filename={0}”, downloadname));
Response.BinaryWrite(ms.GetBuffer());


Hi Rollyh,

Thanks for your inquiry. I have tested the scenario using the following code with Aspose.Pdf for .NET 10.7.0 and was unable to notice any exception with Chrome. We will appreciate it if you please share some more details about the issue and also share a sample project to replicate the issue at our end so we can conduct further investigations and provide you with the relevant information.

Aspose.Pdf.Document pdf;
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
htmlLoadOptions.PageInfo.Width = 800;
htmlLoadOptions.PageInfo.Height = 600;
htmlLoadOptions.PageInfo.Margin.Left = 0;
htmlLoadOptions.PageInfo.Margin.Right = 0;

MemoryStream outputstream = new MemoryStream();
htmlLoadOptions.InputEncoding = "UTF-8";

using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(pageSource)))
{
    pdf = new Aspose.Pdf.Document(stream, htmlLoadOptions);
}

pdf.Save(outputstream);
string downloadname = "filename.pdf";

Response.AppendHeader("Content-Disposition", string.Format("ATTACHMENT;filename={0}", downloadname));
Response.BinaryWrite(outputstream.GetBuffer());

Best Regards,