Android Question PdfDocument

BitsAndBytes

Active Member
Licensed User
I have 22 lines of text and i want to create a pdf file with 3 pages and print lines them so each page can have 10 lines and the last page will have 2 remain lines can you help? Thanks :)

Private pdfDoc As PdfDocument
pdfDoc.Initialize

totalLines = 22
linesPerPage = 10
totalPagesToCreate = 3
intSpacing = 30

First line must have 10 lines
Second must have 10 lines
and the last page 2 remain lines

B4X:
For i = 0 To totalPagesToCreate - 1

      pdfDoc.StartPage(595, 842)
               
  pdfDoc.Canvas.DrawText("New line of text", 40, (i * intSpacing) + 20, Typeface.SANS_SERIF, 14 / GetDeviceLayoutValues.Scale , Colors.Black, "LEFT")
       
     pdfDoc.FinishPage

End If
 

DonManfred

Expert
Licensed User
Longtime User
Do what you said you want to do. It does not work if you just iterate through ALL and you create a new pdf page for each iteration/each line).
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Write the code like you "think"

B4X:
For P=1 To NumberOfPages
       CreatePage
Next

Sub CreatePage
        Dim yPos as Int = 0
        pdfDoc.StartPage(595, 842)
        For L=1 To NumberOFLines
               GetTheLine
               PrintIt at yPos
               Add Spacing to yPos
        Next
       pdfDoc.FinishPage
End Sub
 
Upvote 0

BitsAndBytes

Active Member
Licensed User
My problem is that i want to print in first page the line 1 and line 2 and in second page the line 3 and line 4 . I dont want to print all lines in every page Thanks
 
Last edited:
Upvote 0
Top