Just a thought:
Maybe you can do it by using a WebView to render the html and print the resulting page as pdf?
It looks like if you can output the webview on a canvas, you can print the canvas as pdf with this:
This is an Android 4.4+ (API 19+) library. Its two main features are: 1. Creating Pdf documents with the PdfDocument object. 2. Printing with the Printer object. Lets start with PdfDocument. Dim pdf As PdfDocument pdf.Initialize pdf.StartPage(595, 842) 'A4 size pdf.Canvas.DrawLine(2, 2, 593...
I've handled this situation in two different ways, depending on my needs:
1. Create the HTML, write it into a file, and then open it with Word (directly from you B4J app). Word supports HTML and from there you can edit or convert to PDF or anything.
2. Load the HTML string into a WebView. You can make it invisible if the user doesn't need to see it, and then send it to the printer. You can then choose a PDF printer. There're lots of them. The function I use to print a WebView:
B4X:
Sub PrintWebView(w As WebView)
Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob
PJ.ShowPageSetupDialog(Null)
PJ.ShowPrintDialog(Null)
Dim WVJO As JavaObject = w
WVJO.RunMethodJO("getEngine",Null).RunMethod("print",Array(PJ.GetObject))
PJ.EndJob
End Sub