0
次のコードを書いてPDFでテキストを書きましたが、テキストの後に改行したいと思います。iTextSharpで改行文字を導入するには
Dim document As Document
document = New Document(PageSize.A4, 5.0F, 20.0F, 20.0F, 20.0F)
Try
Dim writer As PdfWriter
writer = PdfWriter.GetInstance(document, New FileStream(filename, FileMode.Create))
document.Open()
Dim spacing As Integer
spacing = 0
Dim curY, lineHeight As Double
curY = document.Top
lineHeight = 0
Const maxPerLine As Integer = 3
For i As Integer = 0 To 5
Dim table As PdfPTable
table = New PdfPTable(4)
table.DefaultCell.Border = Rectangle.NO_BORDER
table.TotalWidth = 200.0F
table.LockedWidth = True
Dim cell As PdfPCell
cell = New PdfPCell(New Phrase("hello \n" + i + "\n" + "wass up ?"))
cell.Colspan = 4
cell.HorizontalAlignment = 0
cell.Border = Rectangle.NO_BORDER
cell.Padding = 30.0F
table.AddCell(cell)
table.WriteSelectedRows(0, -1, document.Left + spacing, curY, writer.DirectContent)
spacing = spacing + 200
lineHeight = Math.Max(lineHeight, table.TotalHeight)
If 0 = (i + 1) Mod maxPerLine Then
curY = curY - lineHeight
spacing = 0
lineHeight = 0
End If
Next
Catch ex As Exception
Finally
document.Close()
End Try
私はParagraphで試しましたが、まだ新しい行にテキストを入力できません。
私はiTextSharpの文書を読んでいますが、行を分割して "\ n"を使いたいが、それは機能していません。
テキストの後に改行するにはどうすればよいですか?
ありがとうございます。 – deepak
Environment.NewLineを使用しています。私は別々の段落を追加する必要はありません –