Package com.shockwave.pdfium
Class PdfiumCore
- java.lang.Object
-
- com.shockwave.pdfium.PdfiumCore
-
public class PdfiumCore extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description PdfiumCore(android.content.Context ctx)Context needed to get screen density
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseDocument(PdfDocument doc)Release native resources and opened filePdfDocument.MetagetDocumentMeta(PdfDocument doc)Get metadata for given documentstatic intgetNumFd(android.os.ParcelFileDescriptor fdObj)intgetPageCount(PdfDocument doc)Get total numer of pages in documentintgetPageHeight(PdfDocument doc, int index)Get page height in pixels.intgetPageHeightPoint(PdfDocument doc, int index)Get page height in PostScript points (1/72th of an inch).
This method requires page to be opened.java.util.List<PdfDocument.Link>getPageLinks(PdfDocument doc, int pageIndex)Get all links from given pageSizegetPageSize(PdfDocument doc, int index)Get size of page in pixels.
This method does not require given page to be opened.intgetPageWidth(PdfDocument doc, int index)Get page width in pixels.intgetPageWidthPoint(PdfDocument doc, int index)Get page width in PostScript points (1/72th of an inch).
This method requires page to be opened.java.util.List<PdfDocument.Bookmark>getTableOfContents(PdfDocument doc)Get table of contents (bookmarks) for given documentandroid.graphics.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 coordinatesandroid.graphics.RectFmapRectToDevice(PdfDocument doc, int pageIndex, int startX, int startY, int sizeX, int sizeY, int rotate, android.graphics.RectF coords)PdfDocumentnewDocument(byte[] data)Create new document from bytearrayPdfDocumentnewDocument(byte[] data, java.lang.String password)Create new document from bytearray with passwordPdfDocumentnewDocument(android.os.ParcelFileDescriptor fd)Create new document from filePdfDocumentnewDocument(android.os.ParcelFileDescriptor fd, java.lang.String password)Create new document from file with passwordlongopenPage(PdfDocument doc, int pageIndex)Open page and store native pointer inPdfDocumentlong[]openPage(PdfDocument doc, int fromIndex, int toIndex)Open range of pages and store native pointers inPdfDocumentvoidrenderPage(PdfDocument doc, android.view.Surface surface, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY)Render page fragment onSurface.
Page must be opened before rendering.voidrenderPage(PdfDocument doc, android.view.Surface surface, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY, boolean renderAnnot)Render page fragment onSurface.voidrenderPageBitmap(PdfDocument doc, android.graphics.Bitmap bitmap, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY)Render page fragment onBitmap.
Page must be opened before rendering.voidrenderPageBitmap(PdfDocument doc, android.graphics.Bitmap bitmap, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY, boolean renderAnnot)Render page fragment onBitmap.
-
-
-
Method Detail
-
getNumFd
public static int getNumFd(android.os.ParcelFileDescriptor fdObj)
-
newDocument
public PdfDocument newDocument(android.os.ParcelFileDescriptor fd) throws java.io.IOException
Create new document from file- Throws:
java.io.IOException
-
newDocument
public PdfDocument newDocument(android.os.ParcelFileDescriptor fd, java.lang.String password) throws java.io.IOException
Create new document from file with password- Throws:
java.io.IOException
-
newDocument
public PdfDocument newDocument(byte[] data) throws java.io.IOException
Create new document from bytearray- Throws:
java.io.IOException
-
newDocument
public PdfDocument newDocument(byte[] data, java.lang.String password) throws java.io.IOException
Create new document from bytearray with password- Throws:
java.io.IOException
-
getPageCount
public int getPageCount(PdfDocument doc)
Get total numer of pages in document
-
openPage
public long openPage(PdfDocument doc, int pageIndex)
Open page and store native pointer inPdfDocument
-
openPage
public long[] openPage(PdfDocument doc, int fromIndex, int toIndex)
Open range of pages and store native pointers inPdfDocument
-
getPageWidth
public int getPageWidth(PdfDocument doc, int index)
Get page width in pixels.
This method requires page to be opened.
-
getPageHeight
public int getPageHeight(PdfDocument doc, int index)
Get page height in pixels.
This method requires page to be opened.
-
getPageWidthPoint
public 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
public 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
public Size getPageSize(PdfDocument doc, int index)
Get size of page in pixels.
This method does not require given page to be opened.
-
renderPage
public void renderPage(PdfDocument doc, android.view.Surface surface, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY)
Render page fragment onSurface.
Page must be opened before rendering.
-
renderPage
public void renderPage(PdfDocument doc, android.view.Surface surface, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY, boolean renderAnnot)
Render page fragment onSurface. This method allows to render annotations.
Page must be opened before rendering.
-
renderPageBitmap
public void renderPageBitmap(PdfDocument doc, android.graphics.Bitmap bitmap, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY)
Render page fragment onBitmap.
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
public void renderPageBitmap(PdfDocument doc, android.graphics.Bitmap bitmap, int pageIndex, int startX, int startY, int drawSizeX, int drawSizeY, boolean renderAnnot)
Render page fragment onBitmap. This method allows to render annotations.
Page must be opened before rendering.For more info see
renderPageBitmap(PdfDocument, Bitmap, int, int, int, int, int)
-
closeDocument
public void closeDocument(PdfDocument doc)
Release native resources and opened file
-
getDocumentMeta
public PdfDocument.Meta getDocumentMeta(PdfDocument doc)
Get metadata for given document
-
getTableOfContents
public java.util.List<PdfDocument.Bookmark> getTableOfContents(PdfDocument doc)
Get table of contents (bookmarks) for given document
-
getPageLinks
public java.util.List<PdfDocument.Link> getPageLinks(PdfDocument doc, int pageIndex)
Get all links from given page
-
mapPageCoordsToDevice
public android.graphics.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- Returns:
- mapped coordinates
-
mapRectToDevice
public android.graphics.RectF mapRectToDevice(PdfDocument doc, int pageIndex, int startX, int startY, int sizeX, int sizeY, int rotate, android.graphics.RectF coords)
- Returns:
- mapped coordinates
- See Also:
mapPageCoordsToDevice(PdfDocument, int, int, int, int, int, int, double, double)
-
-