Annabelle
Annabelle

Reputation: 754

Convert HTML String to PDF with native PrintedPdfDocument

How can I convert HTML string (created on the fly) to PDF only using native PrintedPdfDocument (API 19 or higher)? I look for the solution in which I do not need to add any external libraries.

Upvotes: 2

Views: 1123

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007584

If the HTML is very limited, you can try TextView and some HTML-to-Spanned converter (e.g., Html.fromHtml()).

Or, as I noted in comments, you can use WebView, though you indicate that it does not meet your business requirements, and I am not sure that you can get to the PDF anyway.

Otherwise, your only library-free option is to send the HTML to a server, one that can return to you a PDF.

Upvotes: 0

Related Questions