Hi,
i have been getting "Thread was being aborted" Exception when a report is being exporting to PDF.
i am using the following code to export report into a PDF.
- protected void btnPrint_Calculation(object sender, EventArgs e)
- {
- GeneratePrint();
- }
- public void GeneratePrint()
- {
- try
- {
- Document doc = new Document(new RectangleReadOnly(842, 595), 88f, 88f, 10f, 10f);
- System.IO.MemoryStream MyStream = new System.IO.MemoryStream();
- BaseColor Black = new BaseColor(00, 00, 00);
- iTextSharp.text.Font MyFont = FontFactory.GetFont("vardana", 12, iTextSharp.text.Font.BOLD, Black);
- PdfWriter Writer = PdfWriter.GetInstance(doc, MyStream);
- doc.Open();
- string HeaderTitle = "AIR ROTOR TECHNOLOGIES PVT LTD,";
- string SubHeaderTitle = " 303,Center Facility Building 2,Sector 19,Vashi,";
- string SubHeaderTitle1 = "chikmaglur";
- PdfPTable HeaderTable = new PdfPTable(1);
- PdfPCell HeaderCell = new PdfPCell(new Phrase(HeaderTitle, new Font(Font.FontFamily.HELVETICA, 15f, Font.BOLD, BaseColor.RED)));
- PdfPCell SubHeaderCell = new PdfPCell(new Phrase(SubHeaderTitle, new Font(Font.FontFamily.HELVETICA, 14f, Font.BOLD, BaseColor.BLACK)));
- PdfPCell SubHeaderCell1 = new PdfPCell(new Phrase(SubHeaderTitle1, new Font(Font.FontFamily.HELVETICA, 10f, Font.NORMAL, BaseColor.BLACK)));
- HeaderCell.Border = 0;
- HeaderTable.AddCell(HeaderCell);
- HeaderTable.AddCell(SubHeaderCell);
- HeaderTable.AddCell(SubHeaderCell1);
- PdfPCell text = new PdfPCell(HeaderTable);
- Response.Clear();
-
- Response.ContentType = "application/pdf";
- Response.BinaryWrite(MyStream.ToArray());
- Response.End();
- doc.Close();
- }
- catch (Exception Ex)
- {
- Response.Write("While printing Caught an Error" + Ex.Message);
- }
- }