r19699 by jghali - add missing pdf export settings to scripter (patch from Juraj Fedel)
scribus-commit
scribus-commit at lists.scribus.net
Mon Dec 29 12:49:47 UTC 2014
Author: jghali
Date: Mon Dec 29 12:49:47 2014
New Revision: 19699
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19699
Log:
add missing pdf export settings to scripter (patch from Juraj Fedel)
Modified:
trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp
Modified: trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19699&path=/trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/objpdffile.cpp Mon Dec 29 12:49:47 2014
@@ -48,6 +48,7 @@
PyObject_HEAD
PyObject *file; // string - file to save into
PyObject *fonts; // list of string - fonts to embed
+ PyObject *SubsetList; // list of string - fonts to outline
PyObject *pages; // list of int - pages to print
int thumbnails; // bool -
int cropmarks; // bool -
@@ -95,6 +96,28 @@
double bleedr; // double - 0 to width of page
double bleedb; // double - 0 to hight of page
int usedocbleeds; // bool
+ int useLayers;
+ int embedPDF;
+ int MirrorH;
+ int MirrorV;
+ int doClip;
+ PyObject * RotateDeg; // int
+ int isGrayscale;
+ int PageLayout;
+ int displayBookmarks;
+ int displayThumbs;
+ int displayLayers;
+ int displayFullscreen;
+ int hideToolBar;
+ int hideMenuBar;
+ int fitWindow;
+ int cropMarks;
+ int bleedMarks;
+ int registrationMarks;
+ int colorMarks;
+ int docInfoMarks;
+ double markOffset;
+ PyObject *openAction;
} PDFfile;
@@ -102,6 +125,7 @@
{
Py_XDECREF(self->file);
Py_XDECREF(self->fonts);
+ Py_XDECREF(self->SubsetList);
Py_XDECREF(self->pages);
Py_XDECREF(self->resolution);
Py_XDECREF(self->downsample);
@@ -113,6 +137,8 @@
Py_XDECREF(self->imagepr);
Py_XDECREF(self->printprofc);
Py_XDECREF(self->info);
+ Py_XDECREF(self->RotateDeg);
+ Py_XDECREF(self->openAction);
self->ob_type->tp_free((PyObject *)self);
}
@@ -137,6 +163,11 @@
// set fonts attribute
self->fonts = PyList_New(0);
if (!self->fonts){
+ Py_DECREF(self);
+ return NULL;
+ }
+ self->SubsetList = PyList_New(0);
+ if (!self->SubsetList){
Py_DECREF(self);
return NULL;
}
@@ -262,6 +293,36 @@
self->bleedr = 0; // double -
self->bleedb = 0; // double -
self->usedocbleeds = 1; // bool
+ self->useLayers = 0;
+ self->embedPDF = 0;
+ self->MirrorH = 0;
+ self->MirrorV = 0;
+ self->doClip = 0;
+ self->RotateDeg = PyInt_FromLong(0);
+ if (!self->RotateDeg){
+ Py_DECREF(self);
+ return NULL;
+ }
+ self->isGrayscale = 0;
+ self->PageLayout = 0;
+ self->displayBookmarks = 0;
+ self->displayThumbs = 0;
+ self->displayLayers = 0;
+ self->displayFullscreen = 0;
+ self->hideToolBar = 0;
+ self->hideMenuBar = 0;
+ self->fitWindow = 0;
+ self->cropMarks = 0;
+ self->bleedMarks = 0;
+ self->registrationMarks = 0;
+ self->colorMarks = 0;
+ self->docInfoMarks = 0;
+ self->markOffset = 0;
+ self->openAction = PyString_FromString("");
+ if (!self->openAction){
+ Py_DECREF(self);
+ return NULL;
+ }
}
return (PyObject *) self;
}
@@ -322,6 +383,30 @@
}
// }
}
+// init SubsetList
+ fonts = PyList_New(0);
+ if (fonts){
+ Py_DECREF(self->SubsetList);
+ self->SubsetList = fonts;
+ } else {
+ PyErr_SetString(PyExc_SystemError, "Can not initialize 'SubsetList' attribute");
+ return -1;
+ }
+// copied from TabPDFOptions::restoreDefaults()
+ for (int fe = 0; fe < ScCore->primaryMainWindow()->doc->pdfOptions().SubsetList.count(); ++fe)
+ {
+ PyObject *tmp= NULL;
+ tmp = PyString_FromString(ScCore->primaryMainWindow()->doc->pdfOptions().SubsetList[fe].toLatin1().data());
+ if (tmp) {
+ PyList_Append(self->SubsetList, tmp);
+ Py_DECREF(tmp);
+ }
+ else {
+ PyErr_SetString(PyExc_SystemError, "Can not initialize 'SubsetList' attribute");
+ return -1;
+ }
+ }
+
// set to print all pages
PyObject *pages = NULL;
int num = 0;
@@ -546,6 +631,45 @@
self->bleedr = ScCore->primaryMainWindow()->doc->pdfOptions().bleeds.Right*ScCore->primaryMainWindow()->doc->unitRatio(); // double -
self->bleedb = ScCore->primaryMainWindow()->doc->pdfOptions().bleeds.Bottom*ScCore->primaryMainWindow()->doc->unitRatio(); // double -
self->usedocbleeds = ScCore->primaryMainWindow()->doc->pdfOptions().useDocBleeds; // bool
+ self->useLayers = ScCore->primaryMainWindow()->doc->pdfOptions().useLayers; // bool
+ self->embedPDF = ScCore->primaryMainWindow()->doc->pdfOptions().embedPDF; // bool
+ self->MirrorH = ScCore->primaryMainWindow()->doc->pdfOptions().MirrorH; // bool
+ self->MirrorV = ScCore->primaryMainWindow()->doc->pdfOptions().MirrorV; // bool
+ self->doClip = ScCore->primaryMainWindow()->doc->pdfOptions().doClip; // bool
+ PyObject *RotateDeg = NULL;
+ RotateDeg = PyInt_FromLong(0);
+ if (RotateDeg){
+ Py_DECREF(self->RotateDeg);
+ self->RotateDeg = RotateDeg;
+ } else {
+ PyErr_SetString(PyExc_SystemError, "Can not initialize 'RotateDeg' attribute");
+ return -1;
+ }
+ self->isGrayscale = ScCore->primaryMainWindow()->doc->pdfOptions().isGrayscale; // bool
+ self->PageLayout = ScCore->primaryMainWindow()->doc->pdfOptions().PageLayout; // int
+ self->displayBookmarks = ScCore->primaryMainWindow()->doc->pdfOptions().displayBookmarks; // bool
+ self->displayThumbs = ScCore->primaryMainWindow()->doc->pdfOptions().displayThumbs; // bool
+ self->displayLayers = ScCore->primaryMainWindow()->doc->pdfOptions().displayLayers; // bool
+ self->displayFullscreen = ScCore->primaryMainWindow()->doc->pdfOptions().displayFullscreen; // bool
+ self->hideToolBar = ScCore->primaryMainWindow()->doc->pdfOptions().hideToolBar; // bool
+ self->hideMenuBar = ScCore->primaryMainWindow()->doc->pdfOptions().hideMenuBar; // bool
+ self->fitWindow = ScCore->primaryMainWindow()->doc->pdfOptions().fitWindow; // bool
+ self->cropMarks = ScCore->primaryMainWindow()->doc->pdfOptions().cropMarks; // bool
+ self->bleedMarks = ScCore->primaryMainWindow()->doc->pdfOptions().bleedMarks; // bool
+ self->registrationMarks = ScCore->primaryMainWindow()->doc->pdfOptions().registrationMarks; // bool
+ self->colorMarks = ScCore->primaryMainWindow()->doc->pdfOptions().colorMarks; // bool
+ self->docInfoMarks = ScCore->primaryMainWindow()->doc->pdfOptions().docInfoMarks; // bool
+ self->markOffset = ScCore->primaryMainWindow()->doc->pdfOptions().markOffset; // double
+
+ PyObject *openAction = NULL;
+ openAction = PyString_FromString(ScCore->primaryMainWindow()->doc->pdfOptions().openAction.toLatin1().data());
+ if (openAction){
+ Py_DECREF(self->openAction);
+ self->openAction = openAction;
+ } else {
+ PyErr_SetString(PyExc_SystemError, "Can not initialize 'openAction' attribute");
+ return -1;
+ }
return 0;
}
@@ -586,6 +710,31 @@
{const_cast<char*>("bleedr"), T_DOUBLE, offsetof(PDFfile, bleedr), 0, const_cast<char*>("Bleed Right\n""Distance for bleed from the right of the physical page")},
{const_cast<char*>("bleedb"), T_DOUBLE, offsetof(PDFfile, bleedb), 0, const_cast<char*>("Bleed Bottom\n""Distance for bleed from the bottom of the physical page")},
{const_cast<char*>("usedocbleeds"), T_INT, offsetof(PDFfile, usedocbleeds), 0, const_cast<char*>("Use the existing bleed settings from the document preferences. Bool value")},
+ {const_cast<char*>("useLayers"), T_INT, offsetof(PDFfile, useLayers), 0, const_cast<char*>("Layers in your document are exported to the PDF Only available if PDF 1.5 is chosen.")},
+ {const_cast<char*>("embedPDF"), T_INT, offsetof(PDFfile, embedPDF), 0, const_cast<char*>("Export PDFs in image frames as embedded PDFs. This does *not* yet take care of colorspaces, so you should know what you are doing before setting this to 'true'.")},
+ {const_cast<char*>("MirrorH"), T_INT, offsetof(PDFfile, MirrorH), 0, const_cast<char*>("Mirror Page(s) horizontally")},
+ {const_cast<char*>("MirrorV"), T_INT, offsetof(PDFfile, MirrorV), 0, const_cast<char*>("Mirror Page(s) vertically")},
+ {const_cast<char*>("doClip"), T_INT, offsetof(PDFfile, doClip), 0, const_cast<char*>("Do not show objects outside the margins in the exported file")},
+ {const_cast<char*>("isGrayscale"), T_INT, offsetof(PDFfile, isGrayscale), 0, const_cast<char*>("Export PDF in grayscale")},
+ {const_cast<char*>("PageLayout"), T_INT, offsetof(PDFfile, PageLayout), 0, const_cast<char*>("Document layout in PDF viewer:\n"
+ "\t0 - Show the document in single page mode\n"
+ "\t1 - Show the document in single page mode with the pages displayed continuously end to end like a scroll\n"
+ "\t2 - Show the document with facing pages, starting with the first page displayed on the left\n"
+ "\t3 - Show the document with facing pages, starting with the first page displayed on the right"
+ )},
+ {const_cast<char*>("displayBookmarks"), T_INT, offsetof(PDFfile, displayBookmarks), 0, const_cast<char*>("Display the bookmarks upon opening")},
+ {const_cast<char*>("displayThumbs"), T_INT, offsetof(PDFfile, displayThumbs), 0, const_cast<char*>("Display the page thumbnails upon opening")},
+ {const_cast<char*>("displayLayers"), T_INT, offsetof(PDFfile, displayLayers), 0, const_cast<char*>("Forces the displaying of layers. Useful only for PDF 1.5+.")},
+ {const_cast<char*>("displayFullscreen"), T_INT, offsetof(PDFfile, displayFullscreen), 0, const_cast<char*>("Enables viewing the document in full screen")},
+ {const_cast<char*>("hideToolBar"), T_INT, offsetof(PDFfile, hideToolBar), 0, const_cast<char*>("Hides the Tool Bar which has selection and other editing capabilities")},
+ {const_cast<char*>("hideMenuBar"), T_INT, offsetof(PDFfile, hideMenuBar), 0, const_cast<char*>("Hides the Menu Bar for the viewer, the PDF will display in a plain window. ")},
+ {const_cast<char*>("fitWindow"), T_INT, offsetof(PDFfile, fitWindow), 0, const_cast<char*>("Fit the document page or pages to the available space in the viewer window.")},
+ {const_cast<char*>("cropMarks"), T_INT, offsetof(PDFfile, cropMarks), 0, const_cast<char*>("Creates crop marks in the PDF indicating where the paper should be cut or trimmed after printing")},
+ {const_cast<char*>("bleedMarks"), T_INT, offsetof(PDFfile, bleedMarks), 0, const_cast<char*>("This creates bleed marks which are indicated by _ . _ and show the bleed limit")},
+ {const_cast<char*>("registrationMarks"), T_INT, offsetof(PDFfile, registrationMarks), 0, const_cast<char*>("Add registration marks to each separation")},
+ {const_cast<char*>("colorMarks"), T_INT, offsetof(PDFfile, colorMarks), 0, const_cast<char*>("Add color calibration bars")},
+ {const_cast<char*>("docInfoMarks"), T_INT, offsetof(PDFfile, docInfoMarks), 0, const_cast<char*>("Add document information which includes the document title and page numbers")},
+ {const_cast<char*>("markOffset"), T_DOUBLE, offsetof(PDFfile, markOffset), 0, const_cast<char*>("Indicate the distance offset for the registration marks")},
{NULL, 0, 0, 0, NULL} // sentinel
};
@@ -644,6 +793,36 @@
Py_INCREF(value);
self->fonts = value;
PyList_Sort(self->fonts);
+ return 0;
+}
+
+static PyObject *PDFfile_getSubsetList(PDFfile *self, void * /*closure*/)
+{
+ Py_INCREF(self->SubsetList);
+ return self->SubsetList;
+}
+
+static int PDFfile_setSubsetList(PDFfile *self, PyObject *value, void * /*closure*/)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "Cannot delete 'SubsetList' attribute.");
+ return -1;
+ }
+ if (!PyList_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "The 'SubsetList' attribute value must be list of strings.");
+ return -1;
+ }
+ int n;
+ n = PyList_Size(value);
+ for (int i=0; i<n; ++i)
+ if (!PyString_Check(PyList_GetItem(value, i))) {
+ PyErr_SetString(PyExc_TypeError, "The 'SubsetList' list must contain only strings.");
+ return -1;
+ }
+ Py_DECREF(self->SubsetList);
+ Py_INCREF(value);
+ self->SubsetList = value;
+ PyList_Sort(self->SubsetList);
return 0;
}
@@ -958,6 +1137,55 @@
return 0;
}
+static PyObject *PDFfile_getRotateDeg(PDFfile *self, void * /*closure*/)
+{
+ Py_INCREF(self->RotateDeg);
+ return self->RotateDeg;
+}
+
+static int PDFfile_setRotateDeg(PDFfile *self, PyObject *value, void * /*closure*/)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "Cannot delete 'RotateDeg' attribute.");
+ return -1;
+ }
+ if (!PyInt_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "'RotateDeg' attribute value must be integer.");
+ return -1;
+ }
+ int n = PyInt_AsLong(value);
+ if (n!=0 && n!=90 && n!=180 && n!=270) {
+ PyErr_SetString(PyExc_TypeError, "'RotateDeg' value must be 0 or 90 or 180 or 270");
+ return -1;
+ }
+ Py_DECREF(self->RotateDeg);
+ Py_INCREF(value);
+ self->RotateDeg = value;
+ return 0;
+}
+
+static PyObject *PDFfile_getopenAction(PDFfile *self, void * /*closure*/)
+{
+ Py_INCREF(self->openAction);
+ return self->openAction;
+}
+
+static int PDFfile_setopenAction(PDFfile *self, PyObject *value, void * /*closure*/)
+{
+ if (value == NULL) {
+ PyErr_SetString(PyExc_TypeError, "Cannot delete 'openAction' attribute.");
+ return -1;
+ }
+ if (!PyString_Check(value)) {
+ PyErr_SetString(PyExc_TypeError, "'openAction' attribute value must be string.");
+ return -1;
+ }
+ Py_DECREF(self->openAction);
+ Py_INCREF(value);
+ self->openAction = value;
+ return 0;
+}
+
static char *effval_doc = const_cast<char*>(
"List of effection values for each saved page.\n"
"It is list of list of six integers. Those int has followin meaning:\n\t"
@@ -981,6 +1209,7 @@
static PyGetSetDef PDFfile_getseters [] = {
{const_cast<char*>("file"), (getter)PDFfile_getfile, (setter)PDFfile_setfile, const_cast<char*>("Name of file to save into"), NULL},
{const_cast<char*>("fonts"), (getter)PDFfile_getfonts, (setter)PDFfile_setfonts, const_cast<char*>("List of fonts to embed."), NULL},
+ {const_cast<char*>("SubsetList"), (getter)PDFfile_getSubsetList, (setter)PDFfile_setSubsetList, const_cast<char*>("List of fonts to outlined."), NULL},
{const_cast<char*>("pages"), (getter)PDFfile_getpages, (setter)PDFfile_setpages, const_cast<char*>("List of pages to print"), NULL},
{const_cast<char*>("resolution"), (getter)PDFfile_getresolution, (setter)PDFfile_setresolution, const_cast<char*>("Resolution of output file. Values from 35 to 4000."), NULL},
{const_cast<char*>("downsample"), (getter)PDFfile_getdownsample, (setter)PDFfile_setdownsample, const_cast<char*>("Downsample image resolusion to this value. Values from 35 to 4000\nSet 0 for not to downsample"), NULL},
@@ -992,6 +1221,8 @@
{const_cast<char*>("imagepr"), (getter)PDFfile_getimagepr, (setter)PDFfile_setimagepr, const_cast<char*>("Color profile for images"), NULL},
{const_cast<char*>("printprofc"), (getter)PDFfile_getprintprofc, (setter)PDFfile_setprintprofc, const_cast<char*>("Output profile for printing. If possible, get some guidance from your printer on profile selection."), NULL},
{const_cast<char*>("info"), (getter)PDFfile_getinfo, (setter)PDFfile_setinfo, const_cast<char*>("Mandatory string for PDF/X-3 or the PDF will fail\nPDF/X-3 conformance. We recommend you use the title of the document."), NULL},
+ {const_cast<char*>("RotateDeg"), (getter)PDFfile_getRotateDeg, (setter)PDFfile_setRotateDeg, const_cast<char*>("Automatically rotate the exported pages\n\tValue must be one of integers: 0, 90, 180 or 270"), NULL},
+ {const_cast<char*>("openAction"), (getter)PDFfile_getopenAction, (setter)PDFfile_setopenAction, const_cast<char*>("Javascript to be executed when PDF document is opened."), NULL},
{NULL, NULL, NULL, NULL, NULL} // sentinel
};
@@ -1016,6 +1247,14 @@
QString tmpFon;
tmpFon = QString(PyString_AsString(PyList_GetItem(self->fonts, i)));
ScCore->primaryMainWindow()->doc->pdfOptions().EmbedList.append(tmpFon);
+ }
+// apply SubsetList attribute
+ ScCore->primaryMainWindow()->doc->pdfOptions().SubsetList.clear();
+ n = PyList_Size(self->SubsetList);
+ for ( int i=0; i<n; ++i){
+ QString tmpFon;
+ tmpFon = QString(PyString_AsString(PyList_GetItem(self->SubsetList, i)));
+ ScCore->primaryMainWindow()->doc->pdfOptions().SubsetList.append(tmpFon);
}
// apply file attribute
QString fn;
@@ -1212,6 +1451,29 @@
self->bleedb = minmaxd(self->bleedb, 0, ScCore->primaryMainWindow()->view->Doc->pageHeight()*ScCore->primaryMainWindow()->view->Doc->unitRatio());
ScCore->primaryMainWindow()->doc->pdfOptions().bleeds.Bottom = self->bleedb/ScCore->primaryMainWindow()->view->Doc->unitRatio();
}
+ ScCore->primaryMainWindow()->doc->pdfOptions().useLayers = self->useLayers;
+ ScCore->primaryMainWindow()->doc->pdfOptions().embedPDF = self->embedPDF;
+ ScCore->primaryMainWindow()->doc->pdfOptions().MirrorH = self->MirrorH;
+ ScCore->primaryMainWindow()->doc->pdfOptions().MirrorV = self->MirrorV;
+ ScCore->primaryMainWindow()->doc->pdfOptions().doClip = self->doClip;
+ ScCore->primaryMainWindow()->doc->pdfOptions().RotateDeg = PyInt_AsLong(self->RotateDeg);
+ ScCore->primaryMainWindow()->doc->pdfOptions().isGrayscale = self->isGrayscale;
+ ScCore->primaryMainWindow()->doc->pdfOptions().PageLayout = minmaxi(self->PageLayout, 0, 3);
+ ScCore->primaryMainWindow()->doc->pdfOptions().displayBookmarks = self->displayBookmarks;
+ ScCore->primaryMainWindow()->doc->pdfOptions().displayThumbs = self->displayThumbs;
+ ScCore->primaryMainWindow()->doc->pdfOptions().displayLayers = self->displayLayers;
+ ScCore->primaryMainWindow()->doc->pdfOptions().displayFullscreen = self->displayFullscreen;
+ ScCore->primaryMainWindow()->doc->pdfOptions().hideToolBar = self->hideToolBar;
+ ScCore->primaryMainWindow()->doc->pdfOptions().hideMenuBar = self->hideMenuBar;
+ ScCore->primaryMainWindow()->doc->pdfOptions().fitWindow = self->fitWindow;
+ ScCore->primaryMainWindow()->doc->pdfOptions().cropMarks = self->cropMarks;
+ ScCore->primaryMainWindow()->doc->pdfOptions().bleedMarks = self->bleedMarks;
+ ScCore->primaryMainWindow()->doc->pdfOptions().registrationMarks = self->registrationMarks;
+ ScCore->primaryMainWindow()->doc->pdfOptions().colorMarks = self->colorMarks;
+ ScCore->primaryMainWindow()->doc->pdfOptions().docInfoMarks = self->docInfoMarks;
+ ScCore->primaryMainWindow()->doc->pdfOptions().markOffset = self->markOffset;
+ ScCore->primaryMainWindow()->doc->pdfOptions().openAction = QString(PyString_AsString(self->openAction));
+ ScCore->primaryMainWindow()->doc->pdfOptions().firstUse = false;
QString errorMessage;
bool success = ScCore->primaryMainWindow()->getPDFDriver(fn, nam, Components, pageNs, thumbs, errorMessage);
More information about the scribus-commit
mailing list