~ubuntu-branches/debian/sid/scribus/sid

« back to all changes in this revision

Viewing changes to scribus/plugins/scriptplugin/objpdffile.cpp

  • Committer: Package Import Robot
  • Author(s): Mattia Rizzolo
  • Date: 2015-07-28 12:27:49 UTC
  • mfrom: (1.2.1) (20.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20150728122749-qa6ptt1t5p5x05ix
Tags: 1.4.5+dfsg1-1
* [9185477] Imported Upstream version 1.4.5+dfsg1.
  + This removes several non-dfsg files.
* [38cb2ce,bf61884] debian/rules: properly exclude the plugins from
  dh_fixperms.  Thanks to Philip Muskovac for the idea.
* [c370e55] debian/copyright: exclude some non-free files from the packaging.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        PyObject_HEAD
48
48
        PyObject *file; // string - file to save into
49
49
        PyObject *fonts; // list of string - fonts to  embed
 
50
        PyObject *SubsetList; // list of string - fonts to outline
50
51
        PyObject *pages; // list of int - pages to print
51
52
        int thumbnails; // bool -
 
53
        int cropMarks; // bool -
 
54
        int bleedMarks; // bool -
 
55
        int registrationMarks; // bool -
 
56
        int colorMarks; // bool -
 
57
        int docInfoMarks; // bool -
 
58
        double markOffset; // double -
52
59
        int compress; // bool -
53
60
        int compressmtd; // int - 0=automatic 1=jpeg 2=zip 3=none
54
61
        int quality; // int - 0=Maximum 4=minimum
86
93
        double bleedl; // double - 0 to width of page
87
94
        double bleedr; // double - 0 to width of page
88
95
        double bleedb; // double - 0 to hight of page
 
96
        int usedocbleeds; // bool
 
97
        int useLayers;
 
98
        int embedPDF;
 
99
        int mirrorH;
 
100
        int mirrorV;
 
101
        int doClip;
 
102
        PyObject * RotateDeg; // int
 
103
        int isGrayscale;
 
104
        int pageLayout;
 
105
        int displayBookmarks;
 
106
        int displayThumbs;
 
107
        int displayLayers;
 
108
        int displayFullscreen;
 
109
        int hideToolBar;
 
110
        int hideMenuBar;
 
111
        int fitWindow;
 
112
        PyObject *openAction;
89
113
 
90
114
} PDFfile;
91
115
 
93
117
{
94
118
        Py_XDECREF(self->file);
95
119
        Py_XDECREF(self->fonts);
 
120
        Py_XDECREF(self->SubsetList);
96
121
        Py_XDECREF(self->pages);
97
122
        Py_XDECREF(self->resolution);
98
123
        Py_XDECREF(self->downsample);
104
129
        Py_XDECREF(self->imagepr);
105
130
        Py_XDECREF(self->printprofc);
106
131
        Py_XDECREF(self->info);
 
132
        Py_XDECREF(self->RotateDeg);
 
133
        Py_XDECREF(self->openAction);
107
134
        self->ob_type->tp_free((PyObject *)self);
108
135
}
109
136
 
131
158
                        Py_DECREF(self);
132
159
                        return NULL;
133
160
                }
 
161
                self->SubsetList = PyList_New(0);
 
162
                if (!self->SubsetList){
 
163
                        Py_DECREF(self);
 
164
                        return NULL;
 
165
                }
134
166
// set pages attribute
135
167
                self->pages = PyList_New(0);
136
168
                if (self->pages == NULL){
139
171
                }
140
172
// set thumbnails attribute
141
173
                self->thumbnails = 0;
 
174
// set cropMarks attribute
 
175
                self->cropMarks = 0;
 
176
// set bleedMarks attribute
 
177
                self->bleedMarks = 0;
 
178
// set registrationMarks attribute
 
179
                self->registrationMarks = 0;
 
180
// set colorMarks attribute
 
181
                self->colorMarks = 0;
 
182
// set docInfoMarks attribute
 
183
                self->docInfoMarks = 0;
 
184
// set mark offset attribute
 
185
                self->markOffset = 0;
142
186
// set compress attribute
143
187
                self->compress = 0;
144
188
// set compressmtd attribute
238
282
                self->bleedl = 0; // double -
239
283
                self->bleedr = 0; // double -
240
284
                self->bleedb = 0; // double -
 
285
                self->usedocbleeds = 0; // bool
 
286
                self->useLayers = 0;
 
287
                self->embedPDF = 0;
 
288
                self->mirrorH = 0;
 
289
                self->mirrorV = 0;
 
290
                self->doClip = 0;
 
291
                self->RotateDeg = PyInt_FromLong(0);
 
292
                if (!self->RotateDeg){
 
293
                        Py_DECREF(self);
 
294
                        return NULL;
 
295
                }
 
296
                self->isGrayscale = 0;
 
297
                self->pageLayout = 0;
 
298
                self->displayBookmarks = 0;
 
299
                self->displayThumbs = 0;
 
300
                self->displayLayers = 0;
 
301
                self->displayFullscreen = 0;
 
302
                self->hideToolBar = 0;
 
303
                self->hideMenuBar = 0;
 
304
                self->fitWindow = 0;
 
305
                self->openAction = PyString_FromString("");
 
306
                if (!self->openAction){
 
307
                        Py_DECREF(self);
 
308
                        return NULL;
 
309
                }
241
310
        }
242
311
        return (PyObject *) self;
243
312
}
249
318
                PyErr_SetString(PyExc_SystemError, "Must open doc first");
250
319
                return -1;
251
320
        }
 
321
 
 
322
        ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
 
323
        PDFOptions& pdfOptions = currentDoc->PDF_Options;
 
324
 
252
325
// defaut save into file
253
 
        QString tf = ScCore->primaryMainWindow()->doc->PDF_Options.fileName;
 
326
        QString tf = pdfOptions.fileName;
254
327
        if (tf.isEmpty()) {
255
 
                QFileInfo fi = QFileInfo(ScCore->primaryMainWindow()->doc->DocName);
 
328
                QFileInfo fi = QFileInfo(currentDoc->DocName);
256
329
                tf = fi.path()+"/"+fi.baseName()+".pdf";
257
330
        }
258
331
        PyObject *file = NULL;
275
348
                return -1;
276
349
        }
277
350
        // get all used fonts
278
 
        QMap<QString,int> ReallyUsed = ScCore->primaryMainWindow()->doc->UsedFonts;
 
351
        QMap<QString,int> ReallyUsed = currentDoc->UsedFonts;
279
352
        // create list of all used fonts
280
353
        QList<QString> tmpEm;
281
354
        tmpEm = ReallyUsed.keys();
298
371
                        }
299
372
//              }
300
373
        }
 
374
// init SubsetList
 
375
        fonts = PyList_New(0);
 
376
        if (fonts){
 
377
                Py_DECREF(self->SubsetList);
 
378
                self->SubsetList = fonts;
 
379
        } else {
 
380
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'SubsetList' attribute");
 
381
                return -1;
 
382
        }
 
383
// copied from TabPDFOptions::restoreDefaults()
 
384
        for (int fe = 0; fe < pdfOptions.SubsetList.count(); ++fe)
 
385
        {
 
386
                PyObject *tmp= NULL;
 
387
                tmp = PyString_FromString(pdfOptions.SubsetList[fe].toLatin1().data());
 
388
                if (tmp) {
 
389
                        PyList_Append(self->SubsetList, tmp);
 
390
                        Py_DECREF(tmp);
 
391
                }
 
392
                else {
 
393
                        PyErr_SetString(PyExc_SystemError, "Can not initialize 'SubsetList' attribute");
 
394
                        return -1;
 
395
                }
 
396
        }
 
397
 
301
398
// set to print all pages
302
399
        PyObject *pages = NULL;
303
400
        int num = 0;
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);
308
405
        if (!pages){
309
406
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'pages' attribute");
321
418
        }
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;
 
433
// cropmarks offset 
 
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);
339
448
                return -1;
340
449
        }
341
450
// do not downsample images
342
 
        int down = ScCore->primaryMainWindow()->doc->PDF_Options.RecalcPic ? ScCore->primaryMainWindow()->doc->PDF_Options.PicRes : 0;
 
451
        int down = pdfOptions.RecalcPic ? pdfOptions.PicRes : 0;
343
452
        PyObject *downsample = NULL;
344
453
        downsample = PyInt_FromLong(down);
345
454
        if (downsample){
350
459
                return -1;
351
460
        }
352
461
        // no bookmarks
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;
360
469
        num = 0;
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);
365
474
        if (!effval){
366
475
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'effval' attribute");
367
476
                return -1;
368
477
        }
369
 
        int num2 = ScCore->primaryMainWindow()->doc->PDF_Options.PresentVals.count();
 
478
        int num2 = pdfOptions.PresentVals.count();
370
479
        for (i = 0; i<num2; ++i) {
371
480
                PyObject *tmp;
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 );
374
483
                if (tmp)
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);
404
513
        if (!lpival){
405
514
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'lpival' attribute");
406
515
                return -1;
407
516
        }
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()) {
410
519
                PyObject *tmp;
411
520
                tmp = Py_BuildValue(const_cast<char*>("[siii]"), it.key().toAscii().constData(), it.value().Frequency, it.value().Angle, it.value().SpotFunc);
412
521
                if (!tmp) {
421
530
        self->lpival = lpival;
422
531
// set owner's password
423
532
        PyObject *owner = NULL;
424
 
        owner = PyString_FromString(ScCore->primaryMainWindow()->doc->PDF_Options.PassOwner.toAscii());
 
533
        owner = PyString_FromString(pdfOptions.PassOwner.toAscii());
425
534
        if (owner){
426
535
                Py_DECREF(self->owner);
427
536
                self->owner = owner;
431
540
        }
432
541
// set user'a password
433
542
        PyObject *user = NULL;
434
 
        user = PyString_FromString(ScCore->primaryMainWindow()->doc->PDF_Options.PassUser.toAscii());
 
543
        user = PyString_FromString(pdfOptions.PassUser.toAscii());
435
544
        if (user){
436
545
                Py_DECREF(self->user);
437
546
                self->user = user;
440
549
                return -1;
441
550
        }
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;
454
563
 
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());
465
574
        if (solidpr){
469
578
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'solidpr' attribute");
470
579
                return -1;
471
580
        }
472
 
        QString tp2 = ScCore->primaryMainWindow()->doc->PDF_Options.ImageProf;
 
581
        QString tp2 = pdfOptions.ImageProf;
473
582
        if (!ScCore->InputProfiles.contains(tp2))
474
 
                tp2 = ScCore->primaryMainWindow()->view->Doc->CMSSettings.DefaultSolidColorRGBProfile;
 
583
                tp2 = currentDoc->CMSSettings.DefaultSolidColorRGBProfile;
475
584
        PyObject *imagepr = NULL;
476
585
        imagepr = PyString_FromString(tp2.toAscii());
477
586
        if (imagepr){
481
590
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'imagepr' attribute");
482
591
                return -1;
483
592
        }
484
 
        QString tp3 = ScCore->primaryMainWindow()->doc->PDF_Options.PrintProf;
 
593
        QString tp3 = pdfOptions.PrintProf;
485
594
        if (!ScCore->PDFXProfiles.contains(tp3))
486
 
                tp3 = ScCore->primaryMainWindow()->view->Doc->CMSSettings.DefaultPrinterProfile;
 
595
                tp3 = currentDoc->CMSSettings.DefaultPrinterProfile;
487
596
        PyObject *printprofc = NULL;
488
597
        printprofc = PyString_FromString(tp3.toAscii());
489
598
        if (printprofc){
493
602
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'printprofc' attribute");
494
603
                return -1;
495
604
        }
496
 
        QString tinfo = ScCore->primaryMainWindow()->doc->PDF_Options.Info;
 
605
        QString tinfo = pdfOptions.Info;
497
606
        PyObject *info = NULL;
498
607
        info = PyString_FromString(tinfo.toAscii());
499
608
        if (info){
503
612
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'info' attribute");
504
613
                return -1;
505
614
        }
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);
 
627
        if (RotateDeg){
 
628
                Py_DECREF(self->RotateDeg);
 
629
                self->RotateDeg = RotateDeg;
 
630
        } else {
 
631
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'RotateDeg' attribute");
 
632
                return -1;
 
633
        }
 
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
 
643
 
 
644
        PyObject *openAction = NULL;
 
645
        openAction = PyString_FromString(pdfOptions.openAction.toLatin1().data());
 
646
        if (openAction){
 
647
                Py_DECREF(self->openAction);
 
648
                self->openAction = openAction;
 
649
        } else {
 
650
                PyErr_SetString(PyExc_SystemError, "Can not initialize 'openAction' attribute");
 
651
                return -1;
 
652
        }
510
653
 
511
654
        return 0;
512
655
}
513
656
 
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"
 
703
                                                                                                     )},
 
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
543
712
};
544
713
 
600
769
        return 0;
601
770
}
602
771
 
 
772
static PyObject *PDFfile_getSubsetList(PDFfile *self, void * /*closure*/)
 
773
{
 
774
        Py_INCREF(self->SubsetList);
 
775
        return self->SubsetList;
 
776
}
 
777
 
 
778
static int PDFfile_setSubsetList(PDFfile *self, PyObject *value, void * /*closure*/)
 
779
{
 
780
        if (value == NULL) {
 
781
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'SubsetList' attribute.");
 
782
                return -1;
 
783
        }
 
784
        if (!PyList_Check(value)) {
 
785
                PyErr_SetString(PyExc_TypeError, "The 'SubsetList' attribute value must be list of strings.");
 
786
                return -1;
 
787
        }
 
788
        int n;
 
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.");
 
793
                        return -1;
 
794
                }
 
795
        Py_DECREF(self->SubsetList);
 
796
        Py_INCREF(value);
 
797
        self->SubsetList = value;
 
798
        PyList_Sort(self->SubsetList);
 
799
        return 0;
 
800
}
 
801
 
603
802
static PyObject *PDFfile_getpages(PDFfile *self, void * /*closure*/)
604
803
{
605
804
        Py_INCREF(self->pages);
657
856
        }
658
857
        int n = PyInt_AsLong(value);
659
858
        if (n<35 || n>4000) {
660
 
                PyErr_SetString(PyExc_ValueError, "'compress' value must be in interval from 35 to 4000");
 
859
                PyErr_SetString(PyExc_ValueError, "'resolution' value must be in interval from 35 to 4000");
661
860
                return -1;
662
861
        }
663
862
        Py_DECREF(self->resolution);
912
1111
        return 0;
913
1112
}
914
1113
 
 
1114
static PyObject *PDFfile_getRotateDeg(PDFfile *self, void * /*closure*/)
 
1115
{
 
1116
        Py_INCREF(self->RotateDeg);
 
1117
        return self->RotateDeg;
 
1118
}
 
1119
 
 
1120
static int PDFfile_setRotateDeg(PDFfile *self, PyObject *value, void * /*closure*/)
 
1121
{
 
1122
        if (value == NULL) {
 
1123
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'RotateDeg' attribute.");
 
1124
                return -1;
 
1125
        }
 
1126
        if (!PyInt_Check(value)) {
 
1127
                PyErr_SetString(PyExc_TypeError, "'RotateDeg' attribute value must be integer.");
 
1128
                return -1;
 
1129
        }
 
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");
 
1133
                return -1;
 
1134
        }
 
1135
        Py_DECREF(self->RotateDeg);
 
1136
        Py_INCREF(value);
 
1137
        self->RotateDeg = value;
 
1138
        return 0;
 
1139
}
 
1140
 
 
1141
static PyObject *PDFfile_getopenAction(PDFfile *self, void * /*closure*/)
 
1142
{
 
1143
        Py_INCREF(self->openAction);
 
1144
        return self->openAction;
 
1145
}
 
1146
 
 
1147
static int PDFfile_setopenAction(PDFfile *self, PyObject *value, void * /*closure*/)
 
1148
{
 
1149
        if (value == NULL) {
 
1150
                PyErr_SetString(PyExc_TypeError, "Cannot delete 'openAction' attribute.");
 
1151
                return -1;
 
1152
        }
 
1153
        if (!PyString_Check(value)) {
 
1154
                PyErr_SetString(PyExc_TypeError, "'openAction' attribute value must be string.");
 
1155
                return -1;
 
1156
        }
 
1157
        Py_DECREF(self->openAction);
 
1158
        Py_INCREF(value);
 
1159
        self->openAction = value;
 
1160
        return 0;
 
1161
}
 
1162
 
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
950
1201
};
951
1202
 
956
1207
                return NULL;
957
1208
        };
958
1209
 
 
1210
        ScribusDoc* currentDoc = ScCore->primaryMainWindow()->doc;
 
1211
        PDFOptions& pdfOptions = currentDoc->PDF_Options;
 
1212
 
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;
965
1219
 
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){
970
1224
                QString tmpFon;
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);
 
1227
        }
 
1228
// apply SubsetList attribute
 
1229
        pdfOptions.SubsetList.clear();
 
1230
        n = PyList_Size(self->SubsetList);
 
1231
        for ( int i=0; i<n; ++i){
 
1232
                QString tmpFon;
 
1233
                tmpFon = QString(PyString_AsString(PyList_GetItem(self->SubsetList, i)));
 
1234
                pdfOptions.SubsetList.append(tmpFon);
973
1235
        }
974
1236
// apply file attribute
975
1237
        QString fn;
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)));
983
1245
        }
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);
999
1273
        else
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;
1007
1281
 
1008
1282
        QList<PDFPresentationData> PresentVals;
1009
1283
        PresentVals.clear();
1036
1310
 
1037
1311
        }
1038
1312
 
1039
 
        ScCore->primaryMainWindow()->doc->PDF_Options.PresentVals = PresentVals;
 
1313
        pdfOptions.PresentVals = PresentVals;
1040
1314
// apply lpival
1041
1315
        int n2 = PyList_Size(self->lpival);
1042
1316
        for (int i=0; i<n2; ++i){
1049
1323
//                       PyErr_SetString(PyExc_SystemError, "while parsing 'lpival'. WHY THIS HAPPENED????");
1050
1324
//                       return NULL;
1051
1325
//               }
1052
 
//               ScCore->primaryMainWindow()->doc->PDF_Options.LPISettings[QString(s)]=lpi;
 
1326
//               pdfOptions.LPISettings[QString(s)]=lpi;
1053
1327
                QString st;
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;
1059
1333
        }
1060
1334
 
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)
1070
1344
        {
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)
1075
1349
                        Perm += 4;
1079
1353
                        Perm += 16;
1080
1354
                if (self->aanot)
1081
1355
                        Perm += 32;
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));
1085
1359
        }
1086
1360
        if (self->outdst == 0)
1087
1361
        {
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;
1091
1365
        }
1092
1366
        else
1093
1367
        {
1094
 
                ScCore->primaryMainWindow()->doc->PDF_Options.UseRGB = false;
1095
 
                if (ScCore->primaryMainWindow()->doc->HasCMS)
 
1368
                pdfOptions.UseRGB = false;
 
1369
                if (currentDoc->HasCMS)
1096
1370
                {
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)
1109
1383
                        {
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;
1131
1397
                        }
1132
1398
                }
1133
1399
                else
1134
1400
                {
1135
 
                        ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles = false;
1136
 
                        ScCore->primaryMainWindow()->doc->PDF_Options.UseProfiles2 = false;
 
1401
                        pdfOptions.UseProfiles = false;
 
1402
                        pdfOptions.UseProfiles2 = false;
1137
1403
                }
1138
1404
 
1139
1405
        }
1141
1407
        for (uint ap = 0; ap < pageNs.size(); ++ap)
1142
1408
        {
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);
1147
1413
        }
1148
 
        ReOrderText(ScCore->primaryMainWindow()->doc, ScCore->primaryMainWindow()->view);
 
1414
        ReOrderText(currentDoc, ScCore->primaryMainWindow()->view);
 
1415
 
 
1416
        MarginStruct optBleeds(pdfOptions.bleeds);
 
1417
        pdfOptions.useDocBleeds = self->usedocbleeds;
 
1418
        if (self->usedocbleeds)
 
1419
                pdfOptions.bleeds = currentDoc->bleeds;
 
1420
        else {
 
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();
 
1429
        }
 
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;
 
1447
 
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);
 
1450
        if (!success) {
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());
1155
 
                return NULL;
1156
1455
        }
1157
 
//      Py_INCREF(Py_None);
1158
 
//      return Py_None;
1159
 
        Py_RETURN_NONE;
 
1456
 
 
1457
        if (self->usedocbleeds || (pdfOptions.Version != PDFOptions::PDFVersion_X1a && 
 
1458
                                   pdfOptions.Version != PDFOptions::PDFVersion_X3))
 
1459
                pdfOptions.bleeds = optBleeds;
 
1460
 
 
1461
        if (success)
 
1462
                Py_RETURN_NONE;
 
1463
        return NULL;
1160
1464
}
1161
1465
 
1162
1466
static PyMethodDef PDFfile_methods[] = {