Android Question PDF Margins Vary by Device

mmieher

Active Member
Licensed User
Longtime User
Morning, Droids!

I am using the PDF library to create PDF's. My problem is that the right margin limit is different depending on the device it is run on. I do not know if it is the OS version or what.

I must be missing something in the page setup?

B4X:
    Dim pdfInfo As PageInfo
    Dim pdfRect As Rect
  
    pdf.Initialize("")
  
    pdfRect.Initialize(10,10,585,832)
    pdfInfo.Initialize(595,842,1,pdfRect)
  
    Dim pdfPage As Page = pdf.startPage(pdfInfo)
    cv = pdfPage.Canvas    '    cv is initialized in Activity_Create because I use it all the time.
  
    pdfFontFace = Typeface.SANS_SERIF
    pdfFontSize = 8
    pdfFontAlign = "LEFT"
  
    Outprint("Hello There!",570,0,0,False)
    ...

Sub Outprint(inText As String, inX As Int, inY As Int, MaxWidth As Int, fFit As Boolean)
  
    Dim subX As Int = inX
    Dim subY As Int = inY + 15
  
    Dim tWidth As Int = cv.MeasureStringWidth(inText,pdfFontFace,pdfFontSize)
  
    If MaxWidth<>0 Then
        Do Until tWidth < MaxWidth
            inText = s.Left(inText,inText.Length-1)
            tWidth = cv.MeasureStringWidth(inText,pdfFontFace,pdfFontSize)
        Loop
    End If
  
    DrawMultilineText(cv, inText, subX, subY, pdfFontFace, pdfFontSize, Colors.Black, pdfFontAlign, 0dip)
  
End Sub
On my development tablet, the PDF looks perfect. On the customer's tablets, the output is truncated on the right edge. All tablets are Samsung Galaxy's.
Any ideas?
Marc
 
Top