2009-08-25 185 views
0

对于这条线的成员:widthPercentage宽度百分比不是iTextSharp的

c.WidthPercentage = 100F 

我收到此错误:

错误1 'widthPercentage宽度百分比' 不是 'iTextSharp.text.Table' 的成员。

这是整个代码。它是直接取自教程

进口系统 进口System.Drawing中 进口System.IO 进口iTextSharp.text 进口iTextSharp.text.pdf 命名空间iTextSharp.tutorial.Chap05

Public Class Chap0514 

    Public Sub New() 
     Console.WriteLine("Chapter 5 example 14: nested tables") 
     Dim document As Document = New Document 
     Try 
      PdfWriter.GetInstance(document, New FileStream("Chap0514.pdf", FileMode.Create)) 
      document.Open 
      Dim secondTable As Table = New Table(2) 
      secondTable.AddCell("2nd table 0.0") 
      secondTable.AddCell("2nd table 0.1") 
      secondTable.AddCell("2nd table 1.0") 
      secondTable.AddCell("2nd table 1.1") 
      Dim aTable As Table = New Table(4, 4) 
      aTable.AutoFillEmptyCells = True 
      aTable.AddCell("2.2", New Point(2, 2)) 
      aTable.AddCell("3.3", New Point(3, 3)) 
      aTable.AddCell("2.1", New Point(2, 1)) 
      aTable.InsertTable(secondTable, New Point(1, 3)) 
      document.Add(aTable) 
      Dim thirdTable As Table = New Table(2) 
      thirdTable.AddCell("3rd table 0.0") 
      thirdTable.AddCell("3rd table 0.1") 
      thirdTable.AddCell("3rd table 1.0") 
      thirdTable.AddCell("3rd table 1.1") 
      aTable = New Table(5, 5) 
      aTable.AutoFillEmptyCells = True 
      aTable.AddCell("2.2", New Point(2, 2)) 
      aTable.AddCell("3.3", New Point(3, 3)) 
      aTable.AddCell("2.1", New Point(2, 1)) 
      aTable.InsertTable(secondTable, New Point(1, 3)) 
      aTable.InsertTable(thirdTable, New Point(6, 2)) 
      document.Add(aTable) 
      Dim a As Table = New Table(2) 
      a.Widths = New Single() {85, 15} 
      a.AddCell("a-1") 
      a.AddCell("a-2") 
      Dim b As Table = New Table(5) 
      b.Widths = New Single() {15, 7, 7, 7, 7} 
      b.AddCell("b-1") 
      b.AddCell("b-2") 
      b.AddCell("b-3") 
      b.AddCell("b-4") 
      b.AddCell("b-5") 
      Dim c As Table = New Table(3, 1) 
      c.WidthPercentage = 100F 
      c.Widths = New Single() {20, 2, 78} 
      c.InsertTable(a, New Point(0, 0)) 
      c.InsertTable(b, New Point(0, 2)) 
      document.Add(c) 
      Dim t1 As Table = New Table(3) 
      t1.AddCell("1.1") 
      t1.AddCell("1.2") 
      t1.AddCell("1.3") 
      Dim t2 As Table = New Table(2) 
      t2.AddCell("2.1") 
      t2.AddCell("2.2") 
      t1.InsertTable(t2) 
      t1.AddCell("new cell") 
      document.Add(t1) 
      t1 = New Table(2, 2) 
      Dim i As Integer = 0 
      While i < 4 
       t1.AddCell("t1") 
       System.Math.Min(System.Threading.Interlocked.Increment(i),i-1) 
      End While 
      t2 = New Table(3, 3) 
      i= 0 
      While i < 9 
       If i = 4 Then 
        t2.InsertTable(t1) 
       Else 
        t2.AddCell("t2") 
       End If 
       System.Math.Min(System.Threading.Interlocked.Increment(i),i-1) 
      End While 
      Dim t3 As Table = New Table(4, 4) 
      i= 0 
      While i < 16 
       If i = 10 Then 
        t3.InsertTable(t2) 
       Else 
        t3.AddCell("t3") 
       End If 
       System.Math.Min(System.Threading.Interlocked.Increment(i),i-1) 
      End While 
      document.Add(t3) 
     Catch de As DocumentException 
      Console.Error.WriteLine(de.Message) 
     Catch ioe As IOException 
      Console.Error.WriteLine(ioe.Message) 
     End Try 
     document.Close 
    End Sub 
End Class 

末命名空间

回答

3

看来您正在使用的iTextSharp版本比本教程中使用的版本更新。这应该工作:

c.Width = 100F 
+0

也许你可以回答这个问题呢? http://stackoverflow.com/questions/1331253/i-did-an-imports-error-type-expected – 2009-08-25 22:43:20

+0

也可以请请有你的联系方式,我想问你更多的问题itextsharp – 2009-08-25 22:44:01

+0

为什么不让大家看到问题?这就是为什么。 – Rowan 2009-08-26 10:15:03