mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Run preprocess rules when viewing PDF files
This commit is contained in:
parent
352b5d24ed
commit
aa25d2a814
@ -130,6 +130,9 @@ class EbookIterator(object):
|
|||||||
plumber.opts.dont_package = True
|
plumber.opts.dont_package = True
|
||||||
if hasattr(plumber.opts, 'no_process'):
|
if hasattr(plumber.opts, 'no_process'):
|
||||||
plumber.opts.no_process = True
|
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'),
|
self.pathtoopf = plumber.input_plugin(open(plumber.input, 'rb'),
|
||||||
plumber.opts, plumber.input_fmt, self.log,
|
plumber.opts, plumber.input_fmt, self.log,
|
||||||
{}, self.base)
|
{}, self.base)
|
||||||
|
@ -18,9 +18,15 @@ class PDFInput(InputFormatPlugin):
|
|||||||
description = 'Convert PDF files to HTML'
|
description = 'Convert PDF files to HTML'
|
||||||
file_types = set(['pdf'])
|
file_types = set(['pdf'])
|
||||||
|
|
||||||
|
_preprocess_html_for_viewer = False
|
||||||
|
|
||||||
def convert(self, stream, options, file_ext, log,
|
def convert(self, stream, options, file_ext, log,
|
||||||
accelerators):
|
accelerators):
|
||||||
html = pdftohtml(stream.name)
|
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)
|
||||||
|
|
||||||
with open('index.html', 'wb') as index:
|
with open('index.html', 'wb') as index:
|
||||||
index.write(html)
|
index.write(html)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user