__copyright__ = '2009, John Schember <john@nachtimwald.com>'
__docformat__ = 'restructuredtext en'
import os
from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation
from calibre.ebooks.pdf.pdftohtml import pdftohtml
from calibre.ebooks.metadata.opf2 import OPFCreator
from calibre.constants import plugins
(pdfreflow, pdfreflow_err) = plugins['pdfreflow']
class PDFInput(InputFormatPlugin):
name = 'PDF Input'
author = 'Kovid Goyal and John Schember'
description = 'Convert PDF files to HTML'
file_types = set([
'pdf'])
options = set([
OptionRecommendation(name = 'no_images', recommended_value = False, help = _('Do not extract images from the document')),
OptionRecommendation(name = 'unwrap_factor', recommended_value = 0.5, help = _('Scale used to determine the length at which a line should be unwrapped. Valid values are a decimal between 0 and 1. The default is 0.5, this is the median line length.')),
OptionRecommendation(name = 'new_pdf_engine', recommended_value = False, help = _('Use the new PDF conversion engine.'))])
def convert_new(self, stream, accelerators):
PDFDocument = PDFDocument
import calibre.ebooks.pdf.reflow
if pdfreflow_err:
raise RuntimeError('Failed to load pdfreflow: ' + pdfreflow_err)