375
fonts = PyList_New(0);
377
Py_DECREF(self->SubsetList);
378
self->SubsetList = fonts;
380
PyErr_SetString(PyExc_SystemError, "Can not initialize 'SubsetList' attribute");
383
// copied from TabPDFOptions::restoreDefaults()
384
for (int fe = 0; fe < pdfOptions.SubsetList.count(); ++fe)
387
tmp = PyString_FromString(pdfOptions.SubsetList[fe].toLatin1().data());
389
PyList_Append(self->SubsetList, tmp);
393
PyErr_SetString(PyExc_SystemError, "Can not initialize 'SubsetList' attribute");
301
398
// set to print all pages
302
399
PyObject *pages = NULL;
304
401
// which one should I use ???
305
402
// new = ScCore->primaryMainWindow()->view->Pages.count()
306
num = ScCore->primaryMainWindow()->doc->Pages->count();
403
num = currentDoc->Pages->count();
307
404
pages = PyList_New(num);
309
406
PyErr_SetString(PyExc_SystemError, "Can not initialize 'pages' attribute");
322
419
Py_DECREF(self->pages);
323
420
self->pages = pages;
324
// do not print thumbnails
325
self->thumbnails = ScCore->primaryMainWindow()->doc->PDF_Options.Thumbnails;
421
// print thumbnails ?
422
self->thumbnails = pdfOptions.Thumbnails;
423
// output crop marks ?
424
self->cropMarks = pdfOptions.cropMarks;
425
// output bleed marks ?
426
self->bleedMarks = pdfOptions.bleedMarks;
427
// output registration marks ?
428
self->registrationMarks = pdfOptions.registrationMarks;
429
// output color bars ?
430
self->colorMarks = pdfOptions.colorMarks;
431
// output doc info marks ?
432
self->docInfoMarks = pdfOptions.docInfoMarks;
434
self->markOffset = pdfOptions.markOffset * currentDoc->unitRatio();
326
435
// set automatic compression
327
self->compress = ScCore->primaryMainWindow()->doc->PDF_Options.Compress;
328
self->compressmtd = ScCore->primaryMainWindow()->doc->PDF_Options.CompressMethod;
436
self->compress = pdfOptions.Compress;
437
self->compressmtd = pdfOptions.CompressMethod;
329
438
// use maximum image quality
330
self->quality = ScCore->primaryMainWindow()->doc->PDF_Options.Quality;
439
self->quality = pdfOptions.Quality;
331
440
// default resolution
332
441
PyObject *resolution = NULL;
333
442
resolution = PyInt_FromLong(300);
353
self->bookmarks = ScCore->primaryMainWindow()->doc->PDF_Options.Bookmarks;
462
self->bookmarks = pdfOptions.Bookmarks;
354
463
// left margin binding
355
self->binding = ScCore->primaryMainWindow()->doc->PDF_Options.Binding;
464
self->binding = pdfOptions.Binding;
356
465
// do not enable presentation effects
357
self->presentation = ScCore->primaryMainWindow()->doc->PDF_Options.PresentMode;
466
self->presentation = pdfOptions.PresentMode;
358
467
// set effects values for all pages
359
468
PyObject *effval = NULL;
361
470
// which one should I use ???
362
471
// new = ScCore->primaryMainWindow()->view->Pages.count();
363
num = ScCore->primaryMainWindow()->doc->Pages->count();
472
num = currentDoc->Pages->count();
364
473
effval = PyList_New(num);
366
475
PyErr_SetString(PyExc_SystemError, "Can not initialize 'effval' attribute");
369
int num2 = ScCore->primaryMainWindow()->doc->PDF_Options.PresentVals.count();
478
int num2 = pdfOptions.PresentVals.count();
370
479
for (i = 0; i<num2; ++i) {
372
PDFPresentationData t = ScCore->primaryMainWindow()->doc->PDF_Options.PresentVals[i];
481
PDFPresentationData t = pdfOptions.PresentVals[i];
373
482
tmp = Py_BuildValue(const_cast<char*>("[iiiiii]"), t.pageEffectDuration, t.pageViewDuration, t.effectType, t.Dm, t.M, t.Di );
375
484
PyList_SetItem(effval, i, tmp);
391
500
Py_DECREF(self->effval);
392
501
self->effval = effval;
393
502
// do not save linked text frames as PDF article
394
self->article = ScCore->primaryMainWindow()->doc->PDF_Options.Articles;
503
self->article = pdfOptions.Articles;
395
504
// do not encrypt file
396
self->encrypt = ScCore->primaryMainWindow()->doc->PDF_Options.Encrypt;
505
self->encrypt = pdfOptions.Encrypt;
397
506
// do not Use Custom Rendering Settings
398
self->uselpi = ScCore->primaryMainWindow()->doc->PDF_Options.UseLPI;
399
self->usespot = ScCore->primaryMainWindow()->doc->PDF_Options.UseSpotColors;
400
self->domulti = ScCore->primaryMainWindow()->doc->PDF_Options.doMultiFile;
507
self->uselpi = pdfOptions.UseLPI;
508
self->usespot = pdfOptions.UseSpotColors;
509
self->domulti = pdfOptions.doMultiFile;
401
510
// get default values for lpival
402
int n = ScCore->primaryMainWindow()->doc->PDF_Options.LPISettings.size();
511
int n = pdfOptions.LPISettings.size();
403
512
PyObject *lpival=PyList_New(n);
405
514
PyErr_SetString(PyExc_SystemError, "Can not initialize 'lpival' attribute");
408
QMap<QString,LPIData>::Iterator it = ScCore->primaryMainWindow()->doc->PDF_Options.LPISettings.begin();
409
while (it != ScCore->primaryMainWindow()->doc->PDF_Options.LPISettings.end()) {
517
QMap<QString,LPIData>::Iterator it = pdfOptions.LPISettings.begin();
518
while (it != pdfOptions.LPISettings.end()) {
411
520
tmp = Py_BuildValue(const_cast<char*>("[siii]"), it.key().toAscii().constData(), it.value().Frequency, it.value().Angle, it.value().SpotFunc);
442
551
// allow printing document
443
self->aprint = ScCore->primaryMainWindow()->doc->PDF_Options.Permissions & 4;
552
self->aprint = pdfOptions.Permissions & 4;
444
553
// allow changing document
445
self->achange = ScCore->primaryMainWindow()->doc->PDF_Options.Permissions & 8;
554
self->achange = pdfOptions.Permissions & 8;
446
555
// allow copying document
447
self->acopy = ScCore->primaryMainWindow()->doc->PDF_Options.Permissions & 16;
556
self->acopy = pdfOptions.Permissions & 16;
448
557
// allow adding annotation and fields
449
self->aanot = ScCore->primaryMainWindow()->doc->PDF_Options.Permissions & 32;
558
self->aanot = pdfOptions.Permissions & 32;
450
559
// use 1.4 pdf version *aka. Acrobat 5)
451
self->version = ScCore->primaryMainWindow()->doc->PDF_Options.Version;
560
self->version = pdfOptions.Version;
452
561
// output destination is screen
453
self->outdst = ScCore->primaryMainWindow()->doc->PDF_Options.UseRGB ? 0 : 1;
562
self->outdst = pdfOptions.UseRGB ? 0 : 1;
455
self->profiles = ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles; // bool
456
self->profilei = ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles2; // bool
457
self->noembicc = ScCore->primaryMainWindow()->doc->PDF_Options.EmbeddedI; // bool
458
self->intents = ScCore->primaryMainWindow()->doc->PDF_Options.Intent; // int - 0 - 3
459
self->intenti = ScCore->primaryMainWindow()->doc->PDF_Options.Intent2; // int - 0 - 3
460
QString tp = ScCore->primaryMainWindow()->doc->PDF_Options.SolidProf;
564
self->profiles = pdfOptions.UseProfiles; // bool
565
self->profilei = pdfOptions.UseProfiles2; // bool
566
self->noembicc = pdfOptions.EmbeddedI; // bool
567
self->intents = pdfOptions.Intent; // int - 0 - 3
568
self->intenti = pdfOptions.Intent2; // int - 0 - 3
569
QString tp = pdfOptions.SolidProf;
461
570
if (!ScCore->InputProfiles.contains(tp))
462
tp = ScCore->primaryMainWindow()->view->Doc->CMSSettings.DefaultSolidColorRGBProfile;
571
tp = currentDoc->CMSSettings.DefaultSolidColorRGBProfile;
463
572
PyObject *solidpr = NULL;
464
573
solidpr = PyString_FromString(tp.toAscii());
503
612
PyErr_SetString(PyExc_SystemError, "Can not initialize 'info' attribute");
506
self->bleedt = ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Top*ScCore->primaryMainWindow()->doc->unitRatio(); // double -
507
self->bleedl = ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Left*ScCore->primaryMainWindow()->doc->unitRatio(); // double -
508
self->bleedr = ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Right*ScCore->primaryMainWindow()->doc->unitRatio(); // double -
509
self->bleedb = ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Bottom*ScCore->primaryMainWindow()->doc->unitRatio(); // double -
615
self->bleedt = pdfOptions.bleeds.Top * currentDoc->unitRatio(); // double -
616
self->bleedl = pdfOptions.bleeds.Left * currentDoc->unitRatio(); // double -
617
self->bleedr = pdfOptions.bleeds.Right * currentDoc->unitRatio(); // double -
618
self->bleedb = pdfOptions.bleeds.Bottom * currentDoc->unitRatio(); // double -
619
self->usedocbleeds = 0; // bool
620
self->useLayers = pdfOptions.useLayers; // bool
621
self->embedPDF = pdfOptions.embedPDF; // bool
622
self->mirrorH = pdfOptions.MirrorH; // bool
623
self->mirrorV = pdfOptions.MirrorV; // bool
624
self->doClip = pdfOptions.doClip; // bool
625
PyObject *RotateDeg = NULL;
626
RotateDeg = PyInt_FromLong(0);
628
Py_DECREF(self->RotateDeg);
629
self->RotateDeg = RotateDeg;
631
PyErr_SetString(PyExc_SystemError, "Can not initialize 'RotateDeg' attribute");
634
self->isGrayscale = pdfOptions.isGrayscale; // bool
635
self->pageLayout = pdfOptions.PageLayout; // int
636
self->displayBookmarks = pdfOptions.displayBookmarks; // bool
637
self->displayThumbs = pdfOptions.displayThumbs; // bool
638
self->displayLayers = pdfOptions.displayLayers; // bool
639
self->displayFullscreen = pdfOptions.displayFullscreen; // bool
640
self->hideToolBar = pdfOptions.hideToolBar; // bool
641
self->hideMenuBar = pdfOptions.hideMenuBar; // bool
642
self->fitWindow = pdfOptions.fitWindow; // bool
644
PyObject *openAction = NULL;
645
openAction = PyString_FromString(pdfOptions.openAction.toLatin1().data());
647
Py_DECREF(self->openAction);
648
self->openAction = openAction;
650
PyErr_SetString(PyExc_SystemError, "Can not initialize 'openAction' attribute");
514
657
static PyMemberDef PDFfile_members[] = {
515
658
{const_cast<char*>("thumbnails"), T_INT, offsetof(PDFfile, thumbnails), 0, const_cast<char*>("Generate thumbnails. Bool value.")},
659
{const_cast<char*>("cropMarks"), T_INT, offsetof(PDFfile, cropMarks), 0, const_cast<char*>("Create crop marks in the PDF indicating where the paper should be cut or trimmed after printing.")},
660
{const_cast<char*>("bleedMarks"), T_INT, offsetof(PDFfile, bleedMarks), 0, const_cast<char*>("Create marks delimiting the bleed area.")},
661
{const_cast<char*>("registrationMarks"), T_INT, offsetof(PDFfile, registrationMarks), 0, const_cast<char*>("Add registration marks to each separation.")},
662
{const_cast<char*>("colorMarks"), T_INT, offsetof(PDFfile, colorMarks), 0, const_cast<char*>("Add color calibration bars.")},
663
{const_cast<char*>("docInfoMarks"), T_INT, offsetof(PDFfile, docInfoMarks), 0, const_cast<char*>("Add document information which includes the document title and page numbers.")},
664
{const_cast<char*>("markOffset"), T_DOUBLE, offsetof(PDFfile, markOffset), 0, const_cast<char*>("Indicate the distance offset between mark and page area.")},
516
665
{const_cast<char*>("compress"), T_INT, offsetof(PDFfile, compress), 0, const_cast<char*>("Compression switch. Bool value.")},
517
666
{const_cast<char*>("compressmtd"), T_INT, offsetof(PDFfile, compressmtd), 0, const_cast<char*>("Compression method.\n\t0 - Automatic\n\t1 - JPEG\n\t2 - zip\n\t3 - None.")},
518
667
{const_cast<char*>("quality"), T_INT, offsetof(PDFfile, quality), 0, const_cast<char*>("Image quality\n\t0 - Maximum\n\t1 - High\n\t2 - Medium\n\t3 - Low\n\t4 - Minimum")},
539
688
{const_cast<char*>("bleedl"), T_DOUBLE, offsetof(PDFfile, bleedl), 0, const_cast<char*>("Bleed Left\n""Distance for bleed from the left of the physical page")},
540
689
{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")},
541
690
{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")},
691
{const_cast<char*>("usedocbleeds"), T_INT, offsetof(PDFfile, usedocbleeds), 0, const_cast<char*>("Use the existing bleed settings from the document preferences. Bool value")},
692
{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.")},
693
{const_cast<char*>("embedPDF"), T_INT, offsetof(PDFfile, embedPDF), 0, const_cast<char*>("Export EPS and 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'.")},
694
{const_cast<char*>("mirrorH"), T_INT, offsetof(PDFfile, mirrorH), 0, const_cast<char*>("Mirror Page(s) horizontally")},
695
{const_cast<char*>("mirrorV"), T_INT, offsetof(PDFfile, mirrorV), 0, const_cast<char*>("Mirror Page(s) vertically")},
696
{const_cast<char*>("doClip"), T_INT, offsetof(PDFfile, doClip), 0, const_cast<char*>("Do not show objects outside the margins in the exported file")},
697
{const_cast<char*>("isGrayscale"), T_INT, offsetof(PDFfile, isGrayscale), 0, const_cast<char*>("Export PDF in grayscale")},
698
{const_cast<char*>("pageLayout"), T_INT, offsetof(PDFfile, pageLayout), 0, const_cast<char*>("Document layout in PDF viewer:\n"
699
"\t0 - Show the document in single page mode\n"
700
"\t1 - Show the document in single page mode with the pages displayed continuously end to end like a scroll\n"
701
"\t2 - Show the document with facing pages, starting with the first page displayed on the left\n"
702
"\t3 - Show the document with facing pages, starting with the first page displayed on the right"
704
{const_cast<char*>("displayBookmarks"), T_INT, offsetof(PDFfile, displayBookmarks), 0, const_cast<char*>("Display the bookmarks upon opening")},
705
{const_cast<char*>("displayThumbs"), T_INT, offsetof(PDFfile, displayThumbs), 0, const_cast<char*>("Display the page thumbnails upon opening")},
706
{const_cast<char*>("displayLayers"), T_INT, offsetof(PDFfile, displayLayers), 0, const_cast<char*>("Display the layer list upon opening. Useful only for PDF 1.5+.")},
707
{const_cast<char*>("displayFullscreen"), T_INT, offsetof(PDFfile, displayFullscreen), 0, const_cast<char*>("Display the document in full screen mode upon opening.")},
708
{const_cast<char*>("hideToolBar"), T_INT, offsetof(PDFfile, hideToolBar), 0, const_cast<char*>("Hide the viewer toolbar. The toolbar has usually selection and other editing capabilities.")},
709
{const_cast<char*>("hideMenuBar"), T_INT, offsetof(PDFfile, hideMenuBar), 0, const_cast<char*>("Hide the viewer menu bar, the PDF will display in a plain window.")},
710
{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.")},
542
711
{NULL, 0, 0, 0, NULL} // sentinel
772
static PyObject *PDFfile_getSubsetList(PDFfile *self, void * /*closure*/)
774
Py_INCREF(self->SubsetList);
775
return self->SubsetList;
778
static int PDFfile_setSubsetList(PDFfile *self, PyObject *value, void * /*closure*/)
781
PyErr_SetString(PyExc_TypeError, "Cannot delete 'SubsetList' attribute.");
784
if (!PyList_Check(value)) {
785
PyErr_SetString(PyExc_TypeError, "The 'SubsetList' attribute value must be list of strings.");
789
n = PyList_Size(value);
790
for (int i=0; i<n; ++i)
791
if (!PyString_Check(PyList_GetItem(value, i))) {
792
PyErr_SetString(PyExc_TypeError, "The 'SubsetList' list must contain only strings.");
795
Py_DECREF(self->SubsetList);
797
self->SubsetList = value;
798
PyList_Sort(self->SubsetList);
603
802
static PyObject *PDFfile_getpages(PDFfile *self, void * /*closure*/)
605
804
Py_INCREF(self->pages);
1114
static PyObject *PDFfile_getRotateDeg(PDFfile *self, void * /*closure*/)
1116
Py_INCREF(self->RotateDeg);
1117
return self->RotateDeg;
1120
static int PDFfile_setRotateDeg(PDFfile *self, PyObject *value, void * /*closure*/)
1122
if (value == NULL) {
1123
PyErr_SetString(PyExc_TypeError, "Cannot delete 'RotateDeg' attribute.");
1126
if (!PyInt_Check(value)) {
1127
PyErr_SetString(PyExc_TypeError, "'RotateDeg' attribute value must be integer.");
1130
int n = PyInt_AsLong(value);
1131
if (n!=0 && n!=90 && n!=180 && n!=270) {
1132
PyErr_SetString(PyExc_TypeError, "'RotateDeg' value must be 0 or 90 or 180 or 270");
1135
Py_DECREF(self->RotateDeg);
1137
self->RotateDeg = value;
1141
static PyObject *PDFfile_getopenAction(PDFfile *self, void * /*closure*/)
1143
Py_INCREF(self->openAction);
1144
return self->openAction;
1147
static int PDFfile_setopenAction(PDFfile *self, PyObject *value, void * /*closure*/)
1149
if (value == NULL) {
1150
PyErr_SetString(PyExc_TypeError, "Cannot delete 'openAction' attribute.");
1153
if (!PyString_Check(value)) {
1154
PyErr_SetString(PyExc_TypeError, "'openAction' attribute value must be string.");
1157
Py_DECREF(self->openAction);
1159
self->openAction = value;
915
1163
static char *effval_doc = const_cast<char*>(
916
1164
"List of effection values for each saved page.\n"
917
1165
"It is list of list of six integers. Those int has followin meaning:\n\t"
935
1183
static PyGetSetDef PDFfile_getseters [] = {
936
1184
{const_cast<char*>("file"), (getter)PDFfile_getfile, (setter)PDFfile_setfile, const_cast<char*>("Name of file to save into"), NULL},
937
1185
{const_cast<char*>("fonts"), (getter)PDFfile_getfonts, (setter)PDFfile_setfonts, const_cast<char*>("List of fonts to embed."), NULL},
1186
{const_cast<char*>("SubsetList"), (getter)PDFfile_getSubsetList, (setter)PDFfile_setSubsetList, const_cast<char*>("List of fonts to outlined."), NULL},
938
1187
{const_cast<char*>("pages"), (getter)PDFfile_getpages, (setter)PDFfile_setpages, const_cast<char*>("List of pages to print"), NULL},
939
1188
{const_cast<char*>("resolution"), (getter)PDFfile_getresolution, (setter)PDFfile_setresolution, const_cast<char*>("Resolution of output file. Values from 35 to 4000."), NULL},
940
1189
{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},
946
1195
{const_cast<char*>("imagepr"), (getter)PDFfile_getimagepr, (setter)PDFfile_setimagepr, const_cast<char*>("Color profile for images"), NULL},
947
1196
{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},
948
1197
{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},
1198
{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},
1199
{const_cast<char*>("openAction"), (getter)PDFfile_getopenAction, (setter)PDFfile_setopenAction, const_cast<char*>("Javascript to be executed when PDF document is opened."), NULL},
949
1200
{NULL, NULL, NULL, NULL, NULL} // sentinel
1210
ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
1211
PDFOptions& pdfOptions = currentDoc->PDF_Options;
959
1213
// copied from file scribus.cpp
960
1214
//void ScribusMainWindow::SaveAsPDF()
961
1215
int Components = 3;
962
1216
QString nam = "";
963
1217
if (ScCore->primaryMainWindow()->bookmarkPalette->BView->topLevelItemCount() == 0)
964
ScCore->primaryMainWindow()->doc->PDF_Options.Bookmarks = false;
1218
pdfOptions.Bookmarks = false;
966
1220
// apply fonts attribute
967
ScCore->primaryMainWindow()->doc->PDF_Options.EmbedList.clear();
1221
pdfOptions.EmbedList.clear();
968
1222
int n = PyList_Size(self->fonts);
969
1223
for ( int i=0; i<n; ++i){
971
1225
tmpFon = QString(PyString_AsString(PyList_GetItem(self->fonts, i)));
972
ScCore->primaryMainWindow()->doc->PDF_Options.EmbedList.append(tmpFon);
1226
pdfOptions.EmbedList.append(tmpFon);
1228
// apply SubsetList attribute
1229
pdfOptions.SubsetList.clear();
1230
n = PyList_Size(self->SubsetList);
1231
for ( int i=0; i<n; ++i){
1233
tmpFon = QString(PyString_AsString(PyList_GetItem(self->SubsetList, i)));
1234
pdfOptions.SubsetList.append(tmpFon);
974
1236
// apply file attribute
976
1238
fn = QString(PyString_AsString(self->file));
977
ScCore->primaryMainWindow()->doc->PDF_Options.fileName = fn;
1239
pdfOptions.fileName = fn;
978
1240
// apply pages attribute
979
1241
std::vector<int> pageNs;
980
1242
int nn=PyList_Size(self->pages);
982
1244
pageNs.push_back((int)PyInt_AsLong(PyList_GetItem(self->pages, i)));
984
1246
// apply thumbnails attribute
985
ScCore->primaryMainWindow()->doc->PDF_Options.Thumbnails = self->thumbnails;
1247
pdfOptions.Thumbnails = self->thumbnails;
1248
// apply cropmarks attribute
1249
pdfOptions.cropMarks = self->cropMarks;
1250
// apply bleedmarks attribute
1251
pdfOptions.bleedMarks = self->bleedMarks;
1252
// apply registrationmarks attribute
1253
pdfOptions.registrationMarks = self->registrationMarks;
1254
// apply colormarks attribute
1255
pdfOptions.colorMarks = self->colorMarks;
1256
// apply docInfoMark attribute
1257
pdfOptions.docInfoMarks = self->docInfoMarks;
1258
// apply mark offset attribute
1259
pdfOptions.markOffset = qMax(0.0, self->markOffset / currentDoc->unitRatio());
986
1260
// apply compress attribute
987
1261
self->compressmtd = minmaxi(self->compressmtd, 0, 3);
988
ScCore->primaryMainWindow()->doc->PDF_Options.Compress = self->compress;
989
ScCore->primaryMainWindow()->doc->PDF_Options.CompressMethod = (PDFOptions::PDFCompression) self->compressmtd;
1262
pdfOptions.Compress = self->compress;
1263
pdfOptions.CompressMethod = (PDFOptions::PDFCompression) self->compressmtd;
990
1264
// apply quality attribute
991
1265
self->quality = minmaxi(self->quality, 0, 4);
992
ScCore->primaryMainWindow()->doc->PDF_Options.Quality = self->quality;
1266
pdfOptions.Quality = self->quality;
993
1267
// apply resolusion attribute
994
ScCore->primaryMainWindow()->doc->PDF_Options.Resolution = PyInt_AsLong(self->resolution);
1268
pdfOptions.Resolution = PyInt_AsLong(self->resolution);
995
1269
// apply downsample attribute
996
ScCore->primaryMainWindow()->doc->PDF_Options.RecalcPic = PyInt_AsLong(self->downsample);
997
if (ScCore->primaryMainWindow()->doc->PDF_Options.RecalcPic)
998
ScCore->primaryMainWindow()->doc->PDF_Options.PicRes = PyInt_AsLong(self->downsample);
1270
pdfOptions.RecalcPic = PyInt_AsLong(self->downsample);
1271
if (pdfOptions.RecalcPic)
1272
pdfOptions.PicRes = PyInt_AsLong(self->downsample);
1000
ScCore->primaryMainWindow()->doc->PDF_Options.PicRes = ScCore->primaryMainWindow()->doc->PDF_Options.Resolution;
1274
pdfOptions.PicRes = pdfOptions.Resolution;
1001
1275
// apply bookmarks attribute
1002
ScCore->primaryMainWindow()->doc->PDF_Options.Bookmarks = self->bookmarks;
1276
pdfOptions.Bookmarks = self->bookmarks;
1003
1277
// apply binding attribute
1004
ScCore->primaryMainWindow()->doc->PDF_Options.Binding = self->binding;
1278
pdfOptions.Binding = self->binding;
1005
1279
// apply presentation attribute
1006
ScCore->primaryMainWindow()->doc->PDF_Options.PresentMode = self->presentation;
1280
pdfOptions.PresentMode = self->presentation;
1008
1282
QList<PDFPresentationData> PresentVals;
1009
1283
PresentVals.clear();
1049
1323
// PyErr_SetString(PyExc_SystemError, "while parsing 'lpival'. WHY THIS HAPPENED????");
1050
1324
// return NULL;
1052
// ScCore->primaryMainWindow()->doc->PDF_Options.LPISettings[QString(s)]=lpi;
1326
// pdfOptions.LPISettings[QString(s)]=lpi;
1054
1328
st = QString(PyString_AsString(PyList_GetItem(t,0)));
1055
1329
lpi.Frequency = PyInt_AsLong(PyList_GetItem(t, 1));
1056
1330
lpi.Angle = PyInt_AsLong(PyList_GetItem(t, 2));
1057
1331
lpi.SpotFunc = PyInt_AsLong(PyList_GetItem(t, 3));
1058
ScCore->primaryMainWindow()->doc->PDF_Options.LPISettings[st]=lpi;
1332
pdfOptions.LPISettings[st]=lpi;
1061
ScCore->primaryMainWindow()->doc->PDF_Options.Articles = self->article;
1062
ScCore->primaryMainWindow()->doc->PDF_Options.Encrypt = self->encrypt;
1063
ScCore->primaryMainWindow()->doc->PDF_Options.UseLPI = self->uselpi;
1064
ScCore->primaryMainWindow()->doc->PDF_Options.UseSpotColors = self->usespot;
1065
ScCore->primaryMainWindow()->doc->PDF_Options.doMultiFile = self->domulti;
1066
self->version = minmaxi(self->version, 12, 14);
1335
pdfOptions.Articles = self->article;
1336
pdfOptions.Encrypt = self->encrypt;
1337
pdfOptions.UseLPI = self->uselpi;
1338
pdfOptions.UseSpotColors = self->usespot;
1339
pdfOptions.doMultiFile = self->domulti;
1340
self->version = minmaxi(self->version, 11, 15);
1067
1341
// FIXME: Sanity check version
1068
ScCore->primaryMainWindow()->doc->PDF_Options.Version = (PDFOptions::PDFVersion)self->version;
1342
pdfOptions.Version = (PDFOptions::PDFVersion)self->version;
1069
1343
if (self->encrypt)
1071
1345
int Perm = -64;
1072
if (ScCore->primaryMainWindow()->doc->PDF_Options.Version == PDFOptions::PDFVersion_14)
1346
if (pdfOptions.Version == PDFOptions::PDFVersion_14)
1073
1347
Perm &= ~0x00240000;
1074
1348
if (self->aprint)
1080
1354
if (self->aanot)
1082
ScCore->primaryMainWindow()->doc->PDF_Options.Permissions = Perm;
1083
ScCore->primaryMainWindow()->doc->PDF_Options.PassOwner = QString(PyString_AsString(self->owner));
1084
ScCore->primaryMainWindow()->doc->PDF_Options.PassUser = QString(PyString_AsString(self->user));
1356
pdfOptions.Permissions = Perm;
1357
pdfOptions.PassOwner = QString(PyString_AsString(self->owner));
1358
pdfOptions.PassUser = QString(PyString_AsString(self->user));
1086
1360
if (self->outdst == 0)
1088
ScCore->primaryMainWindow()->doc->PDF_Options.UseRGB = true;
1089
ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles = false;
1090
ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles2 = false;
1362
pdfOptions.UseRGB = true;
1363
pdfOptions.UseProfiles = false;
1364
pdfOptions.UseProfiles2 = false;
1094
ScCore->primaryMainWindow()->doc->PDF_Options.UseRGB = false;
1095
if (ScCore->primaryMainWindow()->doc->HasCMS)
1368
pdfOptions.UseRGB = false;
1369
if (currentDoc->HasCMS)
1097
ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles = self->profiles;
1098
ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles2 = self->profilei;
1371
pdfOptions.UseProfiles = self->profiles;
1372
pdfOptions.UseProfiles2 = self->profilei;
1099
1373
self->intents = minmaxi(self->intents, 0, 3);
1100
ScCore->primaryMainWindow()->doc->PDF_Options.Intent = self->intents;
1374
pdfOptions.Intent = self->intents;
1101
1375
self->intenti = minmaxi(self->intenti, 0, 3);
1102
ScCore->primaryMainWindow()->doc->PDF_Options.Intent2 = self->intenti;
1103
ScCore->primaryMainWindow()->doc->PDF_Options.EmbeddedI = self->noembicc;
1104
ScCore->primaryMainWindow()->doc->PDF_Options.SolidProf = PyString_AsString(self->solidpr);
1105
ScCore->primaryMainWindow()->doc->PDF_Options.ImageProf = PyString_AsString(self->imagepr);
1106
ScCore->primaryMainWindow()->doc->PDF_Options.PrintProf = PyString_AsString(self->printprofc);
1107
if (ScCore->primaryMainWindow()->doc->PDF_Options.Version == PDFOptions::PDFVersion_X1a ||
1108
ScCore->primaryMainWindow()->doc->PDF_Options.Version == PDFOptions::PDFVersion_X3)
1376
pdfOptions.Intent2 = self->intenti;
1377
pdfOptions.EmbeddedI = self->noembicc;
1378
pdfOptions.SolidProf = PyString_AsString(self->solidpr);
1379
pdfOptions.ImageProf = PyString_AsString(self->imagepr);
1380
pdfOptions.PrintProf = PyString_AsString(self->printprofc);
1381
if (pdfOptions.Version == PDFOptions::PDFVersion_X1a ||
1382
pdfOptions.Version == PDFOptions::PDFVersion_X3)
1110
1384
// Where does compiler find cms function when I have not included header for it
1111
1385
ScColorProfile hIn;
1112
hIn = ScColorMgmtEngine::openProfileFromFile(ScCore->PrinterProfiles[ScCore->primaryMainWindow()->doc->PDF_Options.PrintProf]);
1386
hIn = ScColorMgmtEngine::openProfileFromFile(ScCore->PrinterProfiles[pdfOptions.PrintProf]);
1113
1387
nam = hIn.productDescription();
1114
1388
if (hIn.colorSpace() == ColorSpace_Rgb)
1115
1389
Components = 3;
1117
1391
Components = 4;
1118
1392
if (hIn.colorSpace() == ColorSpace_Gray)
1119
1393
Components = 3;
1120
ScCore->primaryMainWindow()->doc->PDF_Options.Info = PyString_AsString(self->info);
1121
self->bleedt = minmaxd(self->bleedt, 0, ScCore->primaryMainWindow()->view->Doc->pageHeight*ScCore->primaryMainWindow()->view->Doc->unitRatio());
1122
ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Top = self->bleedt/ScCore->primaryMainWindow()->view->Doc->unitRatio();
1123
self->bleedl = minmaxd(self->bleedl, 0, ScCore->primaryMainWindow()->view->Doc->pageWidth*ScCore->primaryMainWindow()->view->Doc->unitRatio());
1124
ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Left = self->bleedl/ScCore->primaryMainWindow()->view->Doc->unitRatio();
1125
self->bleedr = minmaxd(self->bleedr, 0, ScCore->primaryMainWindow()->view->Doc->pageWidth*ScCore->primaryMainWindow()->view->Doc->unitRatio());
1126
ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Right = self->bleedr/ScCore->primaryMainWindow()->view->Doc->unitRatio();
1127
self->bleedb = minmaxd(self->bleedb, 0, ScCore->primaryMainWindow()->view->Doc->pageHeight*ScCore->primaryMainWindow()->view->Doc->unitRatio());
1128
ScCore->primaryMainWindow()->doc->PDF_Options.bleeds.Bottom = self->bleedb/ScCore->primaryMainWindow()->view->Doc->unitRatio();
1129
ScCore->primaryMainWindow()->doc->PDF_Options.Encrypt = false;
1130
ScCore->primaryMainWindow()->doc->PDF_Options.PresentMode = false;
1394
pdfOptions.Info = PyString_AsString(self->info);
1395
pdfOptions.Encrypt = false;
1396
pdfOptions.PresentMode = false;
1135
ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles = false;
1136
ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles2 = false;
1401
pdfOptions.UseProfiles = false;
1402
pdfOptions.UseProfiles2 = false;
1141
1407
for (uint ap = 0; ap < pageNs.size(); ++ap)
1143
1409
QPixmap pm(10,10);
1144
if (ScCore->primaryMainWindow()->doc->PDF_Options.Thumbnails)
1410
if (pdfOptions.Thumbnails)
1145
1411
pm = QPixmap::fromImage(ScCore->primaryMainWindow()->view->PageToPixmap(pageNs[ap]-1, 100));
1146
1412
thumbs.insert(pageNs[ap], pm);
1148
ReOrderText(ScCore->primaryMainWindow()->doc, ScCore->primaryMainWindow()->view);
1414
ReOrderText(currentDoc, ScCore->primaryMainWindow()->view);
1416
MarginStruct optBleeds(pdfOptions.bleeds);
1417
pdfOptions.useDocBleeds = self->usedocbleeds;
1418
if (self->usedocbleeds)
1419
pdfOptions.bleeds = currentDoc->bleeds;
1421
self->bleedt = minmaxd(self->bleedt, 0, currentDoc->pageHeight * currentDoc->unitRatio());
1422
pdfOptions.bleeds.Top = self->bleedt / currentDoc->unitRatio();
1423
self->bleedl = minmaxd(self->bleedl, 0, currentDoc->pageWidth * currentDoc->unitRatio());
1424
pdfOptions.bleeds.Left = self->bleedl / currentDoc->unitRatio();
1425
self->bleedr = minmaxd(self->bleedr, 0, currentDoc->pageWidth * currentDoc->unitRatio());
1426
pdfOptions.bleeds.Right = self->bleedr / currentDoc->unitRatio();
1427
self->bleedb = minmaxd(self->bleedb, 0, currentDoc->pageHeight * currentDoc->unitRatio());
1428
pdfOptions.bleeds.Bottom = self->bleedb / currentDoc->unitRatio();
1430
pdfOptions.useLayers = self->useLayers;
1431
pdfOptions.embedPDF = self->embedPDF;
1432
pdfOptions.MirrorH = self->mirrorH;
1433
pdfOptions.MirrorV = self->mirrorV;
1434
pdfOptions.doClip = self->doClip;
1435
pdfOptions.RotateDeg = PyInt_AsLong(self->RotateDeg);
1436
pdfOptions.isGrayscale = self->isGrayscale;
1437
pdfOptions.PageLayout = minmaxi(self->pageLayout, 0, 3);
1438
pdfOptions.displayBookmarks = self->displayBookmarks;
1439
pdfOptions.displayThumbs = self->displayThumbs;
1440
pdfOptions.displayLayers = self->displayLayers;
1441
pdfOptions.displayFullscreen = self->displayFullscreen;
1442
pdfOptions.hideToolBar = self->hideToolBar;
1443
pdfOptions.hideMenuBar = self->hideMenuBar;
1444
pdfOptions.fitWindow = self->fitWindow;
1445
pdfOptions.openAction = QString(PyString_AsString(self->openAction));
1446
pdfOptions.firstUse = false;
1149
1448
QString errorMessage;
1150
if (!ScCore->primaryMainWindow()->getPDFDriver(fn, nam, Components, pageNs, thumbs, errorMessage)) {
1449
bool success = ScCore->primaryMainWindow()->getPDFDriver(fn, nam, Components, pageNs, thumbs, errorMessage);
1151
1451
fn = "Cannot write the File: " + fn;
1152
1452
if (!errorMessage.isEmpty())
1153
1453
fn += QString("\n%1").arg(errorMessage);
1154
1454
PyErr_SetString(PyExc_SystemError, fn.toAscii());
1157
// Py_INCREF(Py_None);
1457
if (self->usedocbleeds || (pdfOptions.Version != PDFOptions::PDFVersion_X1a &&
1458
pdfOptions.Version != PDFOptions::PDFVersion_X3))
1459
pdfOptions.bleeds = optBleeds;
1162
1466
static PyMethodDef PDFfile_methods[] = {