mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-18 22:15:08 +01:00
Fixes for PDB-PDF input.
This commit is contained in:
parent
472e8d1743
commit
7b5cecfc2e
1 changed files with 8 additions and 7 deletions
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
from calibre.ebooks.pdb.formatreader import FormatReader
|
||||
from calibre.ptempfile import TemporaryFile
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
|
||||
class Reader(FormatReader):
|
||||
|
||||
|
|
@ -23,10 +23,12 @@ def __init__(self, header, stream, log, options):
|
|||
def extract_content(self, output_dir):
|
||||
self.log.info('Extracting PDF...')
|
||||
|
||||
with TemporaryFile() as pdf_n:
|
||||
pdf = open(pdf_n, 'rwb')
|
||||
for x in xrange(self.header.section_count()):
|
||||
pdf.write(self.header.section_data(x))
|
||||
pdf = PersistentTemporaryFile('.pdf')
|
||||
pdf.close()
|
||||
pdf = open(pdf, 'wb')
|
||||
for x in xrange(self.header.section_count()):
|
||||
pdf.write(self.header.section_data(x))
|
||||
pdf.close()
|
||||
|
||||
from calibre.customize.ui import plugin_for_input_format
|
||||
|
||||
|
|
@ -35,5 +37,4 @@ def extract_content(self, output_dir):
|
|||
if not hasattr(self.options, opt.option.name):
|
||||
setattr(self.options, opt.option.name, opt.recommended_value)
|
||||
|
||||
pdf.seek(0)
|
||||
return pdf_plugin.convert(pdf, self.options, 'pdf', self.log, {})
|
||||
return pdf_plugin.convert(open(pdf, 'rb'), self.options, 'pdf', self.log, {})
|
||||
|
|
|
|||
Loading…
Reference in a new issue