-
public class PdfiumCore
-
-
Constructor Summary
Constructors Constructor Description PdfiumCore(Context ctx)Context needed to get screen density
-
Method Summary
Modifier and Type Method Description static intgetNumFd(ParcelFileDescriptor fdObj)PdfDocumentnewDocument(ParcelFileDescriptor fd)Create new document from file PdfDocumentnewDocument(ParcelFileDescriptor fd, String password)Create new document from file with password PdfDocumentnewDocument(Array<byte> data)Create new document from bytearray PdfDocumentnewDocument(Array<byte> data, String password)Create new document from bytearray with password intgetPageCount(PdfDocument doc)Get total numer of pages in document longopenPage(PdfDocument doc, int pageIndex)Open page and store native pointer in PdfDocument Array<long>openPage(PdfDocument doc, int fromIndex, int toIndex)Open range of pages and store native pointers in PdfDocument intgetPageWidth(PdfDocument doc, int index)Get page width in pixels. intgetPageHeight(PdfDocument doc, int index)Get page height in pixels. intgetPageWidthPoint(PdfDocument doc, int index)Get page width in PostScript points (1/72th of an inch). intgetPageHeightPoint(PdfDocument doc, int index)Get page height in PostScript points (1/72th of an inch). SizegetPageSize(PdfDocument doc, int index)Get size of page in pixels. voidrenderPage(PdfDocument doc, Surface surface, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY)Render page fragment on Surface. voidrenderPage(PdfDocument doc, Surface surface, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY, boolean renderAnnot)Render page fragment on Surface. voidrenderPageBitmap(PdfDocument doc, Bitmap bitmap, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY)Render page fragment on Bitmap. voidrenderPageBitmap(PdfDocument doc, Bitmap bitmap, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY, boolean renderAnnot)Render page fragment on Bitmap. voidcloseDocument(PdfDocument doc)Release native resources and opened file PdfDocument.MetagetDocumentMeta(PdfDocument doc)Get metadata for given document List<PdfDocument.Bookmark>getTableOfContents(PdfDocument doc)Get table of contents (bookmarks) for given document List<PdfDocument.Link>getPageLinks(PdfDocument doc, int pageIndex)Get all links from given page PointmapPageCoordsToDevice(PdfDocument doc, int pageIndex, int startX, int startY, int sizeX, int sizeY, int rotate, double pageX, double pageY)Map page coordinates to device screen coordinates RectFmapRectToDevice(PdfDocument doc, int pageIndex, int startX, int startY, int sizeX, int sizeY, int rotate, RectF coords)PointFmapDeviceCoordsToPage(PdfDocument doc, int pageIndex, int startX, int startY, int sizeX, int sizeY, int rotate, int deviceX, int deviceY)Add commentMore actionsConvert the screen coordinates of a point to page coordinates.The page coordinate system has its origin at the left-bottom cornerof the page, with the X-axis on the bottom going to the right, andthe Y-axis on the left side going up.NOTE: this coordinate system can be altered when you zoom, scroll,or rotate a page, however, a point on the page should always havethe same coordinate values in the page coordinate system.The device coordinate system is device dependent. -
-
Constructor Detail
-
PdfiumCore
PdfiumCore(Context ctx)
Context needed to get screen density
-
-
Method Detail
-
getNumFd
static int getNumFd(ParcelFileDescriptor fdObj)
-
newDocument
PdfDocument newDocument(ParcelFileDescriptor fd)
Create new document from file
-
newDocument
PdfDocument newDocument(ParcelFileDescriptor fd, String password)
Create new document from file with password
-
newDocument
PdfDocument newDocument(Array<byte> data)
Create new document from bytearray
-
newDocument
PdfDocument newDocument(Array<byte> data, String password)
Create new document from bytearray with password
-
getPageCount
int getPageCount(PdfDocument doc)
Get total numer of pages in document
-
openPage
long openPage(PdfDocument doc, int pageIndex)
Open page and store native pointer in PdfDocument
-
openPage
Array<long> openPage(PdfDocument doc, int fromIndex, int toIndex)
Open range of pages and store native pointers in PdfDocument
-
getPageWidth
int getPageWidth(PdfDocument doc, int index)
Get page width in pixels. This method requires page to be opened.
-
getPageHeight
int getPageHeight(PdfDocument doc, int index)
Get page height in pixels. This method requires page to be opened.
-
getPageWidthPoint
int getPageWidthPoint(PdfDocument doc, int index)
Get page width in PostScript points (1/72th of an inch).This method requires page to be opened.
-
getPageHeightPoint
int getPageHeightPoint(PdfDocument doc, int index)
Get page height in PostScript points (1/72th of an inch).This method requires page to be opened.
-
getPageSize
Size getPageSize(PdfDocument doc, int index)
Get size of page in pixels.This method does not require given page to be opened.
-
renderPage
void renderPage(PdfDocument doc, Surface surface, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY)
Render page fragment on Surface.Page must be opened before rendering.
-
renderPage
void renderPage(PdfDocument doc, Surface surface, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY, boolean renderAnnot)
Render page fragment on Surface. This method allows to render annotations.Page must be opened before rendering.
-
renderPageBitmap
void renderPageBitmap(PdfDocument doc, Bitmap bitmap, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY)
Render page fragment on Bitmap.Page must be opened before rendering.
Supported bitmap configurations:
- ARGB_8888 - best quality, high memory usage, higher possibility of OutOfMemoryError
- RGB_565 - little worse quality, twice less memory usage
-
renderPageBitmap
void renderPageBitmap(PdfDocument doc, Bitmap bitmap, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY, boolean renderAnnot)
Render page fragment on Bitmap. This method allows to render annotations.Page must be opened before rendering.
For more info see renderPageBitmap
-
closeDocument
void closeDocument(PdfDocument doc)
Release native resources and opened file
-
getDocumentMeta
PdfDocument.Meta getDocumentMeta(PdfDocument doc)
Get metadata for given document
-
getTableOfContents
List<PdfDocument.Bookmark> getTableOfContents(PdfDocument doc)
Get table of contents (bookmarks) for given document
-
getPageLinks
List<PdfDocument.Link> getPageLinks(PdfDocument doc, int pageIndex)
Get all links from given page
-
mapPageCoordsToDevice
Point mapPageCoordsToDevice(PdfDocument doc, int pageIndex, int startX, int startY, int sizeX, int sizeY, int rotate, double pageX, double pageY)
Map page coordinates to device screen coordinates
- Parameters:
doc- pdf documentpageIndex- index of pagestartX- left pixel position of the display area in device coordinatesstartY- top pixel position of the display area in device coordinatessizeX- horizontal size (in pixels) for displaying the pagesizeY- vertical size (in pixels) for displaying the pagerotate- page orientation: 0 (normal), 1 (rotated 90 degrees clockwise),2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise)pageX- X value in page coordinatespageY- Y value in page coordinate
-
mapRectToDevice
RectF mapRectToDevice(PdfDocument doc, int pageIndex, int startX, int startY, int sizeX, int sizeY, int rotate, RectF coords)
-
mapDeviceCoordsToPage
PointF mapDeviceCoordsToPage(PdfDocument doc, int pageIndex, int startX, int startY, int sizeX, int sizeY, int rotate, int deviceX, int deviceY)
Add commentMore actionsConvert the screen coordinates of a point to page coordinates.The page coordinate system has its origin at the left-bottom cornerof the page, with the X-axis on the bottom going to the right, andthe Y-axis on the left side going up.NOTE: this coordinate system can be altered when you zoom, scroll,or rotate a page, however, a point on the page should always havethe same coordinate values in the page coordinate system.The device coordinate system is device dependent. For screen device,its origin is at the left-top corner of the window. However thisorigin can be altered by the Windows coordinate transformationutilities.You must make sure the start_x, start_y, size_x, size_yand rotate parameters have exactly same values as you used inthe FPDF_RenderPage() function call.
- Parameters:
doc- pdf documentpageIndex- index of pagestartX- Left pixel position of the display area in device coordinates.startY- Top pixel position of the display area in device coordinates.sizeX- Horizontal size (in pixels) for displaying the page.sizeY- Vertical size (in pixels) for displaying the page.rotate- Page orientation:0 (normal)1 (rotated 90 degrees clockwise)2 (rotated 180 degrees)3 (rotated 90 degrees counter-clockwise)deviceX- X value in device coordinates to be converted.deviceY- Y value in device coordinates to be converted.
-
-
-
-