Private Sub PDF_WrapText(PDF As PdfDocument, Text As String, x As Float, y As Float, Length As Float, Font As Typeface,TextSize As Float, TextColor As Int, Alignment As String) As PdfDocument
Dim y1 As Float = y
Dim b As Int = 0
For c = 1 To Text.Length
If Text.SubString2(b, c).Length > Length / 4.5 Then
PDF.Canvas.DrawText(Text.SubString2(b,Text.LastIndexOf2(" ", c)), x,y1,Font,TextSize,TextColor, Alignment)
b = Text.LastIndexOf2(" ", c) + 1
y1 = y1 + TextSize
End If
If c = Text.Length And Text.SubString2(b,c).Length > 0 Then
PDF.Canvas.DrawText(Text.SubString2(b,c), x,y1,Font,TextSize,TextColor, Alignment)
End If
Next
Return PDF
End Sub