本文介绍了如何将任何格式的文件(.txt,.doc)格式文件输出到在Android应用程序的epub文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发中,我要读或写的任何电子书的应用程序。
I am developing an application in which I have to read or write any eBook.
在可读取任何Android的电子书这么多的图书馆,但写我没有找到任何东西。
In android so many libraries available for reading any eBook, but for writing i didn't find any thing.
有关读取任何电子书文件必须在.epub格式。
For reading any eBook file must be in .epub format.
我有一个编辑器中,我输入一些文字,并保存该文件中的任何格式后,我怎么可以转换文件到.epub文件。
I have an editor in which i am entering some text and after saving that file in any format how can i convert that file into .epub file.
在此先感谢。
推荐答案
在Android的Java是开发语言,用于创建应用程序,使用的(LIB在Java)
In android Java is developer language for create APP, use Epublib (lib in java)
阅读doc文件与 POI
创建EPUB文件:
package nl.siegmann.epublib.examples;
import java.io.InputStream;
import java.io.FileOutputStream;
import nl.siegmann.epublib.domain.Author;
import nl.siegmann.epublib.domain.Book;
import nl.siegmann.epublib.domain.Metadata;
import nl.siegmann.epublib.domain.Resource;
import nl.siegmann.epublib.domain.TOCReference;
import nl.siegmann.epublib.epub.EpubWriter;
public class Translator {
private static InputStream getResource( String path ) {
return Translator.class.getResourceAsStream( path );
}
private static Resource getResource( String path, String href ) {
return new Resource( getResource( path ), href );
}
public static void main(String[] args) {
try {
// Create new Book
Book book = new Book();
Metadata metadata = book.getMetadata();
// Set the title
metadata.addTitle("Epublib test book 1");
// Add an Author
metadata.addAuthor(new Author("Joe", "Tester"));
// Set cover image
book.setCoverImage(
getResource("/book1/test_cover.png", "cover.png") );
// Add Chapter 1
book.addSection("Introduction",
getResource("/book1/chapter1.html", "chapter1.html") );
// Add css file
book.getResources().add(
getResource("/book1/book1.css", "book1.css") );
// Add Chapter 2
TOCReference chapter2 = book.addSection( "Second Chapter",
getResource("/book1/chapter2.html", "chapter2.html") );
// Add image used by Chapter 2
book.getResources().add(
getResource("/book1/flowers_320x240.jpg", "flowers.jpg"));
// Add Chapter2, Section 1
book.addSection(chapter2, "Chapter 2, section 1",
getResource("/book1/chapter2_1.html", "chapter2_1.html"));
// Add Chapter 3
book.addSection("Conclusion",
getResource("/book1/chapter3.html", "chapter3.html"));
// Create EpubWriter
EpubWriter epubWriter = new EpubWriter();
// Write the Book as Epub
epubWriter.write(book, new FileOutputStream("test1_book1.epub"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
这篇关于如何将任何格式的文件(.txt,.doc)格式文件输出到在Android应用程序的epub文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!