To create a new pdf you must download itextsharp.dll from itextsharp.sourceforge.com and add it to the project.
using iTextSharp.text.pdf;
using iTextSharp.text;
......
static Font fontHeaderBold = new Font(1, 10, 1);
static Font fontHeader = new Font(1, 10, Font.NORMAL);
static Font fontHeaderTabelBold = new Font(1, 9, Font.BOLD);
static Font fontHeaderTabel = new Font(1, 6, Font.NORMAL);
static Font fontBlank = new Font(1, 6, Font.NORMAL, new BaseColor(255, 255, 255));
............
Document document = new Document(new Rectangle(0, 0, 942, 595));
document.SetMargins(0, 0, 30, 30);
PdfWriter pdfwriter = PdfWriter.GetInstance(document, new FileStream("Doc.pdf", FileMode.Create));
document.Open();
PdfPTable table = new PdfPTable(7);
float[] widths = new float[] { 105f, 70f, 25f, 10f, 40f, 10f, 100f };
table.SetWidths(widths);
PdfPCell cell0 = new PdfPCell(new Phrase("text1"));
cell0.Border = 0;
PdfPCell cell1 = new PdfPCell(new Phrase("text1", fontHeaderBold));
cell1.Border = 0;
PdfPCell cell2 = new PdfPCell(new Phrase("text1", fontHeaderBold));
cell2.Border = 0;
PdfPCell cell3 = new PdfPCell(new Phrase(" text1 "));
cell3.BorderWidth = 1;
PdfPCell cell4 = new PdfPCell(new Phrase("text1", fontHeaderBold));
cell4.Border = 0;
PdfPCell cell5 = new PdfPCell(new Phrase("text1 "));
cell5.BorderWidth = 1;
PdfPCell cell6 = new PdfPCell(new Phrase("text1"));
cell6.BorderWidth = 0;
PdfPCell cell7 = new PdfPCell(new Phrase("text1", fontHeaderBold));
cell7.BorderWidth = 0;
PdfPCell cell8 = new PdfPCell(new Phrase("text1", new Font(1, 11, 1)));
cell8.Border = 0;
cell8.Colspan = 6;
table.AddCell(cell0);
table.AddCell(cell1);
table.AddCell(cell2);
table.AddCell(cell3);
table.AddCell(cell4);
table.AddCell(cell5);
table.AddCell(cell6);
table.AddCell(cell7);
table.AddCell(cell8);
Paragraph p = new Paragraph("text1", fontHeaderBold);
p.Alignment = 1;
Paragraph p2 = new Paragraph("text1 ", fontHeaderBold);
p2.Alignment = Element.ALIGN_RIGHT;
Paragraph p3 = new Paragraph("text1", fontHeaderBold);
p3.Alignment = Element.ALIGN_RIGHT;
document.Add(table);
document.Add(p);
document.Add(p2);
document.Add(p3);
document.Close();
No comments:
Post a Comment