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
Mukesh
NA
228
42.7k
How to Generate Pdf Using itextsharp i n C#
Mar 19 2018 11:15 PM
Hello sir
below I attached file i want to generate pdf using itextsharp so can you please write a code
it is urgent
public void GeneratePDFCoO()
{
//server folder path which is stored your PDF documents
string path = HttpContext.Current.Server.MapPath("pdffiles");
string filename = path + "/Doc1.pdf";
//Create new PDF document
Document document = new Document(PageSize.A4, 25f, 10f, 10f, 10f);
try
{
PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create));
PdfPTable table = new PdfPTable(2);
table.HorizontalAlignment = 0;
//leave a gap before and after the table
table.SpacingBefore = 20f;
table.SpacingAfter = 30f;
PdfPCell cell11 = new PdfPCell(new Phrase("A"));
cell11.Rowspan = 1;
table.AddCell(cell11);
PdfPCell cell12 = new PdfPCell(new Phrase("B"));
cell12.Rowspan = 1;
cell12.BorderWidthLeft = 0;
cell12.BorderWidthRight = 0;
cell12.BorderWidthTop = 0;
cell12.PaddingRight = 1f;
cell12.PaddingTop = 10f;
cell12.BorderWidthBottom = 0;
cell12.FixedHeight = 40f;
table.AddCell(cell12);
PdfPCell cell13 = new PdfPCell(new Phrase("C"));
cell13.Rowspan = 1;
table.AddCell(cell13);
PdfPCell cell14 = new PdfPCell(new Phrase("D"));
cell14.Rowspan = 1;
//cell14.Colspan = 2;
table.AddCell(cell14);
PdfPCell cell15 = new PdfPCell(new Phrase("E"));
table.AddCell(cell15);
PdfPCell cell16 = new PdfPCell(new Phrase("F"));
// cell16.Rowspan = 2;
table.AddCell(cell16);
PdfPCell cell17 = new PdfPCell();
cell17.Colspan = 2;
// new table
PdfPTable tabledetails = new PdfPTable(5);
tabledetails.HorizontalAlignment = 0;
//leave a gap before and after the table
tabledetails.SpacingBefore = 20f;
tabledetails.SpacingAfter = 30f;
PdfPCell tabledetailsCell1 = new PdfPCell(new Phrase("1"));
tabledetails.AddCell(tabledetailsCell1);
PdfPCell tabledetailsCell2 = new PdfPCell(new Phrase("2"));
tabledetails.AddCell(tabledetailsCell2);
PdfPCell tabledetailsCell3 = new PdfPCell(new Phrase("3"));
tabledetails.AddCell(tabledetailsCell3);
PdfPCell tabledetailsCell4 = new PdfPCell(new Phrase("4"));
tabledetails.AddCell(tabledetailsCell4);
PdfPCell tabledetailsCell5 = new PdfPCell(new Phrase("5"));
tabledetails.AddCell(tabledetailsCell5);
cell17.AddElement(tabledetails);
// new table end
cell17.Rowspan = 3;
table.AddCell(cell17);
document.Open();
document.Add(table);
}
catch (Exception ex)
{
}
finally
{
document.Close();
}
}
Attachment:
Certificate-of-Origin_(1).rar
Reply
Answers (
7
)
WCF Receving Response Without send an http post
edit opearation of cascading dropdown list