当前位置: 首页>>代码示例>>C#>>正文


C# Chapter.Add方法代码示例

本文整理汇总了C#中Chapter.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Chapter.Add方法的具体用法?C# Chapter.Add怎么用?C# Chapter.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chapter的用法示例。


在下文中一共展示了Chapter.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GeneratePDF


//.........这里部分代码省略.........
            {
                chunkHeading = new Chunk(txtprjname + "                                                                                                                                      ", fonts[15]);
            }

            String _modetype = IsFinancial == "Y" ? "Proposal" : "Scope";

            Int32 _document_rev_number = GenerateseqNumberforDocs(Convert.ToInt32(EstNum), _modetype);

            _filename = DateTime.Now.ToString("MM-dd-yyyy") + "-" + txtprjname.Replace("."," ").Trim() + " Architectural Millwork - WhitfieldCo " + _modetype + "-REV 0" + _document_rev_number + ".pdf";

                //if (File.Exists(HttpContext.Current.Server.MapPath("~/attachments/") + _filename))  //If the file exists, create new one.
                //{
                //    //File.Delete(HttpContext.Current.Server.MapPath("~/attachments/") + _filename);
                //    char[] splitchar = { '.' };
                //    string[] strArr = null;
                //    strArr = _filename.Split(splitchar);
                //    String _filenmTest = strArr[0];
                //    int intIndexSubstring = 0;
                //    intIndexSubstring = _filenmTest.IndexOf("-REV#");
                //    _filename = DateTime.Now.ToString("MM-dd-yyyy") + "-" + txtprjname.Replace(".", " ").Trim() + " Architectural Millwork - WhitfieldCo " + _modetype  +"-REV#0" + (Convert.ToInt32(_filenmTest.Substring(intIndexSubstring).Substring(5)) + 1).ToString() + ".pdf";

                //}
                //FileStream MyStream;
                //MyStream = new FileStream(HttpContext.Current.Server.MapPath("~/attachments/") + _filename, FileMode.Create);
                //PdfWriter.GetInstance(document, new FileStream(HttpContext.Current.Server.MapPath("~/attachments/") + _filename, FileMode.Create));
                //using (StreamWriter sw = File.CreateText(mappath + "patientquery.txt"))

            using ( MyStream = new FileStream(HttpContext.Current.Server.MapPath("~/attachments/") + _filename, FileMode.Create))
            //using (FileStream MyStream = File.Create(HttpContext.Current.Server.MapPath("~/attachments/") + _filename))
            //new FileStream(HttpContext.Current.Server.MapPath("~/attachments/") + _filename, FileMode.Create)
            {
                PdfWriter.GetInstance(document, MyStream);
                //attachments
                document.AddAuthor("Whitfield Corporation");
                document.AddSubject("Proposal Generator");

                iTextSharp.text.Image img = this.DoGetImageFile(HttpContext.Current.Server.MapPath("~/assets/img/TWC Primary Logo1.JPG"));
                img.ScalePercent(50);
                Chunk ck = new Chunk(img, 0, -5);

                HeaderFooter headerRight = new HeaderFooter(new Phrase(chunkHeading), new Phrase(ck));
                document.Header = headerRight;
                headerRight.Alignment = iTextSharp.text.Rectangle.ALIGN_RIGHT;
                headerRight.Border = iTextSharp.text.Rectangle.NO_BORDER;

                // we Add a Footer that will show up on PAGE 1
                Phrase phFooter = new Phrase("The Whitfield Corporation, Incorporated  ", fonts[15]);
                phFooter.Add(new Phrase("P.O. Box 0385, Fulton, MD 20759  ", fonts[8]));
                phFooter.Add(new Phrase("Main: 301 483 0791 Fax: 301 483 0792  ", fonts[8]));
                phFooter.Add(new Phrase("\nDelivering on Promises", fonts[11]));
                //
                HeaderFooter footer = new HeaderFooter(phFooter, false);
                footer.Border = iTextSharp.text.Rectangle.NO_BORDER;
                footer.Alignment = iTextSharp.text.Rectangle.ALIGN_CENTER;
                document.Footer = footer;
                // step 3: we open the document
                document.Open();

                // we Add a Header that will show up on PAGE 2

                DateTime dt = DateTime.Now;
                //Chapters and Sections
                int ChapterSequence = 1;
                document.NewPage();
                iTextSharp.text.Font chapterFont = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 16, iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK);
                iTextSharp.text.Font sectionFont = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, iTextSharp.text.Color.BLACK);
开发者ID:frdharish,项目名称:WhitfieldAPPs,代码行数:67,代码来源:PDFHelper.cs

示例2: LoadScopeOfWork

    private void LoadScopeOfWork(Chapter chapterScope, DataSet ds, iTextSharp.text.Font font1)
    {
        int NumColumns = 4;
        try
        {
            // we add some meta information to the document
            //Paragraph DrawingsPara = new Paragraph("Scope of Work:\n\n", font1);
            //chapterScope.Add(DrawingsPara);

            PdfPTable datatable = new PdfPTable(NumColumns);
            //iTextSharp.text.Table datatable = new iTextSharp.text.Table(NumColumns);
            datatable.DefaultCell.Padding = 4;
            float[] headerwidths = { 8, 20, 45, 20 }; // percentage
            datatable.SetWidths(headerwidths);
            datatable.WidthPercentage = 100; // percentage

            datatable.DefaultCell.BorderWidth = 1;
            datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
            //datatable.AddCell("No.");
            datatable.AddCell(new Phrase("No.", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 9, iTextSharp.text.Font.NORMAL)));
            //datatable.AddCell("Description");
            datatable.AddCell(new Phrase("Description", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 9, iTextSharp.text.Font.NORMAL)));
            //datatable.AddCell("Notes");
            datatable.AddCell(new Phrase("Notes", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 9, iTextSharp.text.Font.NORMAL)));
            //datatable.AddCell("Reference");
            datatable.AddCell(new Phrase("Reference", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 9, iTextSharp.text.Font.NORMAL)));
            datatable.HeaderRows = 1;  // this is the end of the table header
            datatable.DefaultCell.BorderWidth = 1;

            int i = 1;
            DataTable MyScope;
            MyScope = ds.Tables[0];

            foreach (DataRow dRow in MyScope.Rows)
            {
                String _number = dRow["work_order_id"] == DBNull.Value ? "" : dRow["work_order_id"].ToString();
                String _description = dRow["Description"] == DBNull.Value ? "" : dRow["Description"].ToString();
                String _notes = dRow["notes1"] == DBNull.Value ? "" : dRow["notes1"].ToString();
                String _reference = dRow["reftext"] == DBNull.Value ? "" : dRow["reftext"].ToString();
                datatable.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT;
                if (i % 2 == 1)
                {
                    datatable.DefaultCell.GrayFill = 0.9f;
                }
                datatable.AddCell(new Phrase(_number, FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, iTextSharp.text.Font.NORMAL)));
                datatable.AddCell(new Phrase(_description, FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, iTextSharp.text.Font.NORMAL)));
                datatable.AddCell(new Phrase(_notes, FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, iTextSharp.text.Font.NORMAL)));
                datatable.AddCell(new Phrase(_reference, FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8, iTextSharp.text.Font.NORMAL)));

                if (i % 2 == 1)
                {
                    datatable.DefaultCell.GrayFill = 1.0f;
                }
                i++;
            }
            chapterScope.Add(datatable);
        }
        catch (Exception ex)
        {
            HttpResponse objResponse = HttpContext.Current.Response;
            objResponse.Write(ex.Message);
        }
    }
开发者ID:frdharish,项目名称:WhitfieldAPPs,代码行数:63,代码来源:PDFHelper.cs


注:本文中的Chapter.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。