From 37a38b606c86cc8c711febe5fb0e3c6c7c883cab Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 26 Aug 2012 12:49:08 +0530 Subject: [PATCH] ... --- src/calibre/ebooks/pdf/manipulate/info.py | 4 ++-- src/calibre/utils/podofo/doc.cpp | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/calibre/ebooks/pdf/manipulate/info.py b/src/calibre/ebooks/pdf/manipulate/info.py index 0cb4f69172..9b6e0312d0 100644 --- a/src/calibre/ebooks/pdf/manipulate/info.py +++ b/src/calibre/ebooks/pdf/manipulate/info.py @@ -13,10 +13,9 @@ import os, sys from calibre.utils.config import OptionParser from calibre.utils.logging import Log -from calibre.constants import preferred_encoding +from calibre.constants import preferred_encoding, plugins from calibre.ebooks.pdf.verify import is_valid_pdfs, is_encrypted from calibre import prints -from calibre.utils.podofo import podofo, podofo_err USAGE = '\n%prog %%name ' + _('''\ file.pdf ... @@ -33,6 +32,7 @@ def option_parser(name): return OptionParser(usage=usage) def print_info(pdf_path): + podofo, podofo_err = plugins['podofo'] if not podofo: raise RuntimeError('Failed to load PoDoFo with error:'+podofo_err) p = podofo.PDFDoc() diff --git a/src/calibre/utils/podofo/doc.cpp b/src/calibre/utils/podofo/doc.cpp index bf3135c7ee..72180bb55f 100644 --- a/src/calibre/utils/podofo/doc.cpp +++ b/src/calibre/utils/podofo/doc.cpp @@ -9,6 +9,7 @@ using namespace pdf; +// Constructor/desctructor {{{ static void PDFDoc_dealloc(PDFDoc* self) { @@ -29,7 +30,9 @@ PDFDoc_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return (PyObject *)self; } +// }}} +// Loading/Opening of PDF files {{{ static PyObject * PDFDoc_load(PDFDoc *self, PyObject *args, PyObject *kwargs) { char *buffer; Py_ssize_t size; @@ -63,7 +66,9 @@ PDFDoc_open(PDFDoc *self, PyObject *args, PyObject *kwargs) { Py_RETURN_NONE; } +// }}} +// Saving/writing of PDF files {{{ static PyObject * PDFDoc_save(PDFDoc *self, PyObject *args, PyObject *kwargs) { char *buffer; @@ -97,7 +102,9 @@ PDFDoc_write(PDFDoc *self, PyObject *args, PyObject *kwargs) { if (ans == NULL) PyErr_NoMemory(); return ans; } +// }}} +// extract_first_page() {{{ static PyObject * PDFDoc_extract_first_page(PDFDoc *self, PyObject *args, PyObject *kwargs) { try { @@ -108,7 +115,9 @@ PDFDoc_extract_first_page(PDFDoc *self, PyObject *args, PyObject *kwargs) { } Py_RETURN_NONE; } +// }}} +// page_count() {{{ static PyObject * PDFDoc_page_count(PDFDoc *self, PyObject *args, PyObject *kwargs) { int count; @@ -119,8 +128,9 @@ PDFDoc_page_count(PDFDoc *self, PyObject *args, PyObject *kwargs) { return NULL; } return Py_BuildValue("i", count); -} +} // }}} +// delete_page {{{ static PyObject * PDFDoc_delete_page(PDFDoc *self, PyObject *args, PyObject *kwargs) { int num = 0; @@ -134,12 +144,13 @@ PDFDoc_delete_page(PDFDoc *self, PyObject *args, PyObject *kwargs) { } else return NULL; Py_RETURN_NONE; -} +} // }}} +// append() {{{ static PyObject * PDFDoc_append(PDFDoc *self, PyObject *args, PyObject *kwargs) { Py_RETURN_NONE; -} +} // }}} // Properties {{{ @@ -379,6 +390,7 @@ static PyMethodDef PDFDoc_methods[] = { {NULL} /* Sentinel */ }; +// Type definition {{{ PyTypeObject pdf::PDFDocType = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ @@ -421,5 +433,5 @@ PyTypeObject pdf::PDFDocType = { PDFDoc_new, /* tp_new */ }; - +// }}}