Thanks for the reply. It works while i save the pdf to harddisk using pdf.save(@"C:\test1.pdf"), however we want to write the data into memory stream and ultimately have to convert it into a byte array so that it can be written into response object.
i am using the below mentioned code
MemoryStream msPdf = new MemoryStream();
try
{
if (res != null && res.GeneratePDFMsgs != null && res.GeneratePDFMsgs.Length != 0)
{
DataTable dtDetail = BdrReportMsgToDataTable(res);
Pdf pdf = new Pdf();
//Create a section in the Pdf instance
Section sec = pdf.Sections.Add();
//Create a Table object
Aspose.Pdf.Table tab = new Aspose.Pdf.Table();
//Add the Table object in the paragraphs collection of the section
sec.Paragraphs.Add(tab);
//Set column widths of the table
tab.ColumnWidths = "60 60 60 60 60 60";
//Set default cell border of the table using BorderInfo object
tab.DefaultCellBorder = new BorderInfo((int)BorderSide.All, 0.1F);
//Import data into the Table object from the DataTable created above
tab.ImportDataTable(dtDetail, true, 0, 1);
pdf.IsTruetypeFontMapCached = true;
pdf.TruetypeFontMapPath = ConfigurationManager.AppSettings["logPath"];
Trace.Listeners.Clear();
Trace.Flush();
Trace.Close();
pdf.Save(msPdf);
return msPdf.GetBuffer();
}
}
And we are using this memory stream msPDF
string timeStamp = DateTime.Now.ToString();
Response.Expires = -1;
Response.ContentType = "application/" + FileType;
Response.AddHeader("Content-Type", "application/" + FileType);
Response.AddHeader("Content-Disposition", "attachment;filename=" + prog + "_" + timeStamp.Replace("/", "").Replace(" ", "").Replace(":", "") + "." + FileType);
Response.BinaryWrite(arrExport);
Response.End();
Please let me know the solution.
thanks,
Sankalp