Back to project page PDF2ImageForEP.
The source code is released under:
GNU General Public License
If you think the Android project PDF2ImageForEP listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* ???????????????????? * ???????static { System.loadLibrary("????????"); }????????com.artifex.mupdf.MuPDFCore.java???????????? * ??????????????????????????????????????????ClassLoader??????????????????????????????????????????????????????????? * ClassLoader????????????????????????????????????????????????????????????????????????????? * ???????????????????????????????????????????????????????Manifest???android:sharedUserId?????????????????????????????????? *///from ww w.j av a 2 s . com package jp.co.muratec.pdf2image; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Calendar; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import android.os.Build; public class LoadLibrary { // ?????????? private static LoadLibrary instance = new LoadLibrary(); private LoadLibrary() {} // ?????????????? public static LoadLibrary getInstance() { return instance; } /* * ??????????????? */ private boolean initFlag = false; private String sourceDir = null; private String outDir = null; // ??????????????????????? public void setAppPath(String _sourceDir,String _outDir) { sourceDir = _sourceDir; outDir = _outDir; } public void init(){ init(sourceDir,outDir); } /** * ?????????????ClassLoader?????????????????? * @param appPath <br>????????.apk?????<br>?Context.getPackageManager().getApplicationInfo("???????????????", 0).sourceDir<br>??????????????????????? * @param outPath <br>?.so???????????<br>???????????????????????????????????????????????????????????? */ public void init(String appPath,String outPath){ if(initFlag == false){ // ?????????????????????????????????????? String soName = "libmupdf.so"; if(Build.CPU_ABI.equals("armeabi-v7a")){ soName = "libmupdf_neon.so"; } Calendar calendar = Calendar.getInstance(); int now = calendar.get(Calendar.MILLISECOND); // ???????????????????System.load??????????already loaded????????????????????????????????????????????????? File outDir = new File(outPath); File[] list = outDir.listFiles(); for(File file : list){ if(file.getName().endsWith(soName)){ // ????so????????????????? file.renameTo(new File(outPath,Integer.toString(now)+soName)); System.load(outPath+"/"+Integer.toString(now)+soName); initFlag = true; return; } } // ????????so?????????????????? String copyFile = outPath+"/"+Integer.toString(now)+soName; ZipExtractFile(appPath,"assets/"+soName,copyFile); // appPath???????.so???????outPath?????? System.load(copyFile); // ????????????????????? initFlag = true; } } //extract file from apk file public static boolean ZipExtractFile(String ZipFile,String SrcFile,String DstFile) { ZipFile zip; try { File DstFileObj=new File(DstFile); zip = new ZipFile(ZipFile); ZipEntry zipen = zip.getEntry(SrcFile); if ((!DstFileObj.exists()) || (zipen.getSize()!=DstFileObj.length())) { InputStream is = zip.getInputStream(zipen); OutputStream os = new FileOutputStream(DstFile); byte[] buf = new byte[8092]; int n; while ((n = is.read(buf)) > 0) { os.write(buf, 0, n); } os.close(); is.close(); } } catch (IOException e) { e.printStackTrace(); return false; } return true; } }