PDFThumbnailGenerator
object PDFThumbnailGenerator
Utility class for generating PDF thumbnails from various document sources.
This class provides static methods to generate thumbnails from PDF documents using different sources like File, Uri, ByteArray, InputStream, or asset paths. All operations are performed on background threads for optimal performance.
Example usage:
// Generate a simple thumbnail
val thumbnail = PDFThumbnailGenerator.generateThumbnail(context, file)
// Generate with custom configuration
val config = ThumbnailConfig(
width = 300,
height = 400,
quality = Bitmap.Config.ARGB_8888,
annotationRendering = true
)
val thumbnail = PDFThumbnailGenerator.generateThumbnail(context, file, config = config)
// Generate multiple thumbnails
val thumbnails = PDFThumbnailGenerator.generateThumbnails(
context, file, listOf(0, 1, 2)
)
Content copied to clipboard
Functions
Link copied to clipboard
Clears the thumbnail cache to free memory.
Link copied to clipboard
suspend fun generateThumbnail(context: Context, source: Any, pageIndex: Int = 0, config: ThumbnailConfig = ThumbnailConfig(), password: String? = null, useCache: Boolean = true): Bitmap?
Generates a thumbnail for a specific page of a PDF document.
Link copied to clipboard
suspend fun generateThumbnails(context: Context, source: Any, pageIndices: List<Int>, config: ThumbnailConfig = ThumbnailConfig(), password: String? = null, useCache: Boolean = true): List<Bitmap?>
Generates thumbnails for multiple pages of a PDF document.
Link copied to clipboard
Gets the current cache size in KB.
Link copied to clipboard
Gets the total number of pages in a PDF document.