Examples of EpubWriter


Examples of nl.siegmann.epublib.epub.EpubWriter

 
      // Add Chapter 3
      book.addResourceAsSection("Conclusion", new InputStreamResource(Simple1.class.getResourceAsStream("/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();
    }
  }
View Full Code Here

Examples of nl.siegmann.epublib.epub.EpubWriter

    if(StringUtils.isBlank(inputLocation) || StringUtils.isBlank(outLocation)) {
      usage();
    }
    BookProcessorPipeline epubCleaner = new DefaultBookProcessorPipeline();
    epubCleaner.addBookProcessors(createBookProcessors(bookProcessorClassNames));
    EpubWriter epubWriter = new EpubWriter(epubCleaner);
    if(! StringUtils.isBlank(xslFile)) {
      epubCleaner.addBookProcessor(new XslBookProcessor(xslFile));
    }
   
    if (StringUtils.isBlank(inputEncoding)) {
      inputEncoding = Constants.CHARACTER_ENCODING;
    }
   
    Book book;
    if("chm".equals(type)) {
      book = ChmParser.parseChm(VFSUtil.resolveFileObject(inputLocation), inputEncoding);
    } else if ("epub".equals(type)) {
      book = new EpubReader().readEpub(VFSUtil.resolveInputStream(inputLocation), inputEncoding);
    } else {
      book = FilesetBookCreator.createBookFromDirectory(VFSUtil.resolveFileObject(inputLocation), inputEncoding);
    }
   
    if(StringUtils.isNotBlank(coverImage)) {
//      book.getResourceByHref(book.getCoverImage());
      book.setCoverImage(new Resource(VFSUtil.resolveInputStream(coverImage), coverImage));
      epubCleaner.getBookProcessors().add(new CoverpageBookProcessor());
    }
   
    if(StringUtils.isNotBlank(title)) {
      List<String> titles = new ArrayList<String>();
      titles.add(title);
      book.getMetadata().setTitles(titles);
    }
   
    if(StringUtils.isNotBlank(isbn)) {
      book.getMetadata().addIdentifier(new Identifier(Identifier.Scheme.ISBN, isbn));
    }
   
    initAuthors(authorNames, book);
   
    OutputStream result;
    try {
      result = VFS.getManager().resolveFile(outLocation).getContent().getOutputStream();
    } catch(FileSystemException e) {
      result = new FileOutputStream(outLocation);
    }
    epubWriter.write(book, result);
  }
View Full Code Here

Examples of nl.siegmann.epublib.epub.EpubWriter

        }
        if (! selectedFile.isDirectory()) {
          previousDir = selectedFile.getParentFile();
        }
        try {
          (new EpubWriter()).write(navigator.getBook(), new FileOutputStream(selectedFile));
        } catch (Exception e1) {
          log.error(e1.getMessage(), e1);
        }
      }
    });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.