PdfFile

class PdfFile(pdfiumCore: PdfiumCore, pageFitPolicy: FitPolicy, viewSize: Size, originalUserPages: List<Int>?, isVertical: Boolean, spacingPx: Int, autoSpacing: Boolean, fitEachPage: Boolean, maxPageCacheSize: Int)

Manages PDF document and its pages.

Parameters

pdfiumCore

The {@link PdfiumCore} instance used to interact with the PDF document.

pageFitPolicy

The policy used to fit pages to the view.

viewSize

The size of the view where the PDF document is displayed.

originalUserPages

The original user-defined page order (optional).

isVertical

True if scrolling is vertical, else it's horizontal.

spacingPx

Fixed spacing between pages in pixels.

autoSpacing

Calculate spacing automatically so each page fits on its own in the center of the view.

fitEachPage

True if every page should fit separately according to the {@link FitPolicy}, else the largest page fits and other pages scale relatively.

maxPageCacheSize

The maximum number of pages that can be kept in the view

Constructors

Link copied to clipboard
constructor(pdfiumCore: PdfiumCore, pageFitPolicy: FitPolicy, viewSize: Size, originalUserPages: List<Int>?, isVertical: Boolean, spacingPx: Int, autoSpacing: Boolean, fitEachPage: Boolean, maxPageCacheSize: Int)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

get page size with biggest dimension (width in vertical mode and height in horizontal mode)

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Ensures the given user-specified page number is within the valid range, considering the original user-defined page order if provided.

Link copied to clipboard
fun dispose()
Link copied to clipboard
fun documentPage(userPage: Int): Int
Link copied to clipboard
fun getDocLen(zoom: Float): Float
Link copied to clipboard
fun getPageAtOffset(offset: Float, zoom: Float): Int
Link copied to clipboard
fun getPageLength(pageIndex: Int, zoom: Float): Float

Get the page's height if swiping vertical, or width if swiping horizontal.

Link copied to clipboard
fun getPageLinks(pageIndex: Int): List<Link>
Link copied to clipboard
fun getPageOffset(pageIndex: Int, zoom: Float): Float

Get primary page offset, that is Y for vertical scroll and X for horizontal scroll

Link copied to clipboard
fun getPageSize(pageIndex: Int): SizeF?
Link copied to clipboard
fun getPageSpacing(pageIndex: Int, zoom: Float): Float
Link copied to clipboard
fun getScaledPageSize(pageIndex: Int, zoom: Float): SizeF
Link copied to clipboard
fun getSecondaryPageOffset(pageIndex: Int, zoom: Float): Float

Get secondary page offset, that is X for vertical scroll and Y for horizontal scroll

Link copied to clipboard
fun mapRectToDevice(pageIndex: Int, startX: Int, startY: Int, sizeX: Int, sizeY: Int, rect: RectF): RectF
Link copied to clipboard
fun openPage(pageIndex: Int): Boolean
Link copied to clipboard
fun pageHasError(pageIndex: Int): Boolean
Link copied to clipboard
fun recalculatePageSizes(viewSize: Size)

Recalculates the page sizes, offsets, and document length based on the current view size.

Link copied to clipboard
fun renderPageBitmap(bitmap: Bitmap, pageIndex: Int, bounds: Rect, annotationRendering: Boolean)