iTextSharp.text.pdf.PdfPTable.SetTotalWidth C# (CSharp) Метод

SetTotalWidth() публичный Метод

public SetTotalWidth ( float columnWidth ) : void
columnWidth float
Результат void
        public void SetTotalWidth(float[] columnWidth)
        {
            if (columnWidth.Length != NumberOfColumns)
                throw new DocumentException(MessageLocalization.GetComposedMessage("wrong.number.of.columns"));
            totalWidth = 0;
            for (int k = 0; k < columnWidth.Length; ++k)
                totalWidth += columnWidth[k];
            SetWidths(columnWidth);
        }

Usage Example

Пример #1
2
 public static void CreateHardwareReport(string fileName, IEnumerable<HardwareCountReport> hardwares)
 {
     try
     {
         Document document = new Document(PageSize.A4, 72, 72, 72, 72);
         PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None));
         document.Open();
         document.Add(new Paragraph(Element.ALIGN_CENTER, "Hardware Report", new Font(iTextSharp.text.Font.FontFamily.HELVETICA, 16, Font.BOLD)));
         document.Add(new Chunk(Chunk.NEWLINE));
         var table = new PdfPTable(3);
         table.SetTotalWidth(new float[] { 25f, 50f, 25f });
         table.WidthPercentage = 100;
         table.AddCell(new Phrase("Category"));
         table.AddCell(new Phrase("Hardware Model/Type"));
         table.AddCell(new Phrase("Total"));
         foreach (var hw in hardwares)
         {
             table.AddCell(new Phrase(hw.Category));
             table.AddCell(new Phrase(hw.Model));
             table.AddCell(new Phrase(hw.Count));
         }
         document.Add(table);
         document.Close();
     }
     catch (Exception x)
     {
         Log.Error("Error when creating report.", x);
     }
 }
All Usage Examples Of iTextSharp.text.pdf.PdfPTable::SetTotalWidth