mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
6e25db5853
commit
0a22c291b7
@ -170,6 +170,30 @@ PDFDoc_append(PDFDoc *self, PyObject *args) {
|
||||
Py_RETURN_NONE;
|
||||
} // }}}
|
||||
|
||||
// set_box() {{{
|
||||
static PyObject *
|
||||
PDFDoc_set_box(PDFDoc *self, PyObject *args) {
|
||||
int num = 0;
|
||||
double left, bottom, width, height;
|
||||
char *box;
|
||||
if (!PyArg_ParseTuple(args, "isdddd", &num, &box, &left, &bottom, &width, &height)) return NULL;
|
||||
|
||||
try {
|
||||
PdfRect r(left, bottom, width, height);
|
||||
PdfObject o;
|
||||
r.ToVariant(o);
|
||||
self->doc->GetPage(num)->GetObject()->GetDictionary().AddKey(PdfName(box), o);
|
||||
} catch(const PdfError & err) {
|
||||
podofo_set_exception(err);
|
||||
return NULL;
|
||||
} catch (...) {
|
||||
PyErr_SetString(PyExc_ValueError, "An unknown error occurred while trying to set the box");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
} // }}}
|
||||
|
||||
// Properties {{{
|
||||
|
||||
static PyObject *
|
||||
@ -403,6 +427,9 @@ static PyMethodDef PDFDoc_methods[] = {
|
||||
{"append", (PyCFunction)PDFDoc_append, METH_VARARGS,
|
||||
"append(doc) -> Append doc (which must be a PDFDoc) to this document."
|
||||
},
|
||||
{"set_box", (PyCFunction)PDFDoc_set_box, METH_VARARGS,
|
||||
"set_box(page_num, box, left, bottom, width, height) -> Set the PDF bounding box for the page numbered nu, box must be one of: MediaBox, CropBox, TrimBox, BleedBox, ArtBox. The numbers are interpreted as pts."
|
||||
},
|
||||
|
||||
|
||||
{NULL} /* Sentinel */
|
||||
|
Loading…
x
Reference in New Issue
Block a user