1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| Dim stringToRead As String = "Characters in 1st line to read" & Environment.NewLine & _
Environment.NewLine & "and 2nd line" & _
Environment.NewLine & "and the end"
Dim lines As String() = stringToRead.Split(New String() {Environment.NewLine}, StringSplitOptions.None)
Using fs As New FileStream(Application.StartupPath & "\Output2.pdf", FileMode.Create)
Dim doc As New Document(PageSize.A4)
Dim writer = PdfWriter.GetInstance(doc, fs)
doc.Open()
Dim bf = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED)
Dim contentByte = writer.DirectContent
contentByte.BeginText()
contentByte.SetFontAndSize(bf, 12)
Dim y As Integer = 500
For Each line As String In lines
contentByte.ShowTextAligned(PdfContentByte.ALIGN_LEFT, line, 300, y, 0)
y -= 20
Next
contentByte.EndText()
doc.Close()
End Using |
Partager