PdfGenerator

class PdfGenerator(context: Context, webView: WebView = WebView(context))

PdfGenerator creates PDF files from HTML content using Android's WebView and PrintManager. Must be initialized on the Main thread.

Parameters

context

Application context for initializing WebView and PrintManager.

webView

WebView instance for loading HTML content (Visible for testing).

Constructors

Link copied to clipboard
constructor(context: Context, webView: WebView = WebView(context))

Functions

Link copied to clipboard
fun generatePdfWithHtml(html: String, pdfTitle: String, onPdfPrinted: () -> Unit)

Generates a PDF file from the provided HTML content.