Methods Summary |
---|
public void | close()Closes this editor. You should not use this instance
after this method is called.
throwIfClosed();
doClose();
|
private void | doClose()
nativeClose(mNativeDocument);
IoUtils.closeQuietly(mInput);
mInput = null;
mCloseGuard.close();
|
protected void | finalize()
try {
mCloseGuard.warnIfOpen();
if (mInput != null) {
doClose();
}
} finally {
super.finalize();
}
|
public int | getPageCount()Gets the number of pages in the document.
throwIfClosed();
return mPageCount;
|
public boolean | getPageCropBox(int pageIndex, android.graphics.Rect outCropBox)Gets the crop box of a given page in mils (1/72").
throwIfClosed();
throwIfOutCropBoxNull(outCropBox);
throwIfPageNotInDocument(pageIndex);
return nativeGetPageCropBox(mNativeDocument, pageIndex, outCropBox);
|
public boolean | getPageMediaBox(int pageIndex, android.graphics.Rect outMediaBox)Gets the media box of a given page in mils (1/72").
throwIfClosed();
throwIfOutMediaBoxNull(outMediaBox);
throwIfPageNotInDocument(pageIndex);
return nativeGetPageMediaBox(mNativeDocument, pageIndex, outMediaBox);
|
public void | getPageSize(int pageIndex, android.graphics.Point outSize)Gets the size of a given page in mils (1/72").
throwIfClosed();
throwIfOutSizeNull(outSize);
throwIfPageNotInDocument(pageIndex);
nativeGetPageSize(mNativeDocument, pageIndex, outSize);
|
private static native void | nativeClose(long documentPtr)
|
private static native int | nativeGetPageCount(long documentPtr)
|
private static native boolean | nativeGetPageCropBox(long documentPtr, int pageIndex, android.graphics.Rect outMediaBox)
|
private static native boolean | nativeGetPageMediaBox(long documentPtr, int pageIndex, android.graphics.Rect outMediaBox)
|
private static native void | nativeGetPageSize(long documentPtr, int pageIndex, android.graphics.Point outSize)
|
private static native long | nativeOpen(int fd, long size)
|
private static native int | nativeRemovePage(long documentPtr, int pageIndex)
|
private static native boolean | nativeScaleForPrinting(long documentPtr)
|
private static native void | nativeSetPageCropBox(long documentPtr, int pageIndex, android.graphics.Rect mediaBox)
|
private static native void | nativeSetPageMediaBox(long documentPtr, int pageIndex, android.graphics.Rect mediaBox)
|
private static native void | nativeSetTransformAndClip(long documentPtr, int pageIndex, long transformPtr, int clipLeft, int clipTop, int clipRight, int clipBottom)
|
private static native void | nativeWrite(long documentPtr, int fd)
|
public void | removePage(int pageIndex)Removes the page with a given index.
throwIfClosed();
throwIfPageNotInDocument(pageIndex);
mPageCount = nativeRemovePage(mNativeDocument, pageIndex);
|
public void | setPageCropBox(int pageIndex, android.graphics.Rect cropBox)Sets the crop box of a given page in mils (1/72").
throwIfClosed();
throwIfCropBoxNull(cropBox);
throwIfPageNotInDocument(pageIndex);
nativeSetPageCropBox(mNativeDocument, pageIndex, cropBox);
|
public void | setPageMediaBox(int pageIndex, android.graphics.Rect mediaBox)Sets the media box of a given page in mils (1/72").
throwIfClosed();
throwIfMediaBoxNull(mediaBox);
throwIfPageNotInDocument(pageIndex);
nativeSetPageMediaBox(mNativeDocument, pageIndex, mediaBox);
|
public void | setTransformAndClip(int pageIndex, android.graphics.Matrix transform, android.graphics.Rect clip)Sets a transformation and clip for a given page. The transformation matrix if
non-null must be affine as per {@link android.graphics.Matrix#isAffine()}. If
the clip is null, then no clipping is performed.
throwIfClosed();
throwIfPageNotInDocument(pageIndex);
throwIfNotNullAndNotAfine(transform);
if (transform == null) {
transform = Matrix.IDENTITY_MATRIX;
}
if (clip == null) {
Point size = new Point();
getPageSize(pageIndex, size);
nativeSetTransformAndClip(mNativeDocument, pageIndex, transform.native_instance,
0, 0, size.x, size.y);
} else {
nativeSetTransformAndClip(mNativeDocument, pageIndex, transform.native_instance,
clip.left, clip.top, clip.right, clip.bottom);
}
|
public boolean | shouldScaleForPrinting()Gets whether the document prefers to be scaled for printing.
throwIfClosed();
return nativeScaleForPrinting(mNativeDocument);
|
private void | throwIfClosed()
if (mInput == null) {
throw new IllegalStateException("Already closed");
}
|
private void | throwIfCropBoxNull(android.graphics.Rect cropBox)
if (cropBox == null) {
throw new NullPointerException("cropBox cannot be null");
}
|
private void | throwIfMediaBoxNull(android.graphics.Rect mediaBox)
if (mediaBox == null) {
throw new NullPointerException("mediaBox cannot be null");
}
|
private void | throwIfNotNullAndNotAfine(android.graphics.Matrix matrix)
if (matrix != null && !matrix.isAffine()) {
throw new IllegalStateException("Matrix must be afine");
}
|
private void | throwIfOutCropBoxNull(android.graphics.Rect outCropBox)
if (outCropBox == null) {
throw new NullPointerException("outCropBox cannot be null");
}
|
private void | throwIfOutMediaBoxNull(android.graphics.Rect outMediaBox)
if (outMediaBox == null) {
throw new NullPointerException("outMediaBox cannot be null");
}
|
private void | throwIfOutSizeNull(android.graphics.Point outSize)
if (outSize == null) {
throw new NullPointerException("outSize cannot be null");
}
|
private void | throwIfPageNotInDocument(int pageIndex)
if (pageIndex < 0 || pageIndex >= mPageCount) {
throw new IllegalArgumentException("Invalid page index");
}
|
public void | write(android.os.ParcelFileDescriptor output)Writes the PDF file to the provided destination.
Note: This method takes ownership of the passed in file
descriptor and is responsible for closing it when writing completes.
try {
throwIfClosed();
nativeWrite(mNativeDocument, output.getFd());
} finally {
IoUtils.closeQuietly(output);
}
|