• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# pdf.PdfPCell类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中iTextSharp.text.pdf.PdfPCell的典型用法代码示例。如果您正苦于以下问题:C# PdfPCell类的具体用法?C# PdfPCell怎么用?C# PdfPCell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PdfPCell类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfPCell类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: WriteTOC

        protected virtual void WriteTOC(List<PdfContentParameter> contents, PdfWriter writer, Document document)
        {
            document.NewPage();
            PdfPTable t = new PdfPTable(2);
            t.WidthPercentage = 100;
            t.SetWidths(new float[] { 98f, 2f });
            t.TotalWidth = document.PageSize.Width - (document.LeftMargin + document.RightMargin);
            t.AddCell(new PdfPCell(
                new Phrase(GlobalStringResource.TableOfContents,
                    FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 16))
                ) { Colspan = 2, Border = Rectangle.NO_BORDER, PaddingBottom = 25 });

            foreach (PdfContentParameter item in contents)
            {
                if (!string.IsNullOrEmpty(item.Header))
                {
                    t.AddCell(
                        new PdfPCell(
                                new Phrase(item.Header,
                                    FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 8)
                                    )
                            ) { Border = Rectangle.NO_BORDER, NoWrap = false, FixedHeight = 15, }
                        );

                    PdfPCell templateCell = new PdfPCell(Image.GetInstance(item.Template));
                    templateCell.HorizontalAlignment = Element.ALIGN_RIGHT;
                    templateCell.Border = Rectangle.NO_BORDER;
                    t.AddCell(templateCell);
                }
            }
            float docHeight = document.PageSize.Height - heightOffset;
            document.Add(t);
        }
开发者ID:meanprogrammer,项目名称:sawebreports_migrated,代码行数:33,代码来源:PDFBuilderStrategyBase.cs


示例2: GenerateRow

        private static void GenerateRow(PdfPTable table, PlayerInfo player, Font font, BaseColor backgroundColor)
        {
            var jpg = Image.GetInstance(player.PictureUrl);
            table.AddCell(jpg);

            PdfPCell cell;

            cell = new PdfPCell(new Phrase(player.JerseyNumber, font)) {BackgroundColor = backgroundColor};
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase(player.Name, font)) {BackgroundColor = backgroundColor};
            table.AddCell(cell);

            if (table.NumberOfColumns == NumberColsWithPosition)
            {
                cell = new PdfPCell(new Phrase(player.Position, font)) {BackgroundColor = backgroundColor};
                table.AddCell(cell);
            }

            cell = new PdfPCell(new Phrase(player.Height, font)) {BackgroundColor = backgroundColor};
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase(player.Weight, font)) {BackgroundColor = backgroundColor};
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase(player.DateOfBirth, font)) {BackgroundColor = backgroundColor};
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase(player.Age, font)) {BackgroundColor = backgroundColor};
            table.AddCell(cell);

            cell = new PdfPCell(new Phrase(player.BirthPlace, font)) {BackgroundColor = backgroundColor};
            table.AddCell(cell);
        }
开发者ID:ColinStranc,项目名称:MockDraftAnalysis,代码行数:34,代码来源:PdfGenerator.cs


示例3: CreatePdf

        private void CreatePdf(FileStream outputStream)
        {
            var doc = new Document(PageSize.A4);

            PdfWriter.GetInstance(doc, outputStream);

            doc.Open();

            WriteFrontPage(doc);
            doc.NewPage();
            WriteSpecification(doc);

            foreach (var representation in _report.Representations)
            {
                doc.NewPage();
                doc.Add(new Paragraph("Representation"));
            }

            PdfPTable table = new PdfPTable(2);
            table.AddCell(new PdfPCell { Colspan = 1 });
            PdfPCell cell = new PdfPCell { Colspan = 1, HorizontalAlignment = 1, Phrase = new Phrase("REPRESENTATIONSKOSTNADER") };
            table.AddCell(cell);
            table.AddCell("Col 1 Row 1");
            table.AddCell("Col 2 Row 1");
            table.AddCell("Col 3 Row 1");
            table.AddCell("Col 1 Row 2");
            table.AddCell("Col 2 Row 2");
            table.AddCell("Col 3 Row 2");
            doc.Add(table);
            doc.Close();
        }
开发者ID:mbjurman,项目名称:ExpenseReport,代码行数:31,代码来源:ExpenseReportPdfTests.cs


示例4: ConfigurarConteudo

        private static void ConfigurarConteudo(List<Tarefa> tarefas, Document document)
        {
            foreach (Tarefa tarefa in tarefas)
            {
                PdfPTable table = new PdfPTable(2);

                PdfPCell cell = new PdfPCell(new Phrase( tarefa.ToString()));
                cell.Colspan = 2;
                cell.BackgroundColor = BaseColor.GRAY;
                cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
                table.AddCell(cell);

                PdfPCell cellSubitem = new PdfPCell(new Phrase("Subitem"));
                cellSubitem.BackgroundColor = BaseColor.LIGHT_GRAY;
                cellSubitem.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right

                PdfPCell cellPercentual = new PdfPCell(new Phrase("Percentual"));
                cellPercentual.BackgroundColor = BaseColor.LIGHT_GRAY;
                cellPercentual.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right

                table.AddCell(cellSubitem);
                table.AddCell(cellPercentual);

                foreach (Subitem subitem in tarefa.Subitens)
                {
                    table.AddCell(subitem.Titulo);
                    table.AddCell(subitem.Percentual.ToString());
                }

                document.Add(table);

                document.Add(new Paragraph(" "));
            }
        }
开发者ID:GiorgiCoelho,项目名称:QuartaFaseToo,代码行数:34,代码来源:GeradorTarefasPdf.cs


示例5: GeneratePdfReport

        public static void GeneratePdfReport(string filepath)
        {
            FileStream fileStream = new FileStream(filepath, FileMode.Create);
            Document document = new Document();
            PdfWriter writer = PdfWriter.GetInstance(document, fileStream);
            document.SetPageSize(PageSize.A3);
            document.Open();

            var paragraph = new Paragraph("Aggregated Sales Report",
                FontFactory.GetFont("Arial", 19, Font.BOLD));
            paragraph.SpacingAfter = 20.0f;
            paragraph.Alignment = 1;

            document.Add(paragraph);

            PdfPTable mainTable = new PdfPTable(1);
            var reports = GetDayReports();
            foreach (var dayReport in reports)
            {
                var headerCell = new PdfPCell(new Phrase("Date: " + dayReport.FormattedDate));
                headerCell.BackgroundColor = new BaseColor(175, 166, 166);
                mainTable.AddCell(headerCell);
                var table = GenerateReportTable(dayReport);
                mainTable.AddCell(table);
            }

            document.Add(mainTable);
            document.Close();
        }
开发者ID:NikolayKostadinov,项目名称:TelerikAkademy,代码行数:29,代码来源:PdfReportGenerator.cs


示例6: GeneratePDFReport

        // to generate the report call the GeneratePDFReport static method.
        // The pdf file will be generated in the SupermarketChain.ConsoleClient folder
        // TODO measures are missing
        // TODO code refactoring to limitr repeated chunks
        public static void GeneratePDFReport()
        {
            Document doc = new Document(iTextSharp.text.PageSize.A4, 10, 10, 40, 35);
            string filePath = @"..\..\..\..\Reports\salesReports.pdf";
            PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(filePath, FileMode.Create));
            doc.Open();
            PdfPTable table = new PdfPTable(5);

            Font verdana = FontFactory.GetFont("Verdana", 16, Font.BOLD);
            Font verdana2 = FontFactory.GetFont("Verdana", 12, Font.BOLD);

            PdfPCell header = new PdfPCell(new Phrase("Aggregated Sales Report", verdana));
            header.Colspan = 5;
            header.HorizontalAlignment = 1;
            table.AddCell(header);

            double totalSales = PourReportData(table);

            PdfPCell totalSum = new PdfPCell(new Phrase("Grand total:"));
            totalSum.Colspan = 4;
            totalSum.HorizontalAlignment = 2;
            totalSum.BackgroundColor = new BaseColor(161, 212, 224);
            table.AddCell(totalSum);

            PdfPCell totalSumNumber = new PdfPCell(new Phrase(String.Format("{0:0.00}", totalSales), verdana));
            totalSumNumber.BackgroundColor = new BaseColor(161, 212, 224);
            table.AddCell(totalSumNumber);

            doc.Add(table);
            doc.Close();

            DirectoryInfo directoryInfo = new DirectoryInfo(filePath);
            Console.WriteLine("Pdf report generated.");
            Console.WriteLine("File:  {0}", directoryInfo.FullName);
        }
开发者ID:TeamMingFern,项目名称:DatabaseApplicationsTeamwork,代码行数:39,代码来源:PDFGenerator.cs


示例7: generatePDFButton_Click

        protected void generatePDFButton_Click(object sender, EventArgs e)
        {
            PdfPTable pdfPTable = new PdfPTable(CreatedStudentInformationGridView.HeaderRow.Cells.Count);

            foreach (TableCell headerCell in CreatedStudentInformationGridView.HeaderRow.Cells)
            {
                PdfPCell pfdPCell = new PdfPCell(new Phrase(headerCell.Text));
                //pfdPCell.BackgroundColor = new BaseColor(newCenterGridView.HeaderStyle.ForeColor);
                pdfPTable.AddCell(pfdPCell);
            }

            foreach (GridViewRow gridViewRow in CreatedStudentInformationGridView.Rows)
            {
                foreach (TableCell tableCell in gridViewRow.Cells)
                {

                    PdfPCell pfdPCell = new PdfPCell(new Phrase(tableCell.Text));
                    //pfdPCell.BackgroundColor = new BaseColor(newCenterGridView.HeaderStyle.ForeColor);
                    pdfPTable.AddCell(pfdPCell);
                }
            }
            Document pdfDocument = new Document(PageSize.A4, 10f, 10f, 10f, 10f);
            PdfWriter.GetInstance(pdfDocument, Response.OutputStream);

            pdfDocument.Open();
            pdfDocument.Add(pdfPTable);
            pdfDocument.Close();

            Response.ContentType = "application/pdf";
            Response.AppendHeader("content-disposition", "attachment;filename=NewCenter.pdf");
            Response.Write(pdfDocument);
            Response.Flush();
            Response.End();
        }
开发者ID:mahmudandme,项目名称:SIMSSIMS,代码行数:34,代码来源:AddedStudentInformation.aspx.cs


示例8: Write

// ---------------------------------------------------------------------------
    public void Write(Stream stream) {
      // step 1
      using (Document document = new Document(PageSize.A5.Rotate())) {
        // step 2
        PdfWriter writer = PdfWriter.GetInstance(document, stream);
        writer.PdfVersion = PdfWriter.VERSION_1_5;
        writer.ViewerPreferences = PdfWriter.PageModeFullScreen;
        writer.PageEvent = new TransitionDuration();        
        // step 3
        document.Open();
        // step 4
        IEnumerable<Movie> movies = PojoFactory.GetMovies();
        Image img;
        PdfPCell cell;
        PdfPTable table = new PdfPTable(6);
        string RESOURCE = Utility.ResourcePosters;
        foreach (Movie movie in movies) {
          img = Image.GetInstance(Path.Combine(RESOURCE, movie.Imdb + ".jpg"));
          cell = new PdfPCell(img, true);
          cell.Border = PdfPCell.NO_BORDER;
          table.AddCell(cell);
        }
        document.Add(table);
      }
    }
开发者ID:,项目名称:,代码行数:26,代码来源:


示例9: CellLayout

 /**
  * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(
  *      com.lowagie.text.pdf.PdfPCell, com.lowagie.text.Rectangle,
  *      com.lowagie.text.pdf.PdfContentByte[])
  */
 public void CellLayout(
   PdfPCell cell, Rectangle rect, PdfContentByte[] canvas
 )
 {
     PdfContentByte cb = canvas[PdfPTable.BACKGROUNDCANVAS];
     cb.SaveState();
     if (duration < 90)
     {
         cb.SetRGBColorFill(0x7C, 0xFC, 0x00);
     }
     else if (duration > 120)
     {
         cb.SetRGBColorFill(0x8B, 0x00, 0x00);
     }
     else
     {
         cb.SetRGBColorFill(0xFF, 0xA5, 0x00);
     }
     cb.Rectangle(
       rect.Left, rect.Bottom,
       rect.Width * duration / 240, rect.Height
     );
     cb.Fill();
     cb.RestoreState();
 }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:30,代码来源:RunLengthEvent.cs


示例10: OnEndPage

        public override void OnEndPage(PdfWriter writer, Document document)
        {
            PdfPTable footer = new PdfPTable(3);
            footer.SetWidths(new float[] { 88f, 7f, 5f });
            footer.WidthPercentage = 100;
            footer.TotalWidth = document.PageSize.Width - (document.LeftMargin + document.RightMargin);

            PdfPCell emptycell = new PdfPCell();
            emptycell.Border = 0;
            footer.AddCell(emptycell);

            Chunk text = new Chunk(string.Format(GlobalStringResource.PageOfFooter,
                document.PageNumber), FontFactory.GetFont(FontFactory.HELVETICA, 8));

            PdfPCell footerCell = new PdfPCell(new Phrase(text));
            footerCell.Border = 0;
            footerCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            footer.AddCell(footerCell);

            PdfPCell cell = new PdfPCell(iTextSharp.text.Image.GetInstance(total));
            cell.Border = 0;
            cell.HorizontalAlignment = Element.ALIGN_LEFT;
            footer.AddCell(cell);
            footer.WriteSelectedRows(0, -1, 50, (document.BottomMargin - 10), writer.DirectContent);
        }
开发者ID:meanprogrammer,项目名称:sawebreports_migrated,代码行数:25,代码来源:Strategy2020ReportBuilder.cs


示例11: CreateTable

        private static PdfPTable CreateTable()
        {
            PdfPTable table = new PdfPTable(2);
            //actual width of table in points
            table.TotalWidth = 216f;
            //fix the absolute width of the table
            table.LockedWidth = true;

            //relative col widths in proportions - 1/3 and 2/3
            float[] widths = new float[] { 1f, 2f };
            table.SetWidths(widths);
            table.HorizontalAlignment = 0;
            //leave a gap before and after the table
            table.SpacingBefore = 20f;
            table.SpacingAfter = 30f;

            PdfPCell cell = new PdfPCell(new Phrase("Products"));
            cell.Colspan = 2;
            cell.Border = 0;
            cell.HorizontalAlignment = 1;
            table.AddCell(cell);

            // Seed data:
            for (int i = 0; i < DummySeed.Info.Count; i++)
            {
                table.AddCell(DummySeed.Info[i].Id.ToString());
                table.AddCell(DummySeed.Info[i].Name);
            }

            return table;
        }
开发者ID:Astatine-Haphazard,项目名称:AstatineTeamwork,代码行数:31,代码来源:PdfReport.cs


示例12: CreateDocument

		public void CreateDocument( List< ScanDetails > info, string path )
		{
			var doc = new Document( PageSize.A4 );
			PdfWriter.GetInstance( doc, new FileStream( path, FileMode.Create ) );

			doc.Open();
			doc.Add( new Paragraph() );

			PdfPTable table = new PdfPTable( 4 ) { WidthPercentage = 100 };
			//header
			PdfPCell cell = new PdfPCell { BackgroundColor = BaseColor.LIGHT_GRAY, Phrase = new Phrase( "URL" ) };
			table.AddCell( cell );

			cell.Phrase = new Phrase( "Response" );
			table.AddCell( cell );

			cell.Phrase = new Phrase( "Size" );
			table.AddCell( cell );

			cell.Phrase = new Phrase( "Page Title" );
			table.AddCell( cell );

			//rows
			foreach( var item in info )
			{
				table.AddCell( item.Url.ToString() );
				table.AddCell( item.Response );
				table.AddCell( item.Size.ToString() );
				table.AddCell( item.PageTitle );
			}

			doc.Add( table );

			doc.Close();
		}
开发者ID:faisal82,项目名称:swat-web-security-scanner,代码行数:35,代码来源:AgReportBuilder.cs


示例13: MakePdfButton_Click

        protected void MakePdfButton_Click(object sender, EventArgs e)
        {
            PdfPTable pdfTable = new PdfPTable(GridView1.HeaderRow.Cells.Count);

            foreach (TableCell headeCell in GridView1.HeaderRow.Cells)
            {
                PdfPCell pdfPCell = new PdfPCell(new Phrase(headeCell.Text));
                pdfTable.AddCell(pdfPCell);
            }

            foreach (GridViewRow gridViewRow in GridView1.Rows)
            {
                foreach (TableCell tableCell in gridViewRow.Cells)
                {
                    PdfPCell pdfPCell = new PdfPCell(new Phrase(tableCell.Text));
                    pdfTable.AddCell(pdfPCell);
                }
            }

            Document pdfDocument = new Document(PageSize.A4, 10f, 10f, 10f, 10f);
            PdfWriter.GetInstance(pdfDocument, Response.OutputStream);
            pdfDocument.Open();
            pdfDocument.Add(pdfTable);
            pdfDocument.Close();

            Response.ContentType = "application/pdf";
            Response.AppendHeader("Content-disposition", "Attachment;filename=Employee.pdf");
            Response.Write(pdfDocument);
            Response.Flush();
            Response.End();
        }
开发者ID:shuvo101,项目名称:UniversityManagmentSystemApp,代码行数:31,代码来源:ViewResult.aspx.cs


示例14: btndownload_Click

 protected void btndownload_Click(object sender, EventArgs e)
 {
     PdfPTable pdftable = new PdfPTable(gvtimetable.HeaderRow.Cells.Count);
     foreach(TableCell headercell in gvtimetable.HeaderRow.Cells)
     {
         Font font = new Font();
         font.Color = new BaseColor(gvtimetable.HeaderStyle.ForeColor);
         PdfPCell pdfcell = new PdfPCell(new Phrase(headercell.Text, font));
         pdfcell.BackgroundColor = new BaseColor(gvtimetable.HeaderStyle.BackColor);
         pdftable.AddCell(pdfcell);
     }
     foreach(GridViewRow gridviewrow in gvtimetable.Rows)
     {
         foreach(TableCell tablecell in gridviewrow.Cells)
         {
             Font font = new Font();
             font.Color = new BaseColor(gvtimetable.RowStyle.ForeColor);
             PdfPCell pdfcell = new PdfPCell(new Phrase(tablecell.Text));
             //pdfcell.BackgroundColor = ;
             pdftable.AddCell(pdfcell);
         }
     }
     Document pdfdocument = new Document(PageSize.A4, 10f, 10f, 10f, 10f);
     PdfWriter.GetInstance(pdfdocument, Response.OutputStream);
     pdfdocument.Open();
     pdfdocument.Add(pdftable);
     pdfdocument.Close();
     Response.ContentType = "application/pdf";
     Response.AppendHeader("content-disposition", "attachment;filename=Student_Timetable.pdf");
     Response.Write(pdfdocument);
     Response.Flush();
     Response.End();
 }
开发者ID:unifamz,项目名称:UniversityManagementSystem,代码行数:33,代码来源:timetable.aspx.cs


示例15: RenderHtml

        /// <summary>
        /// Using iTextSharp's limited HTML to PDF capabilities.
        /// </summary>
        public PdfPCell RenderHtml()
        {
            var pdfCell = new PdfPCell
            {
                UseAscender = true,
                UseDescender = true,
                VerticalAlignment = Element.ALIGN_MIDDLE
            };

            applyStyleSheet();

            var tags = setCustomTags();

            using (var reader = new StringReader(Html))
            {
                var parsedHtmlElements = HTMLWorker.ParseToList(reader, StyleSheet, tags, null);

                foreach (var htmlElement in parsedHtmlElements)
                {
                    applyRtlRunDirection(htmlElement);
                    pdfCell.AddElement(htmlElement);
                }

                return pdfCell;
            }
        }
开发者ID:andycarmona,项目名称:TimelyDepotUps,代码行数:29,代码来源:HtmlWorkerHelper.cs


示例16: CreatePdf

 public void CreatePdf(String dest)
 {
     Document document = new Document();
     PdfWriter.GetInstance(document, new FileStream(dest, FileMode.Create));
     document.Open();
     PdfPTable table = new PdfPTable(5);
     table.SetWidths(new int[] {1, 2, 2, 2, 1});
     PdfPCell cell;
     cell = new PdfPCell(new Phrase("S/N"));
     cell.Rowspan = 2;
     table.AddCell(cell);
     cell = new PdfPCell(new Phrase("Name"));
     cell.Colspan = 3;
     table.AddCell(cell);
     cell = new PdfPCell(new Phrase("Age"));
     cell.Rowspan = 2;
     table.AddCell(cell);
     table.AddCell("SURNAME");
     table.AddCell("FIRST NAME");
     table.AddCell("MIDDLE NAME");
     table.AddCell("1");
     table.AddCell("James");
     table.AddCell("Fish");
     table.AddCell("Stone");
     table.AddCell("17");
     document.Add(table);
     document.Close();
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:28,代码来源:SimpleRowColspan.cs


示例17: TestKeepTogether

 public void TestKeepTogether(bool tagged, bool keepTogether) {
     Document document = new Document();
     String file = "tagged_" + tagged + "-keeptogether_" + keepTogether + ".pdf";
     PdfWriter writer = PdfWriter.GetInstance(document, File.Create(outFolder + file));
     if (tagged)
         writer.SetTagged();
     document.Open();
     int columns = 3;
     int tables = 3;
     for (int tableCount = 0; tableCount < tables; tableCount++) {
         PdfPTable table = new PdfPTable(columns);
         for (int rowCount = 0; rowCount < 50; rowCount++) {
             PdfPCell cell1 = new PdfPCell(new Paragraph("t" + tableCount + " r:" + rowCount));
             PdfPCell cell2 = new PdfPCell(new Paragraph("t" + tableCount + " r:" + rowCount));
             PdfPCell cell3 = new PdfPCell(new Paragraph("t" + tableCount + " r:" + rowCount));
             table.AddCell(cell1);
             table.AddCell(cell2);
             table.AddCell(cell3);
         }
         table.SpacingAfter = 10f;
         table.KeepTogether = keepTogether;
         document.Add(table);
     }
     document.Close();
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:25,代码来源:KeepTogetherTest.cs


示例18: InstantialiseCell

 private void InstantialiseCell()
 {
     cell = new PdfPCell();
     //cell.BorderWidth = 0f;
     cell.PaddingTop = 7.5f;    // 10px http://www.unitconversion.org/typography/postscript-points-to-pixels-x-conversion.html
     cell.PaddingBottom = 7.5f;
 }
开发者ID:jennyngoclan,项目名称:Original_APF_Incident_System,代码行数:7,代码来源:Email_Incident_Handler.cs


示例19: CellLayout

 /**
  * @see com.itextpdf.text.pdf.PdfPCellEvent#cellLayout(com.itextpdf.text.pdf.PdfPCell,
  *      com.itextpdf.text.Rectangle, com.itextpdf.text.pdf.PdfContentByte[])
  */
 virtual public void CellLayout(PdfPCell cell, Rectangle position,
         PdfContentByte[] canvases) {
     float effectivePadding = styleValues.BorderWidthLeft/2 + styleValues.HorBorderSpacing;
     float x1 = position.Left + effectivePadding;
     if (styleValues.IsLastInRow){
         effectivePadding = styleValues.BorderWidthRight/2 + styleValues.HorBorderSpacing;
     } else {
         effectivePadding = styleValues.BorderWidthRight/2;
     }
     float x2 = position.Right - effectivePadding;
     effectivePadding = styleValues.BorderWidthTop/2 + styleValues.VerBorderSpacing;
     float y1 = position.Top - effectivePadding;
     effectivePadding = styleValues.BorderWidthBottom/2;
     float y2 = position.Bottom + effectivePadding;
     PdfContentByte cb = canvases[PdfPTable.LINECANVAS];
     BaseColor color = styleValues.Background;
     if (color != null) {
         cb.SetColorStroke(color);
         cb.SetColorFill(color);
         cb.Rectangle(x1, y1, x2-x1, y2-y1);
         cb.Fill();
     }
     BaseColor borderColor = styleValues.BorderColorLeft;
     float width = styleValues.BorderWidthLeft;
     if (borderColor != null && width != 0) {
         cb.SetLineWidth(width);
         cb.SetColorStroke(borderColor);
         cb.MoveTo(x1, y1); // start leftUpperCorner
         cb.LineTo(x1, y2); // left
         cb.Stroke();
     }
     borderColor = styleValues.BorderColorBottom;
     width = styleValues.BorderWidthBottom;
     if (borderColor != null && width != 0) {
         cb.SetLineWidth(width);
         cb.SetColorStroke(borderColor);
         cb.MoveTo(x1, y2); // left
         cb.LineTo(x2, y2); // bottom
         cb.Stroke();
     }
     borderColor = styleValues.BorderColorRight;
     width = styleValues.BorderWidthRight;
     if (borderColor != null && width != 0) {
         cb.SetLineWidth(width);
         cb.SetColorStroke(borderColor);
         cb.MoveTo(x2, y2); // bottom
         cb.LineTo(x2, y1); // right
         cb.Stroke();
     }
     borderColor = styleValues.BorderColorTop;
     width = styleValues.BorderWidthTop;
     if (borderColor != null && width != 0) {
         cb.SetLineWidth(width);
         cb.SetColorStroke(borderColor);
         cb.MoveTo(x2, y1); // right
         cb.LineTo(x1, y1); // top
         cb.Stroke();
     }
     cb.ResetRGBColorStroke();
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:64,代码来源:CellSpacingEvent.cs


示例20: ExportToPdf

        public string ExportToPdf(DateTime startDate, DateTime endDate)
        {
            DataTable dt = this.CreateTableForReport(startDate, endDate);
            Document document = new Document();
            var exportPath = this.exportFileName;
            PdfWriter.GetInstance(document, new FileStream(exportPath, FileMode.Create));
            document.Open();
            Font font7 = FontFactory.GetFont(FontFactory.HELVETICA, 7);
            Font font7bold = FontFactory.GetFont(FontFactory.HELVETICA, 7, Font.BOLD);
            Font font10 = FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD);

            PdfPTable table = new PdfPTable(dt.Columns.Count);
            float[] widths = new float[] { 2f, 4f, 3f, 3f, 4f, 3f };

            table.SetWidths(widths);

            table.WidthPercentage = 100;
            PdfPCell cell = new PdfPCell(new Phrase("Products"));

            cell.Colspan = dt.Columns.Count;

            PdfPCell header = new PdfPCell(new Phrase("Aggregated Sales Report", font10));
            header.Colspan = 6;
            header.HorizontalAlignment = 1;
            header.VerticalAlignment = 1;
            header.PaddingTop = 10;
            header.PaddingBottom = 10;
            table.AddCell(header);

            foreach (DataColumn c in dt.Columns)
            {
                table.AddCell(new PdfPCell(new Phrase(c.ColumnName, font7bold)) { BackgroundColor = new BaseColor(250, 200, 140), Padding = 2 });
            }

            foreach (DataRow r in dt.Rows)
            {
                if (dt.Rows.Count > 0)
                {
                    table.AddCell(new PdfPCell(new Phrase(r[0].ToString(), font7bold))
                    {
                        Colspan = 6,
                        BackgroundColor = new BaseColor(250, 230, 200),
                        Padding = 2
                    });
                    table.AddCell(new Phrase(""));
                    table.AddCell(new Phrase(r[1].ToString(), font7));
                    table.AddCell(new Phrase(r[2].ToString(), font7));
                    table.AddCell(new Phrase(r[3].ToString(), font7));
                    table.AddCell(new Phrase(r[4].ToString(), font7));
                    table.AddCell(new PdfPCell(new Phrase(r[5].ToString(), font7))
                    {
                        BackgroundColor = new BaseColor(250, 200, 140),
                        Padding = 2
                    });
                }
            }
            document.Add(table);
            document.Close();
            return ExportPdfReportSuccess;
        }
开发者ID:Team-Goldenrod,项目名称:SupermarketsChain,代码行数:60,代码来源:SqlServerToPdfReport.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# pdf.PdfPRow类代码示例发布时间:2022-05-26
下一篇:
C# pdf.PdfOutline类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap