iOS Question DrawText on pdf

iCAB

Well-Known Member
Licensed User
Hi All

I spent few hours trying to figure why this code is not working in B4I.

B4X:
Public Sub PrintTestReceipt() As String
    PDFReceiptFile = PDF_MTR_RECEIPT_FILE_NAME
    Dim TestFont As Font = Font.CreateNew2( "Courier", 10 )
   
    If File.Exists(File.DirTemp, PDFReceiptFile ) = True Then
        File.Delete(File.DirTemp, PDFReceiptFile)
    End If
   
    cvs.InitializePDF(File.DirTemp, PDFReceiptFile,612,792)

'    For iIndex = 0 To 50
'        cvs.DrawLine( 0, iIndex * 10, 200, iIndex * 10, Colors.Black, 1 )
'    Next

    For iIndex = 0 To 10
        Dim TempText As String     = "Line_" & iIndex
        cvs.DrawText( TempText, 20, iIndex * 10, TestFont, Colors.Black, "LEFT")
    Next
'  
    cvs.Release
   
    PDFFullReceiptFile =  File.Combine(File.DirTemp, PDFReceiptFile )
   
    Return PDFFullReceiptFile
End Sub
If I load the generated pdf file in a WebView, it shows as it is supposed to look.
If I email it and try to view it on a PC, it is random: sometimes totally empty, other times few labels are displayed, etc... (unpredictable)
 
Last edited:

iCAB

Well-Known Member
Licensed User
Maybe the file gets corrupted when you send it.
Thanks Erel, that's it

I am using mail composer and forgot to change the attachment type (fully focused on debugging the new code :( , instead of looking at the existing code )
 
Top