Android Question PDFDocument and word wrap - resolved

Nokia

Active Member
Licensed User
When using the library PDFDocument, is there a way to word wrap a sentence for paragraph in an invisible rectangle?
 

Nokia

Active Member
Licensed User

thanks Erel..

not sure if this needs to go on a new thread or not.. but when I use your example.. it comes out blurry.. any suggestions?
 

Attachments

  • pdf sample.PNG
    pdf sample.PNG
    52.1 KB · Views: 56
Upvote 0

Erel

Administrator
Staff member
Licensed User
Have you tried to run this? Your code is broken.

 
Upvote 0

Nokia

Active Member
Licensed User
Have you tried to run this? Your code is broken.

--=
No, I could not run this as my tablet android version is 7.1.1
 
Upvote 0

Nokia

Active Member
Licensed User
I found a way to fix my issue.. I wrote a crude function to allow text to wrap and allow the text to be selectable. In the bitmap version you can't select and copy text from pdf. If anybody has a cleaner way to write the function let me know.. thanks..

B4X:
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
 

Attachments

  • pdf sample.PNG
    pdf sample.PNG
    87.8 KB · Views: 34
Upvote 0
Top