Page
class Page : AutoCloseable
kotlin.Any | |
↳ | android.graphics.pdf.PdfRenderer.Page |
This class represents a PDF document page for rendering.
Summary
Constants | |
---|---|
static Int |
Mode to render the content for display on a screen. |
static Int |
Mode to render the content for printing. |
Public methods | |
---|---|
Unit |
close() Closes this page. |
Int |
Gets the page height in points (1/72"). |
Int |
getIndex() Gets the page index. |
Int |
getWidth() Gets the page width in points (1/72"). |
Unit |
Renders a page to a bitmap. |
Protected methods | |
---|---|
Unit |
finalize() |
Constants
RENDER_MODE_FOR_DISPLAY
static val RENDER_MODE_FOR_DISPLAY: Int
Mode to render the content for display on a screen.
Value: 1
RENDER_MODE_FOR_PRINT
static val RENDER_MODE_FOR_PRINT: Int
Mode to render the content for printing.
Value: 2
Public methods
close
fun close(): Unit
Closes this page.
Exceptions | |
---|---|
java.lang.Exception |
if this resource cannot be closed |
getHeight
fun getHeight(): Int
Gets the page height in points (1/72").
Return | |
---|---|
Int |
The height in points. |
getWidth
fun getWidth(): Int
Gets the page width in points (1/72").
Return | |
---|---|
Int |
The width in points. |
render
fun render(
destination: Bitmap,
destClip: Rect?,
transform: Matrix?,
renderMode: Int
): Unit
Renders a page to a bitmap.
You may optionally specify a rectangular clip in the bitmap bounds. No rendering outside the clip will be performed, hence it is your responsibility to initialize the bitmap outside the clip.
You may optionally specify a matrix to transform the content from page coordinates which are in points (1/72") to bitmap coordinates which are in pixels. If this matrix is not provided this method will apply a transformation that will fit the whole page to the destination clip if provided or the destination bitmap if no clip is provided.
The clip and transformation are useful for implementing tile rendering where the destination bitmap contains a portion of the image, for example when zooming. Another useful application is for printing where the size of the bitmap holding the page is too large and a client can render the page in stripes.
Note: The destination bitmap format must be ARGB
.
Note: The optional transformation matrix must be affine as per Matrix.isAffine()
. Hence, you can specify rotation, scaling, translation but not a perspective transformation.
Parameters | |
---|---|
destination |
Bitmap: Destination bitmap to which to render. This value cannot be null . |
destClip |
Rect?: Optional clip in the bitmap bounds. This value may be null . |
transform |
Matrix?: Optional transformation to apply when rendering. This value may be null . |
renderMode |
Int: The render mode. Value is android.graphics.pdf.PdfRenderer.Page#RENDER_MODE_FOR_DISPLAY , or android.graphics.pdf.PdfRenderer.Page#RENDER_MODE_FOR_PRINT |
Protected methods
finalize
protected fun finalize(): Unit
Exceptions | |
---|---|
java.lang.Throwable |
the Exception raised by this method |