HtmlToPdfConverter

Converts HTML to PDF document.

Note: HTML-to-PDF conversion internally relies on the system WebView implementation. This means that there are certain aspects of this conversion process that PSPDFKit can't support. This includes, for example, any possible WebView bugs.

Note: JavaScript execution is enabled by default. This could cause security and performance issues. Please review your JavaScripts carefully. If you wish to disable JavaScript execution while performing the HTML conversion, set setJavaScriptEnabled to false.

Note: This API requires HTML-to-PDF conversion feature in your license.

Types

Link copied to clipboard
object Companion

Factory methods and device-capability checks for HtmlToPdfConverter.

Link copied to clipboard

Listener for page loading progress updates used when loading HTML page in HtmlToPdfConverter.

Functions

Link copied to clipboard
fun convertToPdfAsync(): Single<File>

Performs HTML-to-PDF conversion to a temporary file in application's cache directory.

fun convertToPdfAsync(outputFile: File): Completable

Performs HTML-to-PDF conversion to specified file.

Link copied to clipboard
fun density(@IntRange(from = 1) densityDpi: Int): HtmlToPdfConverter

Sets the density that should be used when converting HTML images to PDF. Defaults to 300 dpi.

Link copied to clipboard

Sets the size of the created PDF. Defaults to NewPage.PAGE_SIZE_A4.

Link copied to clipboard

Enables or disables JavaScript processing. Defaults to true.

Link copied to clipboard

Sets listener that will be called whenever page loading progress changes.

Link copied to clipboard

Sets resource interceptor that will be called whenever the HTML converter wants to load any page resource (image, stylesheet, JavaScript etc.). Use this if you want to inject custom resources that are otherwise not accessible from the base URL or when you want to override default resource resolution.

Link copied to clipboard
fun timeout(@IntRange(from = 0) timeout: Long): HtmlToPdfConverter

Sets the timeout for loading the HTML document when converting. Defaults to 30000 ms.

Link copied to clipboard

Sets the document title (set via DocumentPdfMetadata). Defaults to HTML title if present (i.e. contents of the <title> tag); sets no title if the HTML document has no title.