123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- package epson.print.pdf;
- import android.content.Context;
- import android.graphics.Bitmap;
- import android.graphics.Matrix;
- import com.adobe.mps.MPS;
- import java.io.File;
- import java.nio.ByteBuffer;
- import epson.common.ExternalFileUtils;
- import epson.image.epsonImage;
- import epson.print.Util.EPLog;
- public class AdobePdfContainer {
- private static final String TAG = "AdobePdfContainer";
- private MPS adpbeMPSInterface = new MPS();
- /* renamed from: bm */
- private Bitmap f385bm = null;
- int colorComponent = 4;
- private final int colorspace_ARGB = 1;
- private Context mContext = null;
- private int pageCount = 0;
- ByteBuffer rawBuffer;
- public class PdfException extends Exception {
- public PdfException() {
- }
- }
- public class PasswordException extends PdfException {
- public PasswordException() {
- super();
- }
- }
- public class NoPdfException extends PdfException {
- public NoPdfException() {
- super();
- }
- }
- public class ParameterException extends PdfException {
- public ParameterException() {
- super();
- }
- }
- public AdobePdfContainer(Context context) {
- mContext = context;
- EPLog.v(TAG, "adpbeMPSInterface.MPSInit()");
- adpbeMPSInterface.MPSInit("com/adobe/mps/ARAESCryptor", "com/adobe/mps/ARSHADigest");
- }
- protected void finalize() {
- EPLog.v(TAG, "finalize()");
- }
- public void LoadDocument(String str, String str2) throws PasswordException, NoPdfException {
- EPLog.v(TAG, "call LoadDocument()");
- if (str2 == null || str2.length() == 0) {
- pageCount = adpbeMPSInterface.PDFDocInit(str);
- } else {
- pageCount = adpbeMPSInterface.PDFDocInit(str, str2);
- }
- switch (pageCount) {
- case -2:
- throw new PasswordException();
- case -1:
- throw new PasswordException();
- case 0:
- throw new NoPdfException();
- default:
- return;
- }
- }
- public int CountPages() {
- return pageCount;
- }
- public int hasPrintPermission() {
- return adpbeMPSInterface.PDFHasPrintPermission((String) null);
- }
- public int GetPageSizeX(int i) throws ParameterException {
- if (CountPages() >= i) {
- return adpbeMPSInterface.PDFGetPageAttributes(i)[0];
- }
- throw new ParameterException();
- }
- public int GetPageSizeY(int i) throws ParameterException {
- if (CountPages() >= i) {
- return adpbeMPSInterface.PDFGetPageAttributes(i)[1];
- }
- throw new ParameterException();
- }
- public Bitmap getPageBitmap(int i, int i2, int i3, int i4) throws Exception {
- EPLog.v(TAG, "getPageBitmap() Start");
- if (CountPages() >= i) {
- Bitmap bitmap = f385bm;
- if (bitmap != null) {
- bitmap.recycle();
- f385bm = null;
- }
- System.gc();
- f385bm = Bitmap.createBitmap(i2, i3, Bitmap.Config.ARGB_8888);
- rawBuffer = ByteBuffer.allocateDirect(i2 * i3 * colorComponent);
- int[] iArr = {0, 0, 0, 0};
- ByteBuffer byteBuffer = rawBuffer;
- if (byteBuffer != null) {
- if (adpbeMPSInterface.PDFPageRender(i, i2, i3, 1, byteBuffer, 0, iArr) == 0) {
- f385bm.copyPixelsFromBuffer(rawBuffer);
- if (i4 != 0) {
- Matrix matrix = new Matrix();
- matrix.postRotate((float) i4);
- f385bm = Bitmap.createBitmap(f385bm, 0, 0, i2, i3, matrix, false);
- }
- }
- rawBuffer.clear();
- rawBuffer = null;
- } else {
- EPLog.e(TAG, "Failed ByteBuffer.allocateDirect()");
- }
- EPLog.v(TAG, "getPageBitmap() End");
- return f385bm;
- }
- throw new ParameterException();
- }
- public String getPageBitmapFile(int i, int i2, int i3, boolean z) throws Exception {
- String str;
- EPLog.v(TAG, "getPageBitmapFile() Start");
- if (CountPages() >= i) {
- String path = new File(ExternalFileUtils.getInstance(mContext).getPrintDir(), "tmpPDF.jpg").getPath();
- if (adpbeMPSInterface.PDFPagetoImage(i, path, i2, i3, 0) != 0) {
- return null;
- }
- if (z) {
- str = new File(ExternalFileUtils.getInstance(mContext).getPrintDir(), "tmpPDF90.jpg").getPath();
- new epsonImage().epsmpRotateImage2(path, str);
- } else {
- str = path;
- }
- EPLog.v(TAG, "getPageBitmapFile() End");
- return str;
- }
- throw new ParameterException();
- }
- public boolean decodeToJpegFile(String str, int i, int i2, int i3) throws ParameterException {
- if (CountPages() >= i) {
- return adpbeMPSInterface.PDFPagetoImage(i, str, i2, i3, 0) == 0;
- }
- throw new ParameterException();
- }
- }
|