diff --git a/src/calibre/utils/podofo/doc.cpp b/src/calibre/utils/podofo/doc.cpp index b33647336c..58572a688e 100644 --- a/src/calibre/utils/podofo/doc.cpp +++ b/src/calibre/utils/podofo/doc.cpp @@ -39,7 +39,11 @@ PDFDoc_load(PDFDoc *self, PyObject *args) { if (PyArg_ParseTuple(args, "s#", &buffer, &size)) { try { +#if PODOFO_VERSION <= 0x000905 self->doc->Load(buffer, (long)size); +#else + self->doc->LoadBuffer(buffer, (long)size); +#endif } catch(const PdfError & err) { podofo_set_exception(err); return NULL; @@ -56,7 +60,11 @@ PDFDoc_open(PDFDoc *self, PyObject *args) { if (PyArg_ParseTuple(args, "s", &fname)) { try { +#if PODOFO_VERSION <= 0x000905 self->doc->Load(fname); +#else + self->doc->LoadFromFile(fname); +#endif } catch(const PdfError & err) { podofo_set_exception(err); return NULL; @@ -88,7 +96,7 @@ PDFDoc_save(PDFDoc *self, PyObject *args) { static PyObject * PDFDoc_write(PDFDoc *self, PyObject *args) { PyObject *ans; - + try { PdfRefCountedBuffer buffer(1*1024*1024); PdfOutputDevice out(&buffer); @@ -305,7 +313,7 @@ PDFDoc_set_xmp_metadata(PDFDoc *self, PyObject *args) { long len = 0; PoDoFo::PdfObject *metadata = NULL, *catalog = NULL; PoDoFo::PdfStream *str = NULL; - TVecFilters compressed(1); + TVecFilters compressed(1); compressed[0] = ePdfFilter_FlateDecode; if (!PyArg_ParseTuple(args, "s#", &raw, &len)) return NULL; @@ -428,7 +436,7 @@ PDFDoc_setter(PDFDoc *self, PyObject *val, int field) { PdfString *s = NULL; 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; @@ -503,35 +511,35 @@ PDFDoc_producer_setter(PDFDoc *self, PyObject *val, void *closure) { } static PyGetSetDef PDFDoc_getsetters[] = { - {(char *)"title", + {(char *)"title", (getter)PDFDoc_title_getter, (setter)PDFDoc_title_setter, (char *)"Document title", NULL}, - {(char *)"author", + {(char *)"author", (getter)PDFDoc_author_getter, (setter)PDFDoc_author_setter, (char *)"Document author", NULL}, - {(char *)"subject", + {(char *)"subject", (getter)PDFDoc_subject_getter, (setter)PDFDoc_subject_setter, (char *)"Document subject", NULL}, - {(char *)"keywords", + {(char *)"keywords", (getter)PDFDoc_keywords_getter, (setter)PDFDoc_keywords_setter, (char *)"Document keywords", NULL}, - {(char *)"creator", + {(char *)"creator", (getter)PDFDoc_creator_getter, (setter)PDFDoc_creator_setter, (char *)"Document creator", NULL}, - {(char *)"producer", + {(char *)"producer", (getter)PDFDoc_producer_getter, (setter)PDFDoc_producer_setter, (char *)"Document producer", NULL}, - {(char *)"pages", + {(char *)"pages", (getter)PDFDoc_pages_getter, NULL, (char *)"Number of pages in document (read only)", NULL}, - {(char *)"version", + {(char *)"version", (getter)PDFDoc_version_getter, NULL, (char *)"The PDF version (read only)", NULL}, @@ -633,4 +641,3 @@ PyTypeObject pdf::PDFDocType = { }; // }}} -