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.AddHeader("content-disposition", "attachment;filename=SaleRegisterReport.pdf");
- Response.ContentType = "application/pdf";
- Response.BinaryWrite(MyStream.ToArray());
- Response.End();
- doc.Close();
- }
- catch (Exception Ex)
- {
- Response.Write("While printing Caught an Error" + Ex.Message);
- }
- }

Dorababu MekaRank #457 · 5.5K reputationPosted Oct 24, 2018, 12:00 AM EDT
Dorababu MekaRank #457 · 5.5K reputationPosted Oct 21, 2018, 11:55 PM EDT
SWAMY YTRank #2,119 · 673 reputationPosted Oct 22, 2018, 12:30 AM EDT
SWAMY YTRank #2,119 · 673 reputationPosted Oct 22, 2018, 1:44 AM EDT
Dorababu MekaRank #457 · 5.5K reputationPosted Oct 23, 2018, 11:59 PM EDT
SWAMY YTRank #2,119 · 673 reputationPosted Oct 24, 2018, 1:22 AM EDT
Leon DRank #851 · 2.6K reputationPosted Sep 12, 2021, 9:02 PM EDT