mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #3294 (Calibre 0.6.8 E-book library management has stopped working)
This commit is contained in:
parent
779fcd4fe2
commit
f289c6b44b
@ -22,6 +22,7 @@ def get_metadata(stream, cover=True):
|
||||
raw = stream.read()
|
||||
doc = poppler.PDFDoc()
|
||||
doc.load(raw)
|
||||
del raw
|
||||
title = doc.title
|
||||
if not title or not title.strip():
|
||||
title = _('Unknown')
|
||||
@ -55,7 +56,6 @@ def get_metadata(stream, cover=True):
|
||||
if cdata is not None:
|
||||
mi.cover_data = ('jpg', cdata)
|
||||
del doc
|
||||
del raw
|
||||
return mi
|
||||
|
||||
|
||||
|
@ -176,15 +176,16 @@ poppler_PDFDoc_render_page(poppler_PDFDoc *self, PyObject *args, PyObject *kwarg
|
||||
int num;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i|ff", &num, &xdpi, &ydpi)) return ans;
|
||||
if ( num < 0 || num >= self->doc->numPages()) {
|
||||
PyErr_SetString(PyExc_ValueError, "Invalid page number");
|
||||
return ans;
|
||||
}
|
||||
if ( self->doc->isLocked()) {
|
||||
PyErr_SetString(PyExc_ValueError, "This document is copyrighted.");
|
||||
return ans;
|
||||
}
|
||||
|
||||
if ( num < 0 || num >= self->doc->numPages()) {
|
||||
PyErr_SetString(PyExc_ValueError, "Invalid page number");
|
||||
return ans;
|
||||
}
|
||||
|
||||
page = self->doc->page(num);
|
||||
img = page->renderToImage(xdpi, ydpi);
|
||||
if (img.isNull()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user