1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 
8 #include <QDir>
9 #include <QFileInfo>
10 #include <QImage>
11 #include <QTemporaryFile>
12 
13 #include "commonstrings.h"
14 #include "cmsettings.h"
15 #include "iconmanager.h"
16 #include "prefsfile.h"
17 #include "prefsmanager.h"
18 #include "prefstable.h"
19 #include "printpreviewcreator_pdf.h"
20 #include "pslib.h"
21 #include "sccolorengine.h"
22 #include "scpaths.h"
23 #include "scprintengine_pdf.h"
24 #include "scribuscore.h"
25 #include "scribusdoc.h"
26 #include "util.h"
27 #include "util_ghostscript.h"
28 #include "util_printer.h"
29 
PrintPreviewCreator_PDF(ScribusDoc * doc)30 PrintPreviewCreator_PDF::PrintPreviewCreator_PDF(ScribusDoc* doc) :
31 	SeparationPreviewCreator(doc),
32 	m_prefsManager(PrefsManager::instance())
33 {
34 	m_pdfPrintEngine = new ScPrintEngine_PDF(*doc);
35 	m_printOptions.prnLanguage = PrintLanguage::PDF;
36 
37 	// Generate a template name for temporary files
38 	QTemporaryFile *tempFile = new QTemporaryFile(ScPaths::tempFileDir() + "/scpdfpreview_XXXXXX.png");
39 	if (tempFile->open())
40 	{
41 		QString tempFileBase = tempFile->fileName();
42 		tempFile->setAutoRemove(false);
43 		tempFile->close();
44 		m_tempBaseName = QFileInfo(tempFileBase).completeBaseName();
45 	}
46 	if (m_tempBaseName.isEmpty())
47 		m_tempBaseName = "scpdfpreview";
48 	delete tempFile;
49 }
50 
~PrintPreviewCreator_PDF()51 PrintPreviewCreator_PDF::~PrintPreviewCreator_PDF()
52 {
53 	if (m_pdfPrintEngine)
54 	{
55 		delete m_pdfPrintEngine;
56 		m_pdfPrintEngine = nullptr;
57 	}
58 	cleanupTemporaryFiles();
59 }
60 
cleanupTemporaryFiles()61 void PrintPreviewCreator_PDF::cleanupTemporaryFiles()
62 {
63 	QString tempFileDir = ScPaths::tempFileDir();
64 	QFile::remove(tempFileDir + "/" + m_tempBaseName + ".pdf");
65 	QFile::remove(tempFileDir + "/" + m_tempBaseName + ".png");
66 	QDir d(tempFileDir + "/", m_tempBaseName + "*", QDir::Name, QDir::Files | QDir::NoSymLinks);
67 	if ((d.exists()) && (d.count() != 0))
68 	{
69 		for (uint i = 0; i < d.count(); i++)
70 			QFile::remove(tempFileDir + "/" + d[i]);
71 	}
72 }
73 
createPreview(int pageIndex)74 QPixmap PrintPreviewCreator_PDF::createPreview(int pageIndex)
75 {
76 	int ret = -1;
77 	int gsRes = qRound(m_previewResolution * m_devicePixelRatio);
78 	int w = qRound(m_doc->Pages->at(pageIndex)->width() * gsRes / 72.0);
79 	int h = qRound(m_doc->Pages->at(pageIndex)->height() * gsRes / 72.0);
80 
81 	QPixmap pixmap;
82 	if (m_printOptionsChanged || (m_pageIndex != pageIndex))
83 	{
84 		bool success = createPreviewFile(pageIndex);
85 		if (!success)
86 		{
87 			imageLoadError(pixmap, pageIndex);
88 			return pixmap;
89 		}
90 	}
91 
92 	if (m_printOptionsChanged || m_renderingOptionsChanged || (m_pageIndex != pageIndex))
93 	{
94 		if (m_sepPreviewEnabled && m_haveTiffSep)
95 			ret = renderPreviewSep(pageIndex, gsRes);
96 		else
97 			ret = renderPreview(pageIndex, gsRes);
98 		if (ret > 0)
99 		{
100 			imageLoadError(pixmap, pageIndex);
101 			return pixmap;
102 		}
103 	}
104 
105 	QImage image;
106 	if (m_sepPreviewEnabled && m_haveTiffSep)
107 	{
108 		bool loadError;
109 		int cyan, magenta, yellow, black;
110 
111 		ScImage im;
112 		bool mode;
113 		int w2 = w;
114 		int h2 = h;
115 		image = QImage(w2, h2, QImage::Format_ARGB32);
116 		image.fill(qRgba(0, 0, 0, 0));
117 
118 		QStringList separationNames { "Cyan", "Magenta", "Yellow" };
119 		CMSettings cms(m_doc, "", Intent_Perceptual);
120 		cms.allowColorManagement(false);
121 		for (int i = 0; i < separationNames.count(); ++i)
122 		{
123 			QString separationName = separationNames.at(i);
124 			if (!isSeparationVisible(separationName))
125 				continue;
126 			if (m_gsVersion < 854)
127 				loadError = im.loadPicture(ScPaths::tempFileDir() + "/" + m_tempBaseName + ".tif." + separationName + ".tif", 1, cms, ScImage::RGBData, 72, &mode);
128 			else if (m_gsVersion <= 905)
129 				loadError = im.loadPicture(ScPaths::tempFileDir() + "/" + m_tempBaseName + "." + separationName + ".tif", 1, cms, ScImage::RGBData, 72, &mode);
130 			else
131 				loadError = im.loadPicture(ScPaths::tempFileDir() + "/" + m_tempBaseName + "(" + separationName + ").tif", 1, cms, ScImage::RGBData, 72, &mode);
132 			if (!loadError)
133 			{
134 				imageLoadError(pixmap, pageIndex);
135 				return pixmap;
136 			}
137 			if (m_showInkCoverage)
138 				blendImagesSumUp(image, im);
139 			else
140 			{
141 				int c = (i == 0) ? 255 : 0;
142 				int m = (i == 1) ? 255 : 0;
143 				int j = (i == 2) ? 255 : 0;
144 				blendImages(image, im, ScColor(c, m, j, 0));
145 			}
146 		}
147 
148 		for (auto sepit = m_sepsToFileNum.begin(); sepit != m_sepsToFileNum.end(); ++sepit)
149 		{
150 			bool visibleSeparation = m_separationVisibilities.value(sepit.key(), false);
151 			if (!visibleSeparation)
152 				continue;
153 			QString sepFileName;
154 			if (m_gsVersion < 854)
155 				sepFileName = QString(ScPaths::tempFileDir() + "/" + m_tempBaseName + ".tif.s%1.tif").arg(sepit.value());
156 			else if (m_gsVersion <= 905)
157 				sepFileName = QString(ScPaths::tempFileDir() + "/" + m_tempBaseName + ".s%1.tif").arg(sepit.value());
158 			else
159 				sepFileName = QString(ScPaths::tempFileDir() + "/" + m_tempBaseName + "(%1).tif").arg(sepit.key());
160 			if (!im.loadPicture(sepFileName, 1, cms, ScImage::RGBData, 72, &mode))
161 			{
162 				imageLoadError(pixmap, pageIndex);
163 				return pixmap;
164 			}
165 			if (m_showInkCoverage)
166 				blendImagesSumUp(image, im);
167 			else
168 				blendImages(image, im, m_doc->PageColors[sepit.key()]);
169 		}
170 
171 		if (m_separationVisibilities.value("Black", false))
172 		{
173 			CMSettings cms(m_doc, "", Intent_Perceptual);
174 			cms.allowColorManagement(false);
175 			if (m_gsVersion < 854)
176 				loadError = im.loadPicture(ScPaths::tempFileDir() + "/" + m_tempBaseName + ".tif.Black.tif", 1, cms, ScImage::RGBData, 72, &mode);
177 			else if (m_gsVersion <= 905)
178 				loadError = im.loadPicture(ScPaths::tempFileDir() + "/" + m_tempBaseName + ".Black.tif", 1, cms, ScImage::RGBData, 72, &mode);
179 			else
180 				loadError = im.loadPicture(ScPaths::tempFileDir() + "/" + m_tempBaseName + "(Black).tif", 1, cms, ScImage::RGBData, 72, &mode);
181 			if (!loadError)
182 			{
183 				imageLoadError(pixmap, pageIndex);
184 				return pixmap;
185 			}
186 			if (m_showInkCoverage)
187 				blendImagesSumUp(image, im);
188 			else
189 				blendImages(image, im, ScColor(0, 0, 0, 255));
190 		}
191 
192 		if (m_showInkCoverage)
193 		{
194 			uint limitVal = (m_inkCoverageThreshold * 255) / 100;
195 			for (int yi = 0; yi < h2; ++yi)
196 			{
197 				QRgb *q = (QRgb*) image.scanLine(yi);
198 				for (int xi = 0; xi < w2; ++xi)
199 				{
200 					uint greyVal = *q;
201 					if (greyVal != 0)
202 					{
203 						if (limitVal == 0)
204 						{
205 							QColor tmpC;
206 							tmpC.setHsv((greyVal * 359) / m_inkMax, 255, 255);
207 							*q = tmpC.rgba();
208 						}
209 						else
210 						{
211 							int col = qMin(255 - static_cast<int>(((greyVal * 128) / m_inkMax) * 2), 255);
212 							if ((*q > 0) && (*q < limitVal))
213 								*q = qRgba(col, col, col, 255);
214 							else
215 								*q = qRgba(col, 0, 0, 255);
216 						}
217 					}
218 					else
219 					{
220 						if (!m_showTransparency)
221 							*q = qRgba(255, 255, 255, 255);
222 					}
223 					q++;
224 				}
225 			}
226 		}
227 		else if (m_doc->HasCMS || ScCore->haveCMS())
228 		{
229 			QRgb alphaFF = qRgba(0,0,0,255);
230 			QRgb alphaOO = qRgba(255,255,255,0);
231 			ScColorMgmtEngine engine = m_doc->colorEngine;
232 			ScColorProfile cmykProfile = m_doc->HasCMS ? m_doc->DocPrinterProf : ScCore->defaultCMYKProfile;
233 			ScColorProfile rgbProfile  = m_doc->HasCMS ? m_doc->DocDisplayProf : ScCore->defaultRGBProfile;
234 			ScColorTransform transCMYK = engine.createTransform(cmykProfile, Format_YMCK_8, rgbProfile, Format_BGRA_8, Intent_Relative_Colorimetric, 0);
235 			for (int yi = 0; yi < h2; ++yi)
236 			{
237 				uchar* ptr = image.scanLine( yi );
238 				transCMYK.apply(ptr, ptr, image.width());
239 				QRgb *q = (QRgb *) ptr;
240 				for (int xi = 0; xi < image.width(); xi++, q++)
241 				{
242 					if (m_showTransparency)
243 					{
244 						cyan = qRed(*q);
245 						magenta = qGreen(*q);
246 						yellow = qBlue(*q);
247 						if	((cyan == 255) && (magenta == 255) && (yellow == 255))
248 							*q = alphaOO;
249 						else
250 							*q |= alphaFF;
251 					}
252 					else
253 						*q |= alphaFF;
254 				}
255 			}
256 		}
257 		else
258 		{
259 			for (int yi = 0; yi < h2; ++yi)
260 			{
261 				QRgb *q = (QRgb*) image.scanLine(yi);
262 				for (int xi = 0; xi < w2; ++xi)
263 				{
264 					cyan = qRed(*q);
265 					magenta = qGreen(*q);
266 					yellow = qBlue(*q);
267 					black = qAlpha(*q);
268 					if ((cyan != 0) || (magenta != 0) || (yellow != 0 ) || (black != 0))
269 						*q = qRgba(255 - qMin(255, cyan + black), 255 - qMin(255, magenta + black), 255 - qMin(255, yellow + black), 255);
270 					else
271 					{
272 						if (!m_showTransparency)
273 							*q = qRgba(255, 255, 255, 255);
274 					}
275 					q++;
276 				}
277 			}
278 		}
279 	}
280 	else
281 	{
282 		QString previewFile;
283 		if (m_showTransparency && m_havePngAlpha)
284 			previewFile = ScPaths::tempFileDir() + "/" + m_tempBaseName + ".png";
285 		else
286 			previewFile = ScPaths::tempFileDir() + "/" + m_tempBaseName + ".tif";
287 		if (!image.load(previewFile))
288 		{
289 			imageLoadError(pixmap, pageIndex);
290 			return pixmap;
291 		}
292 		image = image.convertToFormat(QImage::Format_ARGB32);
293 		if (m_showTransparency && m_havePngAlpha)
294 		{
295 			int wi = image.width();
296 			int hi = image.height();
297 			for (int yi = 0; yi < hi; ++yi)
298 			{
299 				QRgb *s = (QRgb*) image.scanLine(yi);
300 				for (int xi = 0; xi < wi; ++xi)
301 				{
302 					if ((*s) == 0xffffffff)
303 						(*s) &= 0x00ffffff;
304 					s++;
305 				}
306 			}
307 		}
308 	}
309 
310 	image.setDevicePixelRatio(m_devicePixelRatio);
311 	if (m_showTransparency)
312 	{
313 		pixmap = QPixmap(image.width(), image.height());
314 		pixmap.setDevicePixelRatio(m_devicePixelRatio);
315 		QPainter p;
316 		QBrush b(QColor(205,205,205), IconManager::instance().loadPixmap("testfill.png"));
317 		p.begin(&pixmap);
318 		p.fillRect(0, 0, image.width(), image.height(), b);
319 		p.drawImage(0, 0, image);
320 		p.end();
321 	}
322 	else
323 		pixmap = QPixmap::fromImage(image);
324 	pixmap.setDevicePixelRatio(m_devicePixelRatio);
325 
326 	m_pageIndex = pageIndex;
327 	m_printOptionsChanged = false;
328 	m_renderingOptionsChanged = false;
329 
330 	return pixmap;
331 }
332 
createPreviewFile(int pageIndex)333 bool PrintPreviewCreator_PDF::createPreviewFile(int pageIndex)
334 {
335 	std::vector<int> pageNumbers { pageIndex + 1 };
336 
337 	PrintOptions printOptions(m_printOptions);
338 	printOptions.pageNumbers = pageNumbers;
339 	printOptions.outputSeparations = false;
340 	printOptions.separationName = "All";
341 	printOptions.allSeparations = QStringList();
342 	printOptions.setDevParam = false;
343 
344 	// Disable crop marks
345 	printOptions.cropMarks = false;
346 	printOptions.bleedMarks = false;
347 	printOptions.registrationMarks = false;
348 	printOptions.colorMarks = false;
349 	printOptions.markLength = 20.0;
350 	printOptions.markOffset = 0.0;
351 	printOptions.bleeds.set(0, 0, 0, 0);
352 
353 	// Generate PostScript
354 	QString errorMessage;
355 	QString pdfFileName = ScPaths::tempFileDir() + "/"  + m_tempBaseName + ".pdf";
356 
357 	bool success = (m_pdfPrintEngine->createPDFFile(pdfFileName, printOptions, errorMessage) == 0);
358 	return success;
359 }
360 
renderPreview(int pageIndex,int res)361 int PrintPreviewCreator_PDF::renderPreview(int pageIndex, int res)
362 {
363 	int ret = -1;
364 	QString cmd1;
365 
366 	QStringList args;
367 	QString tmp, tmp2, tmp3;
368 	int w = qRound(m_doc->Pages->at(pageIndex)->width() * res / 72.0);
369 	int h = qRound(m_doc->Pages->at(pageIndex)->height() * res / 72.0);
370 
371 	args.append( "-q" );
372 	args.append( "-dNOPAUSE" );
373 	args.append( "-dPARANOIDSAFER" );
374 	args.append( QString("-r%1").arg(tmp.setNum(res)) );
375 	args.append( QString("-g%1x%2").arg(tmp2.setNum(w), tmp3.setNum(h)) );
376 	if (m_sepPreviewEnabled)
377 	{
378 		if (!m_haveTiffSep)
379 			return 1;
380 		args.append( "-sDEVICE=tiffsep" );
381 	}
382 	else
383 	{
384 		if (m_showTransparency && m_havePngAlpha)
385 			args.append("-sDEVICE=pngalpha");
386 		else
387 			args.append("-sDEVICE=tiff24nc");
388 	}
389 	if (m_useAntialiasing)
390 	{
391 		args.append( "-dTextAlphaBits=4" );
392 		args.append( "-dGraphicsAlphaBits=4" );
393 	}
394 	if ((m_doc->HasCMS) && (m_gsVersion >= 900))
395 	{
396 		args.append("-sDefaultCMYKProfile=" + QDir::toNativeSeparators(m_doc->DocPrinterProf.profilePath()));
397 		if (m_sepPreviewEnabled)
398 			args.append("-sOutputICCProfile=" + QDir::toNativeSeparators(m_doc->DocPrinterProf.profilePath()));
399 		else
400 			args.append("-sOutputICCProfile=" + QDir::toNativeSeparators(m_doc->DocDisplayProf.profilePath()));
401 	}
402 	else if (ScCore->haveCMS() && (m_gsVersion >= 900))
403 	{
404 		args.append("-sDefaultCMYKProfile=" + QDir::toNativeSeparators(ScCore->defaultCMYKProfile.profilePath()));
405 		if (m_sepPreviewEnabled)
406 			args.append("-sOutputICCProfile=" + QDir::toNativeSeparators(ScCore->defaultCMYKProfile.profilePath()));
407 		else
408 			args.append("-sOutputICCProfile=" + QDir::toNativeSeparators(ScCore->defaultRGBProfile.profilePath()));
409 	}
410 
411 	// Add any extra font paths being used by Scribus to gs's font search path
412 	PrefsContext *pc = m_prefsManager.prefsFile->getContext("Fonts");
413 	PrefsTable *extraFonts = pc->getTable("ExtraFontDirs");
414 	const char sep = ScPaths::envPathSeparator;
415 	if (extraFonts->getRowCount() >= 1)
416 		cmd1 = QString("-sFONTPATH=%1").arg(QDir::toNativeSeparators(extraFonts->get(0,0)));
417 	for (int i = 1; i < extraFonts->getRowCount(); ++i)
418 		cmd1 += QString("%1%2").arg(sep).arg(QDir::toNativeSeparators(extraFonts->get(i,0)));
419 	if (!cmd1.isEmpty())
420 		args.append( cmd1 );
421 
422 	// then add any final args and call gs
423 	QString tempFileDir = ScPaths::tempFileDir() ;
424 	if (m_sepPreviewEnabled)
425 		args.append( QString("-sOutputFile=%1").arg(QDir::toNativeSeparators(tempFileDir + "/" + m_tempBaseName + ".tif")) );
426 	else if (m_showTransparency && m_havePngAlpha)
427 		args.append( QString("-sOutputFile=%1").arg(QDir::toNativeSeparators(tempFileDir + "/" + m_tempBaseName + ".png")) );
428 	else
429 		args.append(QString("-sOutputFile=%1").arg(QDir::toNativeSeparators(tempFileDir + "/" + m_tempBaseName + ".tif")));
430 	args.append( QDir::toNativeSeparators(ScPaths::tempFileDir() + "/" + m_tempBaseName + ".pdf") );
431 	args.append( "-c" );
432 	args.append( "showpage" );
433 	args.append( "-c" );
434 	args.append( "quit" );
435 	ret = System(m_prefsManager.ghostscriptExecutable(), args);
436 	return ret;
437 }
438 
renderPreviewSep(int pageIndex,int res)439 int PrintPreviewCreator_PDF::renderPreviewSep(int pageIndex, int res)
440 {
441 	int ret = -1;
442 	QString cmd;
443 	QStringList args, args1, args2, args3;
444 
445 	QString tmp, tmp2, tmp3;
446 	int w = qRound(m_doc->Pages->at(pageIndex)->width() * res / 72.0);
447 	int h = qRound(m_doc->Pages->at(pageIndex)->height() * res / 72.0);
448 
449 	args1.append( "-q" );
450 	args1.append( "-dNOPAUSE" );
451 	args1.append( "-dPARANOIDSAFER" );
452 	args1.append( QString("-r%1").arg(tmp.setNum(res)) );
453 	args1.append( QString("-g%1x%2").arg(tmp2.setNum(w), tmp3.setNum(h)) );
454 	if (m_useAntialiasing)
455 	{
456 		args1.append("-dTextAlphaBits=4");
457 		args1.append("-dGraphicsAlphaBits=4");
458 	}
459 	if ((m_doc->HasCMS) && (m_gsVersion >= 900))
460 	{
461 		args1.append("-sDefaultCMYKProfile=" + QDir::toNativeSeparators(m_doc->DocPrinterProf.profilePath()));
462 		args1.append("-sOutputICCProfile=" + QDir::toNativeSeparators(m_doc->DocPrinterProf.profilePath()));
463 	}
464 	else if (ScCore->haveCMS() && (m_gsVersion >= 900))
465 	{
466 		args.append("-sDefaultCMYKProfile=" + QDir::toNativeSeparators(ScCore->defaultCMYKProfile.profilePath()));
467 		args.append("-sOutputICCProfile=" + QDir::toNativeSeparators(ScCore->defaultCMYKProfile.profilePath()));
468 	}
469 
470 	// Add any extra font paths being used by Scribus to gs's font search path
471 	PrefsContext *pc = m_prefsManager.prefsFile->getContext("Fonts");
472 	PrefsTable *extraFonts = pc->getTable("ExtraFontDirs");
473 	const char sep = ScPaths::envPathSeparator;
474 	if (extraFonts->getRowCount() >= 1)
475 		cmd = QString("-sFONTPATH=%1").arg(QDir::toNativeSeparators(extraFonts->get(0,0)));
476 	for (int i = 1; i < extraFonts->getRowCount(); ++i)
477 		cmd += QString("%1%2").arg(sep).arg(QDir::toNativeSeparators(extraFonts->get(i,0)));
478 	if (!cmd.isEmpty())
479 		args1.append(cmd);
480 	args1.append( QString("-sOutputFile=%1").arg(QDir::toNativeSeparators(ScPaths::tempFileDir() + "/" + m_tempBaseName + ".tif")) );
481 
482 	args2.append( QDir::toNativeSeparators(ScPaths::tempFileDir() + "/" + m_tempBaseName + ".pdf") );
483 	args2.append("-c");
484 	args2.append("quit");
485 
486 	ColorList usedSpots;
487 	m_doc->getUsedColors(usedSpots, true);
488 	QStringList spots = usedSpots.keys();
489 	args3.append( "-sDEVICE=tiffsep" );
490 
491 //	args3.append( "-c" );
492 	cmd = "<< /SeparationColorNames ";
493 	QString allSeps ="[ /Cyan /Magenta /Yellow /Black ";
494 	for (int sp = 0; sp < spots.count(); ++sp)
495 	{
496 		allSeps += "(" + spots[sp] + ") ";
497 	}
498 	allSeps += "]";
499 	cmd += allSeps + " /SeparationOrder [ /Cyan /Magenta /Yellow /Black] >> setpagedevice";
500 	QFile fx(QDir::toNativeSeparators(ScPaths::tempFileDir() + "/" +  m_tempBaseName + ".sep.ps"));
501 	if (fx.open(QIODevice::WriteOnly))
502 	{
503 		QTextStream tsx(&fx);
504 		tsx << cmd;
505 		fx.close();
506 	}
507 
508 	QString gsExe(getShortPathName(m_prefsManager.ghostscriptExecutable()));
509 	ret = System(gsExe, args1 + args3 + args2, ScPaths::tempFileDir() + "/" +  m_tempBaseName + ".tif.txt" );
510 
511 	QFile sepInfo(QDir::toNativeSeparators(ScPaths::tempFileDir() + "/" +  m_tempBaseName + ".tif.txt"));
512 	m_sepsToFileNum.clear();
513 	if (sepInfo.open(QIODevice::ReadOnly))
514 	{
515 		QString Sname;
516 		QTextStream tsC(&sepInfo);
517 		int counter = 0;
518 		while (!tsC.atEnd())
519 		{
520 			Sname = tsC.readLine();
521 			QString tt = Sname.remove("%%SeparationName:").trimmed();
522 			if (!tt.isEmpty())
523 			{
524 				m_sepsToFileNum.insert(tt, counter);
525 				counter++;
526 			}
527 		}
528 	}
529 	sepInfo.close();
530 	QString currSeps = "";
531 	uint spc = 0;
532 	for (int sp = 0; sp < spots.count(); ++sp)
533 	{
534 		currSeps += "(" + spots[sp] + ") ";
535 		spc++;
536 		if (sp > 6)
537 		{
538 			args3.clear();
539 			args3.append("-sDEVICE=tiffsep");
540 			QFile fx(QDir::toNativeSeparators(ScPaths::tempFileDir() + "/" +  m_tempBaseName + ".sep.ps"));
541 			if (fx.open(QIODevice::WriteOnly))
542 			{
543 				QTextStream tsx(&fx);
544 				tsx << QString("<< /SeparationColorNames " + allSeps + " /SeparationOrder [ " + currSeps + " ] >> setpagedevice");
545 				fx.close();
546 			}
547 			args3.append("-f");
548 			args3.append(QDir::toNativeSeparators(ScPaths::tempFileDir() + "/" +  m_tempBaseName + ".sep.ps"));
549 			ret = System(gsExe, args1 + args3 + args2);
550 			currSeps = "";
551 			spc = 0;
552 		}
553 	}
554 	if (spc != 0)
555 	{
556 		args3.clear();
557 		args3.append("-sDEVICE=tiffsep");
558 		QFile fx(QDir::toNativeSeparators(ScPaths::tempFileDir() + "/" +  m_tempBaseName + ".sep.ps"));
559 		if (fx.open(QIODevice::WriteOnly))
560 		{
561 			QTextStream tsx(&fx);
562 			tsx << QString("<< /SeparationColorNames " + allSeps+" /SeparationOrder [ " + currSeps + " ] >> setpagedevice");
563 			fx.close();
564 		}
565 		args3.append("-f");
566 		args3.append(QDir::toNativeSeparators(ScPaths::tempFileDir() + "/" +  m_tempBaseName + ".sep.ps"));
567 		ret = System(gsExe, args1 + args3 + args2);
568 	}
569 	return ret;
570 }
571 
setPrintOptions(const PrintOptions & options)572 void PrintPreviewCreator_PDF::setPrintOptions(const PrintOptions& options)
573 {
574 	m_printOptions = options;
575 	m_printOptions.prnLanguage = PrintLanguage::PDF;
576 	m_printOptionsChanged = true;
577 }
578 
imageLoadError(QPixmap & pixmap,int page)579 void PrintPreviewCreator_PDF::imageLoadError(QPixmap &pixmap, int page)
580 {
581 	pixmap = QPixmap(1, 1);
582 	m_pageIndex = page;
583 	m_printOptionsChanged = false;
584 	m_renderingOptionsChanged = false;
585 }
586