use of org.ebookdroid.droids.mupdf.codec.MuPdfDocument in project LibreraReader by foobnix.
the class EpubContext method openDocumentInner.
@Override
public CodecDocument openDocumentInner(final String fileName, String password) {
LOG.d(TAG, fileName);
if (BookCSS.get().isAutoHypens && !cacheFile.isFile()) {
EpubExtractor.proccessHypens(fileName, cacheFile.getPath());
}
if (TempHolder.get().loadingCancelled) {
removeTempFiles();
return null;
}
String bookPath = BookCSS.get().isAutoHypens ? cacheFile.getPath() : fileName;
final MuPdfDocument muPdfDocument = new MuPdfDocument(this, MuPdfDocument.FORMAT_PDF, bookPath, password);
final File jsonFile = new File(cacheFile + ".json");
if (jsonFile.isFile()) {
muPdfDocument.setFootNotes(JsonHelper.fileToMap(jsonFile));
LOG.d("Load notes from file", jsonFile);
}
new Thread() {
@Override
public void run() {
Map<String, String> notes = null;
try {
muPdfDocument.setMediaAttachment(EpubExtractor.getAttachments(fileName));
if (!jsonFile.isFile()) {
notes = EpubExtractor.get().getFooterNotes(fileName);
muPdfDocument.setFootNotes(notes);
JsonHelper.mapToFile(jsonFile, notes);
LOG.d("save notes to file", jsonFile);
}
removeTempFiles();
} catch (Exception e) {
LOG.e(e);
}
}
}.start();
return muPdfDocument;
}
use of org.ebookdroid.droids.mupdf.codec.MuPdfDocument in project LibreraReader by foobnix.
the class Fb2Context method openDocumentInner.
@Override
public CodecDocument openDocumentInner(final String fileName, String password) {
String outName = null;
if (cacheFile.isFile()) {
outName = cacheFile.getPath();
} else if (cacheFile1.isFile()) {
outName = cacheFile1.getPath();
}
if (outName == null) {
outName = cacheFile.getPath();
Fb2Extractor.get().convert(fileName, outName);
LOG.d("Fb2Context create", fileName, "to", outName);
}
LOG.d("Fb2Context open", outName);
try {
muPdfDocument = new MuPdfDocument(this, MuPdfDocument.FORMAT_PDF, outName, password);
} catch (Exception e) {
LOG.e(e);
if (cacheFile.isFile()) {
cacheFile.delete();
}
outName = cacheFile1.getPath();
Fb2Extractor.get().convertFB2(fileName, outName);
muPdfDocument = new MuPdfDocument(this, MuPdfDocument.FORMAT_PDF, outName, password);
LOG.d("Fb2Context create", outName);
}
final File jsonFile = new File(cacheFile + ".json");
if (jsonFile.isFile()) {
muPdfDocument.setFootNotes(JsonHelper.fileToMap(jsonFile));
LOG.d("Load notes from file", jsonFile);
} else {
new Thread() {
@Override
public void run() {
Map<String, String> notes = Fb2Extractor.get().getFooterNotes(fileName);
muPdfDocument.setFootNotes(notes);
JsonHelper.mapToFile(jsonFile, notes);
LOG.d("save notes to file", jsonFile);
removeTempFiles();
}
}.start();
}
return muPdfDocument;
}
Aggregations