#include "../devices/swf.h"
#include "../devices/render.h"
#include "../devices/rescale.h"
+#include "../devices/text.h"
#include "../pdf/pdf.h"
#include "../log.h"
+#include "../utf8.h"
gfxsource_t*pdfdriver;
//---------------------------------------------------------------------
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)
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;
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, ""))
gfxdevice_swf_init(self->output_device);
return (PyObject*)self;
}
+static PyObject* f_createImageList(PyObject* parent, PyObject* args, PyObject* kwargs)
+{
+ static char *kwlist[] = {NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "", kwlist))
+ return NULL;
+ OutputObject*self = PyObject_New(OutputObject, &OutputClass);
+
+ self->output_device = malloc(sizeof(gfxdevice_t));
+ gfxdevice_render_init(self->output_device);
+ return (PyObject*)self;
+}
+static PyObject* f_createPlainText(PyObject* parent, PyObject* args, PyObject* kwargs)
+{
+ static char *kwlist[] = {NULL};
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "", kwlist))
+ return NULL;
+ OutputObject*self = PyObject_New(OutputObject, &OutputClass);
+
+ self->output_device = malloc(sizeof(gfxdevice_t));
+ gfxdevice_text_init(self->output_device);
+ return (PyObject*)self;
+}
+
+
static void output_dealloc(PyObject* _self) {
OutputObject* self = (OutputObject*)_self;
//---------------------------------------------------------------------
staticforward PyObject* doc_getPage(PyObject* parent, PyObject* args, PyObject* kwargs);
+staticforward PyObject* doc_getInfo(PyObject* parent, PyObject* args, PyObject* kwargs);
+staticforward PyObject* doc_setParameter(PyObject* parent, PyObject* args, PyObject* kwargs);
static PyMethodDef doc_methods[] =
{
/* PDF functions */
{"getPage", (PyCFunction)doc_getPage, METH_KEYWORDS, ""},
+ {"getInfo", (PyCFunction)doc_getInfo, METH_KEYWORDS, ""},
+ {"setParameter", (PyCFunction)doc_setParameter, METH_KEYWORDS, ""},
{0,0,0,0}
};
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* doc_setParameter(PyObject* _self, PyObject* args, PyObject* kwargs)
+{
+ DocObject* self = (DocObject*)_self;
+
+ static char *kwlist[] = {"key", "value", NULL};
+ char*key = 0, *value=0;
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ss", kwlist, &key,&value))
+ return NULL;
+
+ self->doc->set_parameter(self->doc, key, value);
+ return PY_NONE;
+}
+
static PyObject* f_open(PyObject* parent, PyObject* args, PyObject* kwargs)
{
static char *kwlist[] = {"type", "filename", NULL};
DocObject*self = PyObject_New(DocObject, &DriverClass);
if(!strcmp(type,"pdf"))
- self->doc = pdfdriver->open(filename);
+ self->doc = pdfdriver->open(pdfdriver,filename);
else
return PY_ERROR("Unknown type %s", type);
char*key=0,*value=0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ss", kwlist, &key, &value))
return NULL;
- pdfdriver->set_parameter(key,value);
+ pdfdriver->set_parameter(pdfdriver,key,value);
+ 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;
}
char*filename=0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &filename))
return NULL;
- pdfdriver->set_parameter("font", filename);
+ pdfdriver->set_parameter(pdfdriver,"font", filename);
return PY_NONE;
}
char*filename=0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &filename))
return NULL;
- pdfdriver->set_parameter("fontdir", filename);
+ pdfdriver->set_parameter(pdfdriver,"fontdir", filename);
return PY_NONE;
}
static PyMethodDef pdf2swf_methods[] =
{
- /* module functions */
+ /* sources */
{"open", (PyCFunction)f_open, METH_KEYWORDS, ""},
{"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, ""},
+ {"ImageList", (PyCFunction)f_createImageList, METH_KEYWORDS, ""},
+ {"PlainText", (PyCFunction)f_createPlainText, METH_KEYWORDS, ""},
+
+ /* sentinel */
{0, 0, 0, 0}
};