AdobePdfContainer.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. package epson.print.pdf;
  2. import android.content.Context;
  3. import android.graphics.Bitmap;
  4. import android.graphics.Matrix;
  5. import com.adobe.mps.MPS;
  6. import epson.common.ExternalFileUtils;
  7. import epson.image.epsonImage;
  8. import epson.print.Util.EPLog;
  9. import java.io.File;
  10. import java.nio.ByteBuffer;
  11. public class AdobePdfContainer {
  12. private static final String TAG = "AdobePdfContainer";
  13. private MPS adpbeMPSInterface = new MPS();
  14. /* renamed from: bm */
  15. private Bitmap f385bm = null;
  16. int colorComponent = 4;
  17. private final int colorspace_ARGB = 1;
  18. private Context mContext = null;
  19. private int pageCount = 0;
  20. ByteBuffer rawBuffer;
  21. public class PdfException extends Exception {
  22. public PdfException() {
  23. }
  24. }
  25. public class PasswordException extends PdfException {
  26. public PasswordException() {
  27. super();
  28. }
  29. }
  30. public class NoPdfException extends PdfException {
  31. public NoPdfException() {
  32. super();
  33. }
  34. }
  35. public class ParameterException extends PdfException {
  36. public ParameterException() {
  37. super();
  38. }
  39. }
  40. public AdobePdfContainer(Context context) {
  41. this.mContext = context;
  42. EPLog.v(TAG, "adpbeMPSInterface.MPSInit()");
  43. this.adpbeMPSInterface.MPSInit("com/adobe/mps/ARAESCryptor", "com/adobe/mps/ARSHADigest");
  44. }
  45. /* access modifiers changed from: protected */
  46. public void finalize() {
  47. EPLog.v(TAG, "finalize()");
  48. }
  49. public void LoadDocument(String str, String str2) throws PasswordException, NoPdfException {
  50. EPLog.v(TAG, "call LoadDocument()");
  51. if (str2 == null || str2.length() == 0) {
  52. this.pageCount = this.adpbeMPSInterface.PDFDocInit(str);
  53. } else {
  54. this.pageCount = this.adpbeMPSInterface.PDFDocInit(str, str2);
  55. }
  56. switch (this.pageCount) {
  57. case -2:
  58. throw new PasswordException();
  59. case -1:
  60. throw new PasswordException();
  61. case 0:
  62. throw new NoPdfException();
  63. default:
  64. return;
  65. }
  66. }
  67. public int CountPages() {
  68. return this.pageCount;
  69. }
  70. public int hasPrintPermission() {
  71. return this.adpbeMPSInterface.PDFHasPrintPermission((String) null);
  72. }
  73. public int GetPageSizeX(int i) throws ParameterException {
  74. if (CountPages() >= i) {
  75. return this.adpbeMPSInterface.PDFGetPageAttributes(i)[0];
  76. }
  77. throw new ParameterException();
  78. }
  79. public int GetPageSizeY(int i) throws ParameterException {
  80. if (CountPages() >= i) {
  81. return this.adpbeMPSInterface.PDFGetPageAttributes(i)[1];
  82. }
  83. throw new ParameterException();
  84. }
  85. public Bitmap getPageBitmap(int i, int i2, int i3, int i4) throws Exception {
  86. EPLog.v(TAG, "getPageBitmap() Start");
  87. if (CountPages() >= i) {
  88. Bitmap bitmap = this.f385bm;
  89. if (bitmap != null) {
  90. bitmap.recycle();
  91. this.f385bm = null;
  92. }
  93. System.gc();
  94. this.f385bm = Bitmap.createBitmap(i2, i3, Bitmap.Config.ARGB_8888);
  95. this.rawBuffer = ByteBuffer.allocateDirect(i2 * i3 * this.colorComponent);
  96. int[] iArr = {0, 0, 0, 0};
  97. ByteBuffer byteBuffer = this.rawBuffer;
  98. if (byteBuffer != null) {
  99. if (this.adpbeMPSInterface.PDFPageRender(i, i2, i3, 1, byteBuffer, 0, iArr) == 0) {
  100. this.f385bm.copyPixelsFromBuffer(this.rawBuffer);
  101. if (i4 != 0) {
  102. Matrix matrix = new Matrix();
  103. matrix.postRotate((float) i4);
  104. this.f385bm = Bitmap.createBitmap(this.f385bm, 0, 0, i2, i3, matrix, false);
  105. }
  106. }
  107. this.rawBuffer.clear();
  108. this.rawBuffer = null;
  109. } else {
  110. EPLog.m307e(TAG, "Failed ByteBuffer.allocateDirect()");
  111. }
  112. EPLog.v(TAG, "getPageBitmap() End");
  113. return this.f385bm;
  114. }
  115. throw new ParameterException();
  116. }
  117. public String getPageBitmapFile(int i, int i2, int i3, boolean z) throws Exception {
  118. String str;
  119. EPLog.v(TAG, "getPageBitmapFile() Start");
  120. if (CountPages() >= i) {
  121. String path = new File(ExternalFileUtils.getInstance(this.mContext).getPrintDir(), "tmpPDF.jpg").getPath();
  122. if (this.adpbeMPSInterface.PDFPagetoImage(i, path, i2, i3, 0) != 0) {
  123. return null;
  124. }
  125. if (z) {
  126. str = new File(ExternalFileUtils.getInstance(this.mContext).getPrintDir(), "tmpPDF90.jpg").getPath();
  127. new epsonImage().epsmpRotateImage2(path, str);
  128. } else {
  129. str = path;
  130. }
  131. EPLog.v(TAG, "getPageBitmapFile() End");
  132. return str;
  133. }
  134. throw new ParameterException();
  135. }
  136. public boolean decodeToJpegFile(String str, int i, int i2, int i3) throws ParameterException {
  137. if (CountPages() >= i) {
  138. return this.adpbeMPSInterface.PDFPagetoImage(i, str, i2, i3, 0) == 0;
  139. }
  140. throw new ParameterException();
  141. }
  142. }