Header too large error

Hi ,

I get an error while using Aspose.Pdf , when it tries to save to the pdf. The error is as below :

The header is too large

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ApplicationException: The header is too large

Source Error:

Line 1071:      MemoryStream outStream = new MemoryStream();
Line 1072:			
Line 1073:      pdf.Save(outStream); //save pdf to stream
Line 1074:			
Line 1075:      page.Response.ClearHeaders(); //clear headers to prepare for application form at and stream of pdf direct to browser

Can any body help me with this?

Thanks

Royce

Hi,

Thank you for considering Aspose.

Could you please share your code that can reproduce this error.

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

Hi Adeel,

This is my function to save the doc to pdf. I am currently using the evaluation copy of your current Aspose pdf version. We have the licence for an older version and want to update to the newer version.

public void SendToBrowserAsPdf(Document doc, string filterKeyset, Page page,bool publicFlag)//publicFlag added for hidden price, and address on the public site

{

// Modified for Feature sheet enhancements.

string includeKeys="";

//Save the document in Aspose.Pdf.Xml format into a memory stream.

MemoryStream stream = new MemoryStream();

Document mergedDoc=null;

////

//doc.Save(stream, SaveFormat.FormatAsposePdf);

Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();

if (filterKeyset==null || filterKeyset.Length==0)

{

includeKeys = "INSERT #IncludeKeys VALUES('"+Guid.Empty.ToString("B")+"')"; //just give the proc something to execute

}

else

{

includeKeys = "INSERT #IncludeKeys VALUES('"+filterKeyset+"')";

}

doc.MailMerge.RemoveEmptyParagraphs = true;

mergedDoc = MergeListing(doc, includeKeys,publicFlag);

mergedDoc.MailMerge.DeleteFields();

//test send as word: mergedDoc.Save(string.Format("{0}.doc", doc.CustomDocumentProperties["TemplateName"]), SaveFormat.FormatDocument, SaveType.OpenInBrowser, page.Response);

mergedDoc.Save(stream, SaveFormat.FormatAsposePdf);

//Seek to the beginning so it can be read by XmlDocument.

stream.Seek(0, SeekOrigin.Begin);

//// //Load the document into an XmlDocument

XmlDocument xmlDoc = new XmlDocument();

xmlDoc.Load(stream);

//Make sure the images that were saved by Aspose.Word into Windows temporary

//// //folder are automatically deleted by Aspose.Pdf when they are no longer needed.

pdf.IsImagesInXmlDeleteNeeded = true;

pdf.BindXML(xmlDoc, null);

page.Response.Clear(); //prepare for binary pdf content

MemoryStream outStream = new MemoryStream();

pdf.Save(outStream); //save pdf to stream

page.Response.ClearHeaders(); //clear headers to prepare for application form at and stream of pdf direct to browser

page.Response.ContentType = "application/pdf"; //set content type for pdf

page.Response.AppendHeader("Content-Disposition","inline;filename=Document1.pdf"); // disposition to open directly in browser

page.Response.BinaryWrite(outStream.ToArray()); //write the pdf data to the browser

try

{

stream.Close();

}

catch{}

try

{

outStream.Close();

}

catch{}

mergedDoc = null;

pdf = null;

}

Thanks

Hi,

The code looks fine. Can you please send your Word document to me.

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team

Hi,

you have send me the Word template file and using that I am unable to reproduce this error. Please make sure that you are using Aspose.Words and Aspose.Pdf Latest version. I need Word or XML file. Please change this line to :

mergedDoc.Save(“C:/Aspose.XML” SaveFormat.FormatAsposePdf);

and then send me this XML file and let us investigate this issue.

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team