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