use of org.ebookdroid.droids.mupdf.codec.MuPdfDocument in project LibreraReader by foobnix.
the class HtmlContext method openDocumentInner.
@Override
public CodecDocument openDocumentInner(String fileName, String password) {
Map<String, String> notes = null;
try {
FooterNote extract = HtmlExtractor.extract(fileName, CacheZipUtils.CACHE_BOOK_DIR.getPath());
fileName = extract.path;
notes = extract.notes;
LOG.d("new file name", fileName);
} catch (Exception e) {
LOG.e(e);
}
MuPdfDocument muPdfDocument = new MuPdfDocument(this, MuPdfDocument.FORMAT_PDF, fileName, password);
muPdfDocument.setFootNotes(notes);
return muPdfDocument;
}
use of org.ebookdroid.droids.mupdf.codec.MuPdfDocument in project LibreraReader by foobnix.
the class CbrContext method openDocumentInner.
@Override
public CodecDocument openDocumentInner(String fileName, String password) {
if (!cacheFile.isFile()) {
LOG.d("Type no cache file");
try {
if (CbzCbrExtractor.isZip(fileName)) {
CacheZipUtils.copyFile(new File(fileName), cacheFile);
} else {
String extractDir = CacheZipUtils.CACHE_BOOK_DIR + "/" + "CBR_" + fileName.hashCode();
File cbrDir = new File(extractDir);
cbrDir.mkdirs();
try {
ExtractArchive.extractArchive(fileName, extractDir, password);
} catch (OutOfMemoryError e) {
LOG.e(e);
}
CacheZipUtils.zipFolder(extractDir, cacheFile.getPath());
CacheZipUtils.deleteDir(cbrDir);
}
} catch (Exception e) {
LOG.e(e);
}
}
MuPdfDocument muPdfDocument = new MuPdfDocument(this, MuPdfDocument.FORMAT_PDF, cacheFile.getPath(), password);
return muPdfDocument;
}
use of org.ebookdroid.droids.mupdf.codec.MuPdfDocument in project LibreraReader by foobnix.
the class Fb2Context method openDocumentInner2.
public CodecDocument openDocumentInner2(final String fileName1, String password) {
final String fileName = cacheFile1.getPath();
Fb2Extractor.get().convertFB2(fileName1, fileName);
MuPdfDocument muPdfDocument2 = new MuPdfDocument(this, MuPdfDocument.FORMAT_PDF, fileName, password) {
@Override
public java.util.List<OutlineLink> getOutline() {
List<OutlineLink> res = new ArrayList<OutlineLink>();
try {
String encoding = Fb2Extractor.findHeaderEncoding(fileName1);
List<String> titles = Fb2Extractor.getFb2Titles(fileName1, encoding);
for (int i = 0; i < titles.size(); i++) {
String string = titles.get(i).replace("~@~[title]", "###");
String[] full = string.split("###");
int level = Integer.parseInt(full[0]);
String title = full[1];
String linkUri = "#" + (i + 1);
res.add(new OutlineLink(title + linkUri, "", level, getDocumentHandle(), linkUri));
}
} catch (Exception e) {
LOG.e(e);
}
return res;
}
};
return muPdfDocument2;
}
use of org.ebookdroid.droids.mupdf.codec.MuPdfDocument in project LibreraReader by foobnix.
the class MobiContext method openDocumentInner.
@Override
public CodecDocument openDocumentInner(String fileName, String password) {
LOG.d("Context", "MobiContext", fileName);
if (cacheFile.isFile()) {
fileNameEpub = cacheFile.getPath();
LOG.d("Context", "MobiContext cache", fileNameEpub);
} else {
try {
int outName = BookCSS.get().isAutoHypens ? "temp".hashCode() : originalHashCode;
FooterNote extract = MobiExtract.extract(fileName, CacheZipUtils.CACHE_BOOK_DIR.getPath(), outName + "");
fileNameEpub = extract.path;
if (BookCSS.get().isAutoHypens) {
EpubExtractor.proccessHypens(fileNameEpub, cacheFile.getPath());
fileNameEpub = cacheFile.getPath();
}
LOG.d("Context", "MobiContext extract", fileNameEpub);
} catch (Exception e) {
LOG.e(e);
}
}
final MuPdfDocument muPdfDocument = new MuPdfDocument(this, MuPdfDocument.FORMAT_PDF, fileNameEpub, password);
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 = null;
try {
notes = EpubExtractor.get().getFooterNotes(fileNameEpub);
LOG.d("new file name", fileNameEpub);
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 TxtContext method openDocumentInner.
@Override
public CodecDocument openDocumentInner(String fileName, String password) {
Map<String, String> notes = null;
try {
FooterNote extract = TxtExtract.extract(fileName, CacheZipUtils.CACHE_BOOK_DIR.getPath());
fileName = extract.path;
notes = extract.notes;
LOG.d("new file name", fileName);
} catch (Exception e) {
LOG.e(e);
}
MuPdfDocument muPdfDocument = new MuPdfDocument(this, MuPdfDocument.FORMAT_PDF, fileName, password);
muPdfDocument.setFootNotes(notes);
return muPdfDocument;
}
Aggregations