I am not a visual basic programmer (the last time I used visual basic was in 1996 and I said: never again!), but just by using Google, I adapted your example like this:
Dim table As New PdfPTable(3)
table.WidthPercentage = 100
table.AddCell(GetCell("Text to the left", PdfPCell.ALIGN_LEFT))
table.AddCell(GetCell("Text in the middle", PdfPCell.ALIGN_CENTER))
table.AddCell(GetCell("Text to the right", PdfPCell.ALIGN_RIGHT))
document.Add(table)
Public Function GetCell(ByVal text As String, ByVal alignment As Integer) As PdfPCell
Dim cell As New PdfPCell(New Phrase(text))
cell.Padding = 0
cell.HorizontalAlignment = alignment
cell.Border = PdfPCell.NO_BORDER
Return cell
End Function
This is commonly known:
- Methods in Java start with lower case; methods in .NET start with upper case, so when people ask you to use Java code as pseudo code and to convert Java to .NET, you need to change methods such as
add()
and addCell()
into Add()
and AddCell()
.
- Member-variables in Java are changed and consulted using getters and setters; variables in .NET are changed and consulted using methods that look like properties. This means the you need to change lines such as
cell.setBorder(border);
and border = cell.getBorder();
into cell.Border = border
and border = cell.Border
.
iText and iTextSharp are kept in sync, which means that, using the two rules explained above, a developer won't have any problem to convert iText code into iTextSharp code.
When in doubt about a method, one can always do as I did, Google for these methods and properties! You'll find examples such as:
If you want a whole bunch of examples in one place, download The Best iText Questions on StackOverflow
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…