本文整理汇总了C#中Chapter.AddSection方法的典型用法代码示例。如果您正苦于以下问题:C# Chapter.AddSection方法的具体用法?C# Chapter.AddSection怎么用?C# Chapter.AddSection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chapter
的用法示例。
在下文中一共展示了Chapter.AddSection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button4_Click
private void button4_Click(object sender, EventArgs e)
{
//Control ctl = this.dataGridView1;
Control ctl = Control.FromHandle(this.dataGridView1.Handle);
{
Bitmap bt = new Bitmap(ctl.Width, ctl.Height);
ctl.DrawToBitmap(bt, new System.Drawing.Rectangle(0, 0, bt.Width, bt.Height));
bt.Save("abc.gif",System.Drawing.Imaging.ImageFormat.Gif);
Document document = new Document(PageSize.A4, 10,10, 10,10);
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(Application.StartupPath + @"\abcd.pdf", FileMode.Create));
writer.ViewerPreferences = (PdfWriter.CenterWindow | PdfWriter.FitWindow | PdfWriter.PageModeUseNone);
document.Open();
//使用宋体字体
BaseFont baseFont = BaseFont.CreateFont("C:\\WINDOWS\\FONTS\\simsun.ttc,0",
BaseFont.IDENTITY_H,
BaseFont.NOT_EMBEDDED);
PdfContentByte cb = writer.DirectContent;
Chapter chapter1 = new Chapter(new Paragraph("This is Chapter 1"), 1);
Section section1 = chapter1.AddSection(20f, "Section 1.1", 2);
Section section2 = chapter1.AddSection(20f, "Section 1.2", 2);
Section subsection1 = section2.AddSection(20f, "Subsection 1.2.1", 3);
Section subsection2 = section2.AddSection(20f, "Subsection 1.2.2", 3);
Section subsubsection = subsection2.AddSection(20f, "Sub Subsection 1.2.2.1", 4);
Chapter chapter2 = new Chapter(new Paragraph("This is Chapter 2"), 1);
Section section3 = chapter2.AddSection("Section 2.1", 2);
Section subsection3 = section3.AddSection("Subsection 2.1.1", 3);
Section section4 = chapter2.AddSection("Section 2.2", 2);
chapter1.BookmarkTitle = "Changed Title";
chapter1.BookmarkOpen = true;
chapter2.BookmarkOpen = false;
document.Add(chapter1);
document.Add(chapter2);
ZapfDingbatsList zlist = new ZapfDingbatsList(49, 15);
zlist.Add("One");
zlist.Add("Two");
zlist.Add("Three");
zlist.Add("Four");
zlist.Add("Five");
document.Add(zlist);
RomanList romanlist = new RomanList(true, 20);
romanlist.IndentationLeft = 30f;
romanlist.Add("One");
romanlist.Add("Two");
romanlist.Add("Three");
romanlist.Add("Four");
romanlist.Add("Five");
document.Add(romanlist);
PdfPTable table1 = new PdfPTable(3);
PdfPCell cell1 = new PdfPCell(new Phrase("Header spanning 3 columns"));
cell1.Colspan = 3;
cell1.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
table1.AddCell(cell1);
table1.AddCell(cell1);
table1.AddCell("Col 1 Row 2");
table1.AddCell("Col 2 Row 2");
table1.AddCell("Col 3 Row 2");
table1.SetWidths(new int[]{50,100,100});
table1.WidthPercentage = 100f;
document.Add(table1);
//using it = iTextSharp.text;
//PdfPTable table2 = new PdfPTable(3);
//table2.AddCell("Cell 1");
//PdfPCell cell2 = new PdfPCell(new it.Phrase("Cell 2", new Font(Font.HELVETICA, 8f, Font.NORMAL, Color.YELLOW)));
//cell2.BackgroundColor = new Color(0, 150, 0);
//cell2.BorderColor = new Color(255, 242, 0);
//cell2.Border = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER;
//cell2.BorderWidthBottom = 3f;
//cell2.BorderWidthTop = 3f;
//cell2.PaddingBottom = 10f;
//cell2.PaddingLeft = 20f;
//cell2.PaddingTop = 4f;
//table2.AddCell(cell2);
//table2.AddCell("Cell 3");
//document.Add(table2);
System.Drawing.Image img = bt;
MemoryStream mem = new MemoryStream();
img.Save(mem, System.Drawing.Imaging.ImageFormat.Gif);
byte[] bytes = mem.ToArray();
iTextSharp.text.Image img2 = iTextSharp.text.Image.GetInstance(bytes);
iTextSharp.text.Image img3 = iTextSharp.text.Image.GetInstance(bytes);
img2.ScalePercent(100f);
img3.ScalePercent(100f);
img2.SetAbsolutePosition(50f, 400f);
img3.SetAbsolutePosition(50f, 400f - img2.Height);
//cb.AddImage(img2);
//.........这里部分代码省略.........