mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-01-30 18:25:44 +01:00
Here is the first batch of modules, which are needed for converting several formats to LRF. Some of the logic has been change, more cleanups will follow.
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
|
|
'''
|
|
Read content from palmdoc pdb file.
|
|
'''
|
|
|
|
__license__ = 'GPL v3'
|
|
__copyright__ = '2010, John Schember <john@nachtimwald.com>'
|
|
__docformat__ = 'restructuredtext en'
|
|
|
|
|
|
from ebook_converter.ebooks.pdb.formatreader import FormatReader
|
|
from ebook_converter.ptempfile import PersistentTemporaryFile
|
|
from ebook_converter.polyglot.builtins import range
|
|
|
|
|
|
class Reader(FormatReader):
|
|
|
|
def __init__(self, header, stream, log, options):
|
|
self.header = header
|
|
self.stream = stream
|
|
self.log = log
|
|
self.options = options
|
|
|
|
def extract_content(self, output_dir):
|
|
self.log.info('Extracting PDF...')
|
|
|
|
pdf = PersistentTemporaryFile('.pdf')
|
|
pdf.close()
|
|
pdf = open(pdf, 'wb')
|
|
for x in range(self.header.section_count()):
|
|
pdf.write(self.header.section_data(x))
|
|
pdf.close()
|
|
|
|
from ebook_converter.customize.ui import plugin_for_input_format
|
|
|
|
pdf_plugin = plugin_for_input_format('pdf')
|
|
for opt in pdf_plugin.options:
|
|
if not hasattr(self.options, opt.option.name):
|
|
setattr(self.options, opt.option.name, opt.recommended_value)
|
|
|
|
return pdf_plugin.convert(open(pdf, 'rb'), self.options, 'pdf', self.log, {})
|