X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpython%2Fgfx.c;h=7e5c400b81fdc89cce9ca6bd6b1e0a2bffeaac01;hb=042eafdfeac139b966275672972385f6469e2dff;hp=336d162f575567d6b9a235090e9baddb24dcc2e5;hpb=436191adfc1794661e59c87c88ab3b5830d6c4f8;p=swftools.git diff --git a/lib/python/gfx.c b/lib/python/gfx.c index 336d162..7e5c400 100644 --- a/lib/python/gfx.c +++ b/lib/python/gfx.c @@ -69,15 +69,15 @@ static char* strf(char*format, ...) //--------------------------------------------------------------------- staticforward PyObject* output_save(PyObject* _self, PyObject* args, PyObject* kwargs); -staticforward PyObject* output_startframe(PyObject* _self, PyObject* args, PyObject* kwargs); -staticforward PyObject* output_endframe(PyObject* _self, PyObject* args, PyObject* kwargs); +staticforward PyObject* output_startpage(PyObject* _self, PyObject* args, PyObject* kwargs); +staticforward PyObject* output_endpage(PyObject* _self, PyObject* args, PyObject* kwargs); static PyMethodDef output_methods[] = { /* Output functions */ {"save", (PyCFunction)output_save, METH_KEYWORDS, ""}, - {"startframe", (PyCFunction)output_startframe, METH_KEYWORDS, ""}, - {"endframe", (PyCFunction)output_endframe, METH_KEYWORDS, ""}, + {"startpage", (PyCFunction)output_startpage, METH_KEYWORDS, ""}, + {"endpage", (PyCFunction)output_endpage, METH_KEYWORDS, ""}, {0,0,0,0} }; static PyObject* output_save(PyObject* _self, PyObject* args, PyObject* kwargs) @@ -89,13 +89,14 @@ static PyObject* output_save(PyObject* _self, PyObject* args, PyObject* kwargs) return NULL; gfxresult_t*result = self->output_device->finish(self->output_device); + self->output_device = 0; if(result->save(result, filename) < 0) { return PY_ERROR("Couldn't write to %s", filename); } result->destroy(result); return PY_NONE; } -static PyObject* output_startframe(PyObject* _self, PyObject* args, PyObject* kwargs) +static PyObject* output_startpage(PyObject* _self, PyObject* args, PyObject* kwargs) { OutputObject* self = (OutputObject*)_self; int width=0, height=0; @@ -104,7 +105,7 @@ static PyObject* output_startframe(PyObject* _self, PyObject* args, PyObject* kw self->output_device->startpage(self->output_device, width, height); return PY_NONE; } -static PyObject* output_endframe(PyObject* _self, PyObject* args, PyObject* kwargs) +static PyObject* output_endpage(PyObject* _self, PyObject* args, PyObject* kwargs) { OutputObject* self = (OutputObject*)_self; if (!PyArg_ParseTuple(args, "")) @@ -311,11 +312,13 @@ static int page_print(PyObject * _self, FILE *fi, int flags) //--------------------------------------------------------------------- staticforward PyObject* doc_getPage(PyObject* parent, PyObject* args, PyObject* kwargs); +staticforward PyObject* doc_getInfo(PyObject* parent, PyObject* args, PyObject* kwargs); static PyMethodDef doc_methods[] = { /* PDF functions */ {"getPage", (PyCFunction)doc_getPage, METH_KEYWORDS, ""}, + {"getInfo", (PyCFunction)doc_getInfo, METH_KEYWORDS, ""}, {0,0,0,0} }; @@ -340,6 +343,19 @@ static PyObject* doc_getPage(PyObject* _self, PyObject* args, PyObject* kwargs) return (PyObject*)page; } +static PyObject* doc_getInfo(PyObject* _self, PyObject* args, PyObject* kwargs) +{ + DocObject* self = (DocObject*)_self; + + static char *kwlist[] = {"key", NULL}; + char*key = 0; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &key)) + return NULL; + + char*s = self->doc->getinfo(self->doc, key); + return PyString_FromString(s); +} + static PyObject* f_open(PyObject* parent, PyObject* args, PyObject* kwargs) { static char *kwlist[] = {"type", "filename", NULL}; @@ -445,6 +461,16 @@ static PyObject* f_setoption(PyObject* self, PyObject* args, PyObject* kwargs) return PY_NONE; } +static PyObject* f_verbose(PyObject* self, PyObject* args, PyObject* kwargs) +{ + static char *kwlist[] = {"val", NULL}; + int val; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &val)) + return NULL; + setConsoleLogging(val); + return PY_NONE; +} + static PyObject* f_addfont(PyObject* self, PyObject* args, PyObject* kwargs) { static char *kwlist[] = {"filename", NULL}; @@ -472,6 +498,7 @@ static PyMethodDef pdf2swf_methods[] = {"addfont", (PyCFunction)f_addfont, METH_KEYWORDS, ""}, {"addfontdir", (PyCFunction)f_addfontdir, METH_KEYWORDS, ""}, {"setoption", (PyCFunction)f_setoption, METH_KEYWORDS, ""}, + {"verbose", (PyCFunction)f_verbose, METH_KEYWORDS, ""}, /* devices */ {"SWF", (PyCFunction)f_createSWF, METH_KEYWORDS, ""},