本文整理匯總了C#中iTextSharp.text.pdf.PdfPTable.NormalizeHeadersFooters方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfPTable.NormalizeHeadersFooters方法的具體用法?C# PdfPTable.NormalizeHeadersFooters怎麽用?C# PdfPTable.NormalizeHeadersFooters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfPTable
的用法示例。
在下文中一共展示了PdfPTable.NormalizeHeadersFooters方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: createPdfButton
private void createPdfButton(object sender, EventArgs e)
{
string test = string.Format(textBox1.Text);
if (test.Equals(""))
{
MessageBox.Show("Please enter a file name.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else if( test.Contains("\\")||test.Equals("/"))
{
MessageBox.Show("Invalid character \\", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else if (!test.Equals(""))
{
string name = string.Format(textBox2.Text);
//ss = string.Format(name.FullName);
if (File.Exists(name+"\\"+textBox1.Text+".pdf"))
{
MessageBox.Show("File name must be unique.","Message",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
else
{
try
{
string path = string.Format(textBox2.Text + "\\");
string fileName = path + test + ".pdf";
Document document = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 30, 10);
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create));
document.Open();
String st = Application.StartupPath;
st += "\\jj.jpg";
iTextSharp.text.Image png = iTextSharp.text.Image.GetInstance(st);
png.ScaleAbsolute(70,70);
png.SetAbsolutePosition(document.PageSize.Width -10f -340f,document.PageSize.Height -20f -50f);
document.Add(png);
Paragraph paragraph = new Paragraph("\n\n Campuse Library \n Islamic University,Kushtia-7003\n E-mail:[email protected] \n Mobile:01913-540251,01740197701\n " + " Date:" + DateTime.Now.ToShortDateString());
paragraph.IndentationLeft = 200f;
document.Add(paragraph);
Paragraph p = new Paragraph(""+'\n');
document.Add(p);
PdfPTable table = new PdfPTable(dataGridView1.ColumnCount-1);
PdfPCell cell = new PdfPCell(new Phrase("Total Book Order", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 16f, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.ORANGE)));
cell.BackgroundColor = new iTextSharp.text.BaseColor(200, 20, 120);
iTextSharp.text.Font fntTableFont = FontFactory.GetFont("Times New Roman", 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
table.WidthPercentage = 100;
table.HorizontalAlignment = 0;
table.SpacingAfter = 10;
cell.Colspan = dataGridView1.ColumnCount-1;
cell.HorizontalAlignment = 1;
table.AddCell(cell);
for (int i = 0; i < dataGridView1.ColumnCount-1; i++)
{
table.AddCell(new Phrase(dataGridView1.Columns[i].HeaderText));
}
table.HeaderRows = 1;
table.NormalizeHeadersFooters();
float[] widths = new float[] { 1f, 4f, 4.5f, 1.25f, 1f, 1.25f, 1.50f};
table.SetWidths(widths);
for (int i = 0; i < dataGridView1.RowCount; i++)
{
for (int j = 0; j < dataGridView1.ColumnCount-1; j++)
{
if (dataGridView1[j, i].Value != null)
{
PdfPCell CellOne = new PdfPCell(new Phrase(dataGridView1[j, i].Value.ToString(), fntTableFont));
table.AddCell(CellOne);
}
}
}
document.Add(table);
int sum = 0;
for (int i = 0; i < dataGridView1.Rows.Count;++i)
{
sum += Convert.ToInt32(dataGridView1.Rows[i].Cells["Quantity"].Value);
}
Paragraph paragraph1 = new Paragraph("Total = " + sum + " pices", new iTextSharp.text.Font(iTextSharp.text.Font.NORMAL, 12f, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.BLACK));
paragraph1.IndentationLeft = 450f;
document.Add(paragraph1);
MessageBox.Show("Successfully Created pdf file.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
document.Close();
System.Diagnostics.Process.Start(path + test + ".pdf");
}
catch (Exception exception)
{
MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
//.........這裏部分代碼省略.........