This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/android/conversion/pdf-to-image.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Android PDF to image library: Convert PDF to JPG, PNG | Nutrient

To render an image from a PDF file in Nutrient Android SDK, you need to do the following:

try {
// Create a Uri for the PDF file.
val uri = Uri.parse("path/to/file.pdf")
// Instantiate a `Document` from the PDF file's URL.
val document = PdfDocumentLoader.openDocument(context, uri)
val pageIndex = 0
val pageImageSize = document.getPageSize(pageIndex).toRect()
// Create the image
val bitmap = document.renderPageToBitmap(
context,
pageIndex
pageImageSize.width().toInt()
pageImageSize.height().toInt()
)
} catch(ex: Exception) {
// Handle error.
}

Note that the renderPageToBitmap API used in the above example is a synchronous API that will block whatever thread it’s called into, so make sure to either call it on a background thread or use the asynchronous method, renderPageToBitmapAsync.