mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Ebook Viewer: When viewing PDF run through OEBBook
This commit is contained in:
parent
61b10c93d7
commit
b407fdf9ab
@ -123,19 +123,21 @@ class EbookIterator(object):
|
||||
self.delete_on_exit = []
|
||||
self._tdir = TemporaryDirectory('_ebook_iter')
|
||||
self.base = self._tdir.__enter__()
|
||||
from calibre.ebooks.conversion.plumber import Plumber
|
||||
from calibre.ebooks.conversion.plumber import Plumber, create_oebbook
|
||||
plumber = Plumber(self.pathtoebook, self.base, self.log)
|
||||
plumber.setup_options()
|
||||
if hasattr(plumber.opts, 'dont_package'):
|
||||
plumber.opts.dont_package = True
|
||||
if hasattr(plumber.opts, 'no_process'):
|
||||
plumber.opts.no_process = True
|
||||
if hasattr(plumber.input_plugin, '_preprocess_html_for_viewer'):
|
||||
plumber.input_plugin._preprocess_html_for_viewer = True
|
||||
|
||||
self.pathtoopf = plumber.input_plugin(open(plumber.input, 'rb'),
|
||||
plumber.opts, plumber.input_fmt, self.log,
|
||||
{}, self.base)
|
||||
|
||||
if plumber.input_fmt.lower() == 'pdf':
|
||||
self.pathtoopf = create_oebbook(self.log, self.pathtoopf, plumber.opts,
|
||||
plumber.input_plugin)
|
||||
if hasattr(self.pathtoopf, 'manifest'):
|
||||
self.pathtoopf = write_oebbook(self.pathtoopf, self.base)
|
||||
|
||||
|
@ -17,18 +17,10 @@ class PDFInput(InputFormatPlugin):
|
||||
description = 'Convert PDF files to HTML'
|
||||
file_types = set(['pdf'])
|
||||
|
||||
_preprocess_html_for_viewer = False
|
||||
|
||||
def convert(self, stream, options, file_ext, log,
|
||||
accelerators):
|
||||
html = pdftohtml(stream.name)
|
||||
|
||||
if self._preprocess_html_for_viewer:
|
||||
from calibre.ebooks.conversion.preprocess import HTMLPreProcessor
|
||||
prepro = HTMLPreProcessor(lambda x:x, False)
|
||||
html = prepro(html.decode('utf-8')).encode('utf-8')
|
||||
|
||||
|
||||
with open('index.html', 'wb') as index:
|
||||
index.write(html)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user