I've been using the old PDFWriter to make PDFs and don't know when I could move my users to the PdfDocument as that would force them to API 19 and besides if it ain't broke don't fix it
Anyway. I've been using the following routine to give me an idea of a string width so when I am make my PDF I can center, align, justify text.
ONLY the other day did I realize on devices with different Scale values were the PDFs not being generated correctly so I added the divide "Width / mLayoutValues.Scale" and that seems to make everything work as it should
MY Problem is I know this is NOT right. I am using a Screen function to calculate the width of text being shown on a point device (printers are 1/72)
Now this code about seems to work just fine (see attached PDF - looks great / same when generated by S3, S5 and Tab2)
Any help by anyone?
Anyway. I've been using the following routine to give me an idea of a string width so when I am make my PDF I can center, align, justify text.
B4X:
Public Sub GetTextWidth(Text As String, TextSize As Int, MonoSpace As Boolean) As Int
Dim FmtLabel As Label
Dim JavaObj As JavaObject
FmtLabel.Initialize("")
FmtLabel.TextSize = TextSize
FmtLabel.Text = Text
If MonoSpace Then FmtLabel.Typeface = Typeface.CreateNew(Typeface.MONOSPACE, Typeface.STYLE_NORMAL)
JavaObj = FmtLabel
JavaObj.RunMethod("setPadding", Array As Object(0, 0, 0, 0))
JavaObj.RunMethod("setIncludeFontPadding", Array As Object(False))
Dim Width As Int = mCanvas.MeasureStringWidth(FmtLabel.Text, FmtLabel.Typeface, FmtLabel.TextSize)
Return Width / mLayoutValues.Scale
End Sub
ONLY the other day did I realize on devices with different Scale values were the PDFs not being generated correctly so I added the divide "Width / mLayoutValues.Scale" and that seems to make everything work as it should
MY Problem is I know this is NOT right. I am using a Screen function to calculate the width of text being shown on a point device (printers are 1/72)
Now this code about seems to work just fine (see attached PDF - looks great / same when generated by S3, S5 and Tab2)
Any help by anyone?