mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1791430 [Podofo ABI breakage in 0.9.6](https://bugs.launchpad.net/calibre/+bug/1791430)
This commit is contained in:
parent
d00b9e704a
commit
dc130d90cd
@ -39,7 +39,11 @@ PDFDoc_load(PDFDoc *self, PyObject *args) {
|
|||||||
|
|
||||||
if (PyArg_ParseTuple(args, "s#", &buffer, &size)) {
|
if (PyArg_ParseTuple(args, "s#", &buffer, &size)) {
|
||||||
try {
|
try {
|
||||||
|
#if PODOFO_VERSION <= 0x000905
|
||||||
self->doc->Load(buffer, (long)size);
|
self->doc->Load(buffer, (long)size);
|
||||||
|
#else
|
||||||
|
self->doc->LoadBuffer(buffer, (long)size);
|
||||||
|
#endif
|
||||||
} catch(const PdfError & err) {
|
} catch(const PdfError & err) {
|
||||||
podofo_set_exception(err);
|
podofo_set_exception(err);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -56,7 +60,11 @@ PDFDoc_open(PDFDoc *self, PyObject *args) {
|
|||||||
|
|
||||||
if (PyArg_ParseTuple(args, "s", &fname)) {
|
if (PyArg_ParseTuple(args, "s", &fname)) {
|
||||||
try {
|
try {
|
||||||
|
#if PODOFO_VERSION <= 0x000905
|
||||||
self->doc->Load(fname);
|
self->doc->Load(fname);
|
||||||
|
#else
|
||||||
|
self->doc->LoadFromFile(fname);
|
||||||
|
#endif
|
||||||
} catch(const PdfError & err) {
|
} catch(const PdfError & err) {
|
||||||
podofo_set_exception(err);
|
podofo_set_exception(err);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -88,7 +96,7 @@ PDFDoc_save(PDFDoc *self, PyObject *args) {
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
PDFDoc_write(PDFDoc *self, PyObject *args) {
|
PDFDoc_write(PDFDoc *self, PyObject *args) {
|
||||||
PyObject *ans;
|
PyObject *ans;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PdfRefCountedBuffer buffer(1*1024*1024);
|
PdfRefCountedBuffer buffer(1*1024*1024);
|
||||||
PdfOutputDevice out(&buffer);
|
PdfOutputDevice out(&buffer);
|
||||||
@ -305,7 +313,7 @@ PDFDoc_set_xmp_metadata(PDFDoc *self, PyObject *args) {
|
|||||||
long len = 0;
|
long len = 0;
|
||||||
PoDoFo::PdfObject *metadata = NULL, *catalog = NULL;
|
PoDoFo::PdfObject *metadata = NULL, *catalog = NULL;
|
||||||
PoDoFo::PdfStream *str = NULL;
|
PoDoFo::PdfStream *str = NULL;
|
||||||
TVecFilters compressed(1);
|
TVecFilters compressed(1);
|
||||||
compressed[0] = ePdfFilter_FlateDecode;
|
compressed[0] = ePdfFilter_FlateDecode;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "s#", &raw, &len)) return NULL;
|
if (!PyArg_ParseTuple(args, "s#", &raw, &len)) return NULL;
|
||||||
@ -428,7 +436,7 @@ PDFDoc_setter(PDFDoc *self, PyObject *val, int field) {
|
|||||||
PdfString *s = NULL;
|
PdfString *s = NULL;
|
||||||
|
|
||||||
if (self->doc->GetEncrypted()) s = podofo_convert_pystring_single_byte(val);
|
if (self->doc->GetEncrypted()) s = podofo_convert_pystring_single_byte(val);
|
||||||
else s = podofo_convert_pystring(val);
|
else s = podofo_convert_pystring(val);
|
||||||
if (s == NULL) return -1;
|
if (s == NULL) return -1;
|
||||||
|
|
||||||
|
|
||||||
@ -503,35 +511,35 @@ PDFDoc_producer_setter(PDFDoc *self, PyObject *val, void *closure) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static PyGetSetDef PDFDoc_getsetters[] = {
|
static PyGetSetDef PDFDoc_getsetters[] = {
|
||||||
{(char *)"title",
|
{(char *)"title",
|
||||||
(getter)PDFDoc_title_getter, (setter)PDFDoc_title_setter,
|
(getter)PDFDoc_title_getter, (setter)PDFDoc_title_setter,
|
||||||
(char *)"Document title",
|
(char *)"Document title",
|
||||||
NULL},
|
NULL},
|
||||||
{(char *)"author",
|
{(char *)"author",
|
||||||
(getter)PDFDoc_author_getter, (setter)PDFDoc_author_setter,
|
(getter)PDFDoc_author_getter, (setter)PDFDoc_author_setter,
|
||||||
(char *)"Document author",
|
(char *)"Document author",
|
||||||
NULL},
|
NULL},
|
||||||
{(char *)"subject",
|
{(char *)"subject",
|
||||||
(getter)PDFDoc_subject_getter, (setter)PDFDoc_subject_setter,
|
(getter)PDFDoc_subject_getter, (setter)PDFDoc_subject_setter,
|
||||||
(char *)"Document subject",
|
(char *)"Document subject",
|
||||||
NULL},
|
NULL},
|
||||||
{(char *)"keywords",
|
{(char *)"keywords",
|
||||||
(getter)PDFDoc_keywords_getter, (setter)PDFDoc_keywords_setter,
|
(getter)PDFDoc_keywords_getter, (setter)PDFDoc_keywords_setter,
|
||||||
(char *)"Document keywords",
|
(char *)"Document keywords",
|
||||||
NULL},
|
NULL},
|
||||||
{(char *)"creator",
|
{(char *)"creator",
|
||||||
(getter)PDFDoc_creator_getter, (setter)PDFDoc_creator_setter,
|
(getter)PDFDoc_creator_getter, (setter)PDFDoc_creator_setter,
|
||||||
(char *)"Document creator",
|
(char *)"Document creator",
|
||||||
NULL},
|
NULL},
|
||||||
{(char *)"producer",
|
{(char *)"producer",
|
||||||
(getter)PDFDoc_producer_getter, (setter)PDFDoc_producer_setter,
|
(getter)PDFDoc_producer_getter, (setter)PDFDoc_producer_setter,
|
||||||
(char *)"Document producer",
|
(char *)"Document producer",
|
||||||
NULL},
|
NULL},
|
||||||
{(char *)"pages",
|
{(char *)"pages",
|
||||||
(getter)PDFDoc_pages_getter, NULL,
|
(getter)PDFDoc_pages_getter, NULL,
|
||||||
(char *)"Number of pages in document (read only)",
|
(char *)"Number of pages in document (read only)",
|
||||||
NULL},
|
NULL},
|
||||||
{(char *)"version",
|
{(char *)"version",
|
||||||
(getter)PDFDoc_version_getter, NULL,
|
(getter)PDFDoc_version_getter, NULL,
|
||||||
(char *)"The PDF version (read only)",
|
(char *)"The PDF version (read only)",
|
||||||
NULL},
|
NULL},
|
||||||
@ -633,4 +641,3 @@ PyTypeObject pdf::PDFDocType = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user