android - mupdf: how to open pdf file with openBuffer method? -


unfortunatelly, haven't found documentation on point, maybe wrong.

i use mupdf sample android , have modified source code of mupdfactivity way:

public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);          malertbuilder = new alertdialog.builder(this);          if (core == null) {             core = (mupdfcore)getlastnonconfigurationinstance();              if (savedinstancestate != null && savedinstancestate.containskey("filename")) {                 mfilename = savedinstancestate.getstring("filename");             }         }         if (core == null) {             intent intent = getintent();             byte buffer[] = null;             if (intent.action_view.equals(intent.getaction())) {                 uri uri = intent.getdata();                 try {                     inputstream inputstream = new fileinputstream(new file(uri.tostring()));                     int len = inputstream.available();                     buffer = new byte[len];                     inputstream.read(buffer, 0, len);                     inputstream.close();                 } catch (exception e) {                     log.e(tag, e.getmessage());                 }                 if (buffer != null) {                     core = openbuffer(buffer);                 } else {                     core = openfile(uri.decode(uri.getencodedpath()));                 }                 searchtaskresult.set(null);             } 

the activity's openbuffer() method hasn't been changed:

private mupdfcore openbuffer(byte buffer[]) {         system.out.println("trying open byte buffer");         try {             core = new mupdfcore(this, buffer);             // new file: drop old outline data             outlineactivitydata.set(null);         } catch (exception e) {             system.out.println(e);             return null;         }         return core; } 

after try open pdf, app shows alert message "cannot open document". logs:

03-21 10:43:14.754    3601-3601/com.artifex.mupdfdemo.debug e/libmupdf﹕ opening document... 03-21 10:43:14.754    3601-3601/com.artifex.mupdfdemo.debug e/libmupdf﹕ error: no document handlers registered 03-21 10:43:14.754    3601-3601/com.artifex.mupdfdemo.debug e/libmupdf﹕ error: cannot open memory document 03-21 10:43:14.754    3601-3601/com.artifex.mupdfdemo.debug e/libmupdf﹕ failed: cannot open memory document 

so, whether there way open pdf file byte array , way?

my guess using version of android jni file mupdf.c older version of main library files. there change in library api necessitates fz_register_document_handlers(ctx) being called between creating context , calling fz_open_document. first error message seeing suggests fz_register_document_handlers not being called


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -