mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Fix #858359 (Private bug)
This commit is contained in:
commit
223cdb4ec1
@ -173,6 +173,10 @@ class PDFWriter(QObject): # {{{
|
|||||||
printer.setOutputFormat(QPrinter.NativeFormat)
|
printer.setOutputFormat(QPrinter.NativeFormat)
|
||||||
self.view.print_(printer)
|
self.view.print_(printer)
|
||||||
printer.abort()
|
printer.abort()
|
||||||
|
else:
|
||||||
|
# The document is so corrupt that we can't render the page.
|
||||||
|
self.loop.exit(0)
|
||||||
|
raise Exception('Document cannot be rendered.')
|
||||||
self._render_book()
|
self._render_book()
|
||||||
|
|
||||||
def _delete_tmpdir(self):
|
def _delete_tmpdir(self):
|
||||||
@ -207,11 +211,14 @@ class PDFWriter(QObject): # {{{
|
|||||||
try:
|
try:
|
||||||
outPDF = PdfFileWriter(title=self.metadata.title, author=self.metadata.author)
|
outPDF = PdfFileWriter(title=self.metadata.title, author=self.metadata.author)
|
||||||
for item in self.combine_queue:
|
for item in self.combine_queue:
|
||||||
with open(item, 'rb') as item_stream:
|
# The input PDF stream must remain open until the final PDF
|
||||||
inputPDF = PdfFileReader(item_stream)
|
# is written to disk. PyPDF references pages added to the
|
||||||
for page in inputPDF.pages:
|
# final PDF from the input PDF on disk. It does not store
|
||||||
outPDF.addPage(page)
|
# the pages in memory so we can't close the input PDF.
|
||||||
outPDF.write(self.out_stream)
|
inputPDF = PdfFileReader(open(item, 'rb'))
|
||||||
|
for page in inputPDF.pages:
|
||||||
|
outPDF.addPage(page)
|
||||||
|
outPDF.write(self.out_stream)
|
||||||
finally:
|
finally:
|
||||||
self._delete_tmpdir()
|
self._delete_tmpdir()
|
||||||
self.loop.exit(0)
|
self.loop.exit(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user