TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
SWAMY YT
1.1k
643
30.3k
generate a pdf in asp.net c#
Oct 22 2018 3:30 AM
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);
}
}
Reply
Answers (
7
)
Is there is a way to implement breadcrumbs in WPF app
insert data with image into database