Rev 4223 | Rev 4225 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3133 | fschmid | 1 | /*************************************************************************** |
2 | pdflib.cpp - description |
||
3 | ------------------- |
||
4 | begin : Sat Jan 19 2002 |
||
5 | copyright : (C) 2002 by Franz Schmid |
||
6 | email : Franz.Schmid@altmuehlnet.de |
||
7 | ***************************************************************************/ |
||
8 | |||
9 | /*************************************************************************** |
||
10 | * * |
||
11 | * This program is free software; you can redistribute it and/or modify * |
||
12 | * it under the terms of the GNU General Public License as published by * |
||
13 | * the Free Software Foundation; either version 2 of the License, or * |
||
14 | * (at your option) any later version. * |
||
15 | * * |
||
16 | ***************************************************************************/ |
||
17 | |||
18 | #include "pdflib.h" |
||
19 | #include "pdflib.moc" |
||
20 | |||
21 | #include "scconfig.h" |
||
22 | |||
23 | #include <qstring.h> |
||
24 | #include <qrect.h> |
||
25 | #include <qimage.h> |
||
26 | #include <qregexp.h> |
||
27 | #include <qdatetime.h> |
||
28 | #include <qfileinfo.h> |
||
29 | #include <qtextstream.h> |
||
30 | #include <qdir.h> |
||
31 | #include <cstdlib> |
||
32 | #include <cmath> |
||
33 | #ifdef HAVE_UNISTD_H |
||
34 | #include <unistd.h> |
||
35 | #endif |
||
36 | #include "rc4.h" |
||
37 | |||
4028 | cbradney | 38 | #include "commonstrings.h" |
3670 | cbradney | 39 | #include "page.h" |
3133 | fschmid | 40 | #include "pageitem.h" |
41 | #include "bookmwin.h" |
||
42 | #include "scribus.h" |
||
4028 | cbradney | 43 | #include "scribusapp.h" |
3699 | cbradney | 44 | #include "scribusdoc.h" |
4028 | cbradney | 45 | #include "multiprogressdialog.h" |
3133 | fschmid | 46 | #include "bookpalette.h" |
47 | #include "scfontmetrics.h" |
||
48 | #include "util.h" |
||
49 | #include "prefsmanager.h" |
||
3252 | craig | 50 | #include "prefscontext.h" |
3133 | fschmid | 51 | #include "pdfoptions.h" |
4007 | fschmid | 52 | #include "sccolor.h" |
3133 | fschmid | 53 | |
54 | using namespace std; |
||
55 | |||
56 | #ifdef HAVE_CMS |
||
57 | extern bool CMSuse; |
||
58 | #endif |
||
59 | #ifdef HAVE_TIFF |
||
60 | #include <tiffio.h> |
||
61 | #endif |
||
62 | |||
4223 | craig | 63 | PDFlib::PDFlib(ScribusDoc * docu) |
64 | : QObject(docu), |
||
65 | doc(docu), |
||
66 | ActPageP(0), |
||
67 | Options(0), |
||
68 | Bvie(0), |
||
69 | Dokument(0), |
||
70 | ObjCounter(7), |
||
71 | ResNam("RE"), |
||
72 | ResCount(0), |
||
73 | NDnam("LI"), |
||
74 | NDnum(0), |
||
75 | KeyGen(32), |
||
76 | OwnerKey(32), |
||
77 | UserKey(32), |
||
78 | FileID(16), |
||
79 | EncryKey(5), |
||
80 | Encrypt(0), |
||
81 | KeyLen(5), |
||
82 | colorsToUse(), |
||
83 | spotNam("Spot"), |
||
84 | spotCount(0), |
||
85 | abortExport(false), |
||
86 | usingGUI(ScQApp->usingGUI()) |
||
3133 | fschmid | 87 | { |
88 | Catalog.Outlines = 2; |
||
89 | Catalog.PageTree = 3; |
||
90 | Catalog.Dest = 4; |
||
91 | PageTree.Count = 0; |
||
92 | Outlines.First = 0; |
||
93 | Outlines.Last = 0; |
||
94 | Outlines.Count = 0; |
||
95 | Seite.ObjNum = 0; |
||
96 | Seite.Thumb = 0; |
||
97 | #ifdef HAVE_LIBZ |
||
98 | CompAvail = true; |
||
99 | #else |
||
100 | CompAvail = false; |
||
101 | #endif |
||
102 | int kg_array[] = {0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, |
||
103 | 0x01, 0x08, 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80, 0x2f, 0x0c, 0xa9, 0xfe, |
||
104 | 0x64, 0x53, 0x69, 0x7a}; |
||
105 | for (int a = 0; a < 32; ++a) |
||
106 | KeyGen[a] = kg_array[a]; |
||
4028 | cbradney | 107 | if (usingGUI) |
108 | { |
||
4223 | craig | 109 | progressDialog = new MultiProgressDialog(tr("Saving PDF"), CommonStrings::tr_Cancel, ScMW, "pdfexportprogress"); |
4224 | craig | 110 | Q_CHECK_PTR(progressDialog); |
111 | QStringList barNames, barTexts; |
||
112 | barNames << "EMP" << "EP" << "ECPI"; |
||
113 | barTexts << QT_TR_NOOP("Exporting Master Pages:") << QT_TR_NOOP("Exporting Pages:") << QT_TR_NOOP("Exporting Items on Current Page:"); |
||
114 | progressDialog->addExtraProgressBars(barNames, barTexts); |
||
115 | connect(progressDialog->buttonCancel, SIGNAL(clicked()), this, SLOT(cancelRequested())); |
||
4028 | cbradney | 116 | } |
3133 | fschmid | 117 | } |
118 | |||
4224 | craig | 119 | PDFlib::~PDFlib() |
120 | { |
||
121 | delete progressDialog; |
||
122 | } |
||
123 | |||
4030 | cbradney | 124 | bool PDFlib::doExport(const QString& fn, const QString& nam, int Components, std::vector<int> &pageNs, QMap<int,QPixmap> thumbs) |
3133 | fschmid | 125 | { |
126 | QPixmap pm; |
||
127 | bool ret = false; |
||
4028 | cbradney | 128 | int pc_exportpages=0; |
129 | int pc_exportmasterpages=0; |
||
4224 | craig | 130 | if (usingGUI) |
131 | progressDialog->show(); |
||
4026 | craig | 132 | if (PDF_Begin_Doc(fn, &doc->PDF_Options, PrefsManager::instance()->appPrefs.AvailFonts, doc->UsedFonts, ScMW->bookmarkPalette->BView)) |
3133 | fschmid | 133 | { |
134 | QMap<int, int> pageNsMpa; |
||
135 | for (uint a = 0; a < pageNs.size(); ++a) |
||
136 | { |
||
3724 | cbradney | 137 | pageNsMpa.insert(doc->MasterNames[doc->Pages->at(pageNs[a]-1)->MPageNam], 0); |
3133 | fschmid | 138 | } |
4028 | cbradney | 139 | if (usingGUI) |
3133 | fschmid | 140 | { |
4028 | cbradney | 141 | progressDialog->setOverallTotalSteps(pageNsMpa.count()+pageNs.size()); |
142 | progressDialog->setTotalSteps("EMP", pageNsMpa.count()); |
||
143 | progressDialog->setTotalSteps("EP", pageNs.size()); |
||
144 | progressDialog->setOverallProgress(0); |
||
145 | progressDialog->setProgress("EMP", 0); |
||
146 | progressDialog->setProgress("EP", 0); |
||
147 | } |
||
148 | for (uint ap = 0; ap < doc->MasterPages.count() && !abortExport; ++ap) |
||
149 | { |
||
3133 | fschmid | 150 | if (doc->MasterItems.count() != 0) |
151 | { |
||
152 | if (pageNsMpa.contains(ap)) |
||
153 | { |
||
4028 | cbradney | 154 | ScQApp->processEvents(); |
3133 | fschmid | 155 | PDF_TemplatePage(doc->MasterPages.at(ap)); |
4028 | cbradney | 156 | ++pc_exportmasterpages; |
3133 | fschmid | 157 | } |
158 | } |
||
4028 | cbradney | 159 | |
160 | if (usingGUI) |
||
161 | { |
||
162 | progressDialog->setProgress("EMP", pc_exportmasterpages); |
||
163 | progressDialog->setOverallProgress(pc_exportmasterpages+pc_exportpages); |
||
164 | } |
||
3133 | fschmid | 165 | } |
4028 | cbradney | 166 | for (uint a = 0; a < pageNs.size() && !abortExport; ++a) |
3133 | fschmid | 167 | { |
168 | if (doc->PDF_Options.Thumbnails) |
||
169 | pm = thumbs[pageNs[a]]; |
||
4028 | cbradney | 170 | ScQApp->processEvents(); |
171 | if (abortExport) break; |
||
3724 | cbradney | 172 | PDF_Begin_Page(doc->Pages->at(pageNs[a]-1), pm); |
4028 | cbradney | 173 | ScQApp->processEvents(); |
174 | if (abortExport) break; |
||
3724 | cbradney | 175 | PDF_ProcessPage(doc->Pages->at(pageNs[a]-1), pageNs[a]-1); |
4028 | cbradney | 176 | ScQApp->processEvents(); |
177 | if (abortExport) break; |
||
3133 | fschmid | 178 | PDF_End_Page(); |
4028 | cbradney | 179 | pc_exportpages++; |
180 | if (usingGUI) |
||
181 | { |
||
182 | progressDialog->setProgress("EP", pc_exportpages); |
||
183 | progressDialog->setOverallProgress(pc_exportmasterpages+pc_exportpages); |
||
184 | } |
||
3133 | fschmid | 185 | } |
4028 | cbradney | 186 | ret = true;//Even when aborting we return true. Dont want that "couldnt write msg" |
187 | if (!abortExport) |
||
188 | { |
||
189 | if (doc->PDF_Options.Version == PDFOptions::PDFVersion_X3) |
||
190 | PDF_End_Doc(ScMW->PrinterProfiles[doc->PDF_Options.PrintProf], nam, Components); |
||
191 | else |
||
192 | PDF_End_Doc(); |
||
193 | } |
||
3133 | fschmid | 194 | else |
4028 | cbradney | 195 | closeAndCleanup(); |
3133 | fschmid | 196 | } |
4029 | cbradney | 197 | if (usingGUI) |
198 | progressDialog->close(); |
||
3133 | fschmid | 199 | return ret; |
200 | } |
||
201 | |||
3829 | cbradney | 202 | QString PDFlib::FToStr(const double c) |
3133 | fschmid | 203 | { |
204 | QString cc; |
||
205 | return cc.sprintf("%.5f", c); |
||
206 | } |
||
207 | |||
3829 | cbradney | 208 | QString PDFlib::IToStr(const int c) |
3133 | fschmid | 209 | { |
210 | QString cc; |
||
211 | return cc.setNum(c); |
||
212 | } |
||
213 | |||
214 | void PDFlib::PutDoc(QString in) |
||
215 | { |
||
3829 | cbradney | 216 | //QTextStream t(&Spool); //CB replaced with member t. |
217 | uint inlen=in.length(); |
||
218 | t.writeRawBytes(in.latin1(), inlen); |
||
3133 | fschmid | 219 | Spool.flush(); |
3829 | cbradney | 220 | Dokument += inlen; |
3133 | fschmid | 221 | } |
222 | |||
223 | void PDFlib::PutPage(QString in) |
||
224 | { |
||
225 | Inhalt += in; |
||
226 | } |
||
227 | |||
228 | void PDFlib::StartObj(int nr) |
||
229 | { |
||
230 | XRef.append(Dokument); |
||
231 | PutDoc(IToStr(nr)+ " 0 obj\n"); |
||
232 | } |
||
233 | |||
234 | QString PDFlib::PDFEncode(QString in) |
||
235 | { |
||
236 | QString tmp = ""; |
||
237 | QString cc; |
||
238 | for (uint d = 0; d < in.length(); ++d) |
||
239 | { |
||
240 | cc = in.at(d); |
||
241 | if ((cc == "(") || (cc == ")") || (cc == "\\")) |
||
242 | tmp += "\\"; |
||
243 | tmp += cc; |
||
244 | } |
||
245 | return tmp; |
||
246 | } |
||
247 | |||
248 | QString PDFlib::EncStream(QString *in, int ObjNum) |
||
249 | { |
||
250 | if (in->length() < 1) |
||
251 | return ""; |
||
252 | rc4_context_t rc4; |
||
253 | QString tmp = ""; |
||
254 | int dlen = 0; |
||
255 | if (Options->Encrypt) |
||
256 | { |
||
257 | tmp = *in; |
||
258 | QByteArray us(tmp.length()); |
||
259 | QByteArray ou(tmp.length()); |
||
260 | for (uint a = 0; a < tmp.length(); ++a) |
||
261 | us[a] = uchar(QChar(tmp.at(a))); |
||
262 | QByteArray data(10); |
||
263 | if (KeyLen > 5) |
||
264 | data.resize(21); |
||
265 | for (int cd = 0; cd < KeyLen; ++cd) |
||
266 | { |
||
267 | data[cd] = EncryKey[cd]; |
||
268 | dlen++; |
||
269 | } |
||
270 | data[dlen++] = ObjNum; |
||
271 | data[dlen++] = ObjNum >> 8; |
||
272 | data[dlen++] = ObjNum >> 16; |
||
273 | data[dlen++] = 0; |
||
274 | data[dlen++] = 0; |
||
275 | QByteArray step1(16); |
||
276 | step1 = ComputeMD5Sum(&data); |
||
277 | rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), QMIN(KeyLen+5, 16)); |
||
278 | rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()), reinterpret_cast<uchar*>(ou.data()), tmp.length()); |
||
279 | QString uk = ""; |
||
280 | for (uint cl = 0; cl < tmp.length(); ++cl) |
||
281 | uk += QChar(ou[cl]); |
||
282 | tmp = uk; |
||
283 | } |
||
284 | else |
||
285 | tmp = *in; |
||
286 | return tmp; |
||
287 | } |
||
288 | |||
289 | QString PDFlib::EncString(QString in, int ObjNum) |
||
290 | { |
||
291 | rc4_context_t rc4; |
||
292 | QString tmp; |
||
293 | int dlen = 0; |
||
294 | if (Options->Encrypt) |
||
295 | { |
||
3366 | fschmid | 296 | if (in.length() < 3) |
297 | return "<>"; |
||
3133 | fschmid | 298 | tmp = in.mid(1, in.length()-2); |
299 | QByteArray us(tmp.length()); |
||
300 | QByteArray ou(tmp.length()); |
||
301 | for (uint a = 0; a < tmp.length(); ++a) |
||
302 | us[a] = static_cast<uchar>(QChar(tmp.at(a))); |
||
303 | QByteArray data(10); |
||
304 | if (KeyLen > 5) |
||
305 | data.resize(21); |
||
306 | for (int cd = 0; cd < KeyLen; ++cd) |
||
307 | { |
||
308 | data[cd] = EncryKey[cd]; |
||
309 | dlen++; |
||
310 | } |
||
311 | data[dlen++] = ObjNum; |
||
312 | data[dlen++] = ObjNum >> 8; |
||
313 | data[dlen++] = ObjNum >> 16; |
||
314 | data[dlen++] = 0; |
||
315 | data[dlen++] = 0; |
||
316 | QByteArray step1(16); |
||
317 | step1 = ComputeMD5Sum(&data); |
||
318 | rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), QMIN(KeyLen+5, 16)); |
||
319 | rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()), reinterpret_cast<uchar*>(ou.data()), tmp.length()); |
||
320 | QString uk = ""; |
||
321 | for (uint cl = 0; cl < tmp.length(); ++cl) |
||
322 | uk += QChar(ou[cl]); |
||
323 | tmp = "<"+String2Hex(&uk, false)+">"; |
||
324 | } |
||
325 | else |
||
326 | tmp = in; |
||
327 | return tmp; |
||
328 | } |
||
329 | |||
330 | QString PDFlib::FitKey(QString pass) |
||
331 | { |
||
332 | QString pw = pass; |
||
333 | if (pw.length() < 32) |
||
334 | { |
||
335 | uint l = pw.length(); |
||
336 | for (uint a = 0; a < 32 - l; ++a) |
||
337 | pw += QChar(KeyGen[a]); |
||
338 | } |
||
339 | else |
||
340 | pw = pw.left(32); |
||
341 | return pw; |
||
342 | } |
||
343 | |||
344 | void PDFlib::CalcOwnerKey(QString Owner, QString User) |
||
345 | { |
||
346 | rc4_context_t rc4; |
||
347 | QString pw = User; |
||
348 | QString pw2; |
||
349 | pw2 = Owner; |
||
350 | if (pw2.isEmpty()) |
||
351 | pw2 = User; |
||
352 | pw = FitKey(pw); |
||
353 | pw2 = FitKey(pw2); |
||
354 | QByteArray step1(16); |
||
355 | step1 = ComputeMD5(pw2); |
||
356 | if (KeyLen > 5) |
||
357 | { |
||
358 | for (int kl = 0; kl < 50; ++kl) |
||
359 | step1 = ComputeMD5Sum(&step1); |
||
360 | } |
||
361 | QByteArray us(32); |
||
362 | QByteArray enk(16); |
||
363 | if (KeyLen > 5) |
||
364 | { |
||
365 | for (uint a2 = 0; a2 < 32; ++a2) |
||
366 | OwnerKey[a2] = static_cast<uchar>(QChar(pw.at(a2))); |
||
367 | for (int rl = 0; rl < 20; rl++) |
||
368 | { |
||
369 | for (int j = 0; j < 16; j ++) |
||
370 | enk[j] = step1[j] ^ rl; |
||
371 | rc4_init(&rc4, reinterpret_cast<uchar*>(enk.data()), 16); |
||
372 | rc4_encrypt(&rc4, reinterpret_cast<uchar*>(OwnerKey.data()), |
||
373 | reinterpret_cast<uchar*>(OwnerKey.data()), 32); |
||
374 | } |
||
375 | } |
||
376 | else |
||
377 | { |
||
378 | for (uint a = 0; a < 32; ++a) |
||
379 | us[a] = static_cast<uchar>(QChar(pw.at(a))); |
||
380 | rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), 5); |
||
381 | rc4_encrypt(&rc4, reinterpret_cast<uchar*>(us.data()), |
||
382 | reinterpret_cast<uchar*>(OwnerKey.data()), 32); |
||
383 | } |
||
384 | } |
||
385 | |||
386 | void PDFlib::CalcUserKey(QString User, int Permission) |
||
387 | { |
||
388 | rc4_context_t rc4; |
||
389 | QString pw = User; |
||
390 | pw = FitKey(pw); |
||
391 | QByteArray step1(16); |
||
392 | QByteArray perm(4); |
||
393 | uint perm_value = static_cast<uint>(Permission); |
||
394 | perm[0] = perm_value; |
||
395 | perm[1] = perm_value >> 8; |
||
396 | perm[2] = perm_value >> 16; |
||
397 | perm[3] = perm_value >> 24; |
||
398 | for (uint a = 0; a < 32; ++a) |
||
399 | pw += QChar(OwnerKey[a]); |
||
400 | for (uint a1 = 0; a1 < 4; ++a1) |
||
401 | pw += QChar(perm[a1]); |
||
402 | for (uint a3 = 0; a3 < 16; ++a3) |
||
403 | pw += QChar(FileID[a3]); |
||
404 | step1 = ComputeMD5(pw); |
||
405 | if (KeyLen > 5) |
||
406 | { |
||
407 | for (int kl = 0; kl < 50; ++kl) |
||
408 | step1 = ComputeMD5Sum(&step1); |
||
409 | EncryKey.resize(16); |
||
410 | } |
||
411 | for (int a2 = 0; a2 < KeyLen; ++a2) |
||
412 | EncryKey[a2] = step1[a2]; |
||
413 | if (KeyLen > 5) |
||
414 | { |
||
415 | QString pr2 = ""; |
||
416 | for (int kl3 = 0; kl3 < 32; ++kl3) |
||
417 | pr2 += QChar(KeyGen[kl3]); |
||
418 | for (uint a4 = 0; a4 < 16; ++a4) |
||
419 | pr2 += QChar(FileID[a4]); |
||
420 | step1 = ComputeMD5(pr2); |
||
421 | QByteArray enk(16); |
||
422 | for (uint a3 = 0; a3 < 16; ++a3) |
||
423 | UserKey[a3] = step1[a3]; |
||
424 | for (int rl = 0; rl < 20; rl++) |
||
425 | { |
||
426 | for (int j = 0; j < 16; j ++) |
||
427 | enk[j] = EncryKey[j] ^ rl; |
||
428 | rc4_init(&rc4, reinterpret_cast<uchar*>(enk.data()), 16); |
||
429 | rc4_encrypt(&rc4, reinterpret_cast<uchar*>(UserKey.data()), reinterpret_cast<uchar*>(UserKey.data()), 16); |
||
430 | } |
||
431 | } |
||
432 | else |
||
433 | { |
||
434 | rc4_init(&rc4, reinterpret_cast<uchar*>(step1.data()), 5); |
||
435 | rc4_encrypt(&rc4, reinterpret_cast<uchar*>(KeyGen.data()), reinterpret_cast<uchar*>(UserKey.data()), 32); |
||
436 | } |
||
437 | } |
||
438 | |||
3829 | cbradney | 439 | QByteArray PDFlib::ComputeMD5(const QString& in) |
3133 | fschmid | 440 | { |
3829 | cbradney | 441 | uint inlen=in.length(); |
442 | QByteArray TBytes(inlen); |
||
443 | for (uint a = 0; a < inlen; ++a) |
||
3133 | fschmid | 444 | TBytes[a] = static_cast<uchar>(QChar(in.at(a))); |
445 | return ComputeMD5Sum(&TBytes); |
||
446 | } |
||
447 | |||
3829 | cbradney | 448 | bool PDFlib::PDF_Begin_Doc(const QString& fn, PDFOptions *opts, SCFonts &AllFonts, QMap<QString,int> DocFonts, BookMView* vi) |
3133 | fschmid | 449 | { |
450 | Spool.setName(fn); |
||
451 | if (!Spool.open(IO_WriteOnly)) |
||
452 | return false; |
||
3829 | cbradney | 453 | t.setDevice(&Spool); |
3133 | fschmid | 454 | QString tmp; |
455 | QString ok = ""; |
||
456 | QString uk = ""; |
||
457 | QFileInfo fd; |
||
458 | QString fext; |
||
459 | int a; |
||
460 | Bvie = vi; |
||
461 | Options = opts; |
||
462 | BookMinUse = false; |
||
463 | UsedFontsP.clear(); |
||
464 | if ((Options->Version == 15) && (Options->useLayers)) |
||
465 | ObjCounter = 10; |
||
466 | else |
||
467 | ObjCounter = 9; |
||
468 | switch (Options->Version) |
||
469 | { |
||
470 | case 12: |
||
471 | case 13: |
||
472 | PutDoc("%PDF-1.3\n"); |
||
473 | break; |
||
474 | case 14: |
||
475 | PutDoc("%PDF-1.4\n"); |
||
476 | break; |
||
477 | case 15: |
||
478 | PutDoc("%PDF-1.5\n"); |
||
479 | break; |
||
480 | } |
||
481 | if (Options->Version == 12) |
||
482 | ObjCounter++; |
||
483 | PutDoc("%"+QString(QChar(199))+QString(QChar(236))+QString(QChar(143))+QString(QChar(162))+"\n"); |
||
484 | StartObj(1); |
||
485 | PutDoc("<<\n/Type /Catalog\n/Outlines 3 0 R\n/Pages 4 0 R\n/Dests 5 0 R\n/AcroForm 6 0 R\n/Names 7 0 R\n/Threads 8 0 R\n"); |
||
486 | if ((Options->Version == 15) && (Options->useLayers)) |
||
487 | PutDoc("/OCProperties 9 0 R\n"); |
||
488 | if (Options->Version == 12) |
||
489 | PutDoc("/OutputIntents [ "+IToStr(ObjCounter-1)+" 0 R ]\n"); |
||
4197 | fschmid | 490 | PutDoc("/PageLayout "); |
491 | switch (Options->PageLayout) |
||
3133 | fschmid | 492 | { |
4197 | fschmid | 493 | case PDFOptions::SinglePage: |
494 | PutDoc("/SinglePage\n"); |
||
495 | break; |
||
496 | case PDFOptions::OneColumn: |
||
497 | PutDoc("/OneColumn\n"); |
||
498 | break; |
||
499 | case PDFOptions::TwoColumnLeft: |
||
500 | PutDoc("/TwoColumnLeft\n"); |
||
501 | break; |
||
502 | case PDFOptions::TwoColumnRight: |
||
503 | PutDoc("/TwoColumnRight\n"); |
||
504 | break; |
||
505 | } |
||
506 | if (Options->displayBookmarks) |
||
507 | PutDoc("/PageMode /UseOutlines\n"); |
||
508 | else if (Options->displayFullscreen) |
||
509 | PutDoc("/PageMode /FullScreen\n"); |
||
510 | else if (Options->displayThumbs) |
||
511 | PutDoc("/PageMode /UseThumbs\n"); |
||
512 | else if ((Options->Version == 15) && (Options->displayLayers)) |
||
513 | PutDoc("/PageMode /UseOC\n"); |
||
4201 | fschmid | 514 | if (!Options->openAction.isEmpty()) |
4197 | fschmid | 515 | { |
4201 | fschmid | 516 | PutDoc("/OpenAction << /S /JavaScript /JS (this."+Options->openAction+"\\(\\)) >>\n"); |
3133 | fschmid | 517 | } |
518 | PutDoc("/ViewerPreferences\n<<\n/PageDirection "); |
||
519 | PutDoc( Options->Binding == 0 ? "/L2R\n" : "/R2L\n"); |
||
4201 | fschmid | 520 | if (Options->hideToolBar) |
521 | PutDoc("/HideToolbar true\n"); |
||
522 | if (Options->hideMenuBar) |
||
523 | PutDoc("/HideMenubar true\n"); |
||
524 | if (Options->fitWindow) |
||
525 | PutDoc("/FitWindow true\n"); |
||
3133 | fschmid | 526 | PutDoc(" >>\n>>\nendobj\n"); |
3829 | cbradney | 527 | QString IDg(Datum); |
3133 | fschmid | 528 | IDg += Options->Datei; |
529 | IDg += "Scribus "+QString(VERSION); |
||
530 | IDg += "Libpdf for Scribus "+QString(VERSION); |
||
531 | IDg += doc->documentInfo.getTitle(); |
||
532 | IDg += doc->documentInfo.getAuthor(); |
||
533 | IDg += "/False"; |
||
534 | FileID = ComputeMD5(IDg); |
||
535 | if (Options->Encrypt) |
||
536 | { |
||
537 | KeyLen = Options->Version == 14 ? 16 : 5; |
||
538 | CalcOwnerKey(Options->PassOwner, Options->PassUser); |
||
539 | CalcUserKey(Options->PassUser, Options->Permissions); |
||
540 | for (uint cl2 = 0; cl2 < 32; ++cl2) |
||
541 | ok += QChar(OwnerKey[cl2]); |
||
542 | if (KeyLen > 5) |
||
543 | { |
||
544 | for (uint cl3 = 0; cl3 < 16; ++cl3) |
||
545 | uk += QChar(UserKey[cl3]); |
||
546 | for (uint cl3r = 0; cl3r < 16; ++cl3r) |
||
547 | uk += QChar(KeyGen[cl3r]); |
||
548 | } |
||
549 | else |
||
550 | { |
||
551 | for (uint cl = 0; cl < 32; ++cl) |
||
552 | uk += QChar(UserKey[cl]); |
||
553 | } |
||
554 | } |
||
555 | QDate d = QDate::currentDate(); |
||
556 | Datum = "D:"; |
||
557 | tmp.sprintf("%4d", d.year()); |
||
558 | tmp.replace(QRegExp(" "), "0"); |
||
559 | Datum += tmp; |
||
560 | tmp.sprintf("%2d", d.month()); |
||
561 | tmp.replace(QRegExp(" "), "0"); |
||
562 | Datum += tmp; |
||
563 | tmp.sprintf("%2d", d.day()); |
||
564 | tmp.replace(QRegExp(" "), "0"); |
||
565 | Datum += tmp; |
||
566 | QTime t = QTime::currentTime(); |
||
567 | tmp = t.toString(); |
||
568 | tmp.replace(QRegExp(":"), ""); |
||
569 | Datum += tmp; |
||
570 | StartObj(2); |
||
571 | PutDoc("<<\n/Creator "+EncString("(Scribus "+QString(VERSION)+")",2)+"\n"); |
||
572 | PutDoc("/Producer "+EncString("(Libpdf for Scribus "+QString(VERSION)+")",2)+"\n"); |
||
573 | PutDoc("/Title "+EncString("("+doc->documentInfo.getTitle()+")",2)+"\n"); |
||
574 | PutDoc("/Author "+EncString("("+doc->documentInfo.getAuthor()+")",2)+"\n"); |
||
575 | PutDoc("/Keywords "+EncString("("+doc->documentInfo.getKeywords()+")",2)+"\n"); |
||
576 | PutDoc("/CreationDate "+EncString("("+Datum+")",2)+"\n"); |
||
577 | PutDoc("/ModDate "+EncString("("+Datum+")",2)+"\n"); |
||
578 | if (Options->Version == 12) |
||
579 | PutDoc("/GTS_PDFXVersion (PDF/X-3:2002)\n"); |
||
580 | PutDoc("/Trapped /False\n>>\nendobj\n"); |
||
581 | for (int t = 0; t < 6; ++t) |
||
582 | XRef.append(Dokument); |
||
583 | if ((Options->Version == 15) && (Options->useLayers)) |
||
584 | XRef.append(Dokument); |
||
585 | if (Options->Version == 12) |
||
586 | XRef.append(Dokument); |
||
587 | if (Options->Encrypt) |
||
588 | { |
||
589 | StartObj(ObjCounter); |
||
590 | Encrypt = ObjCounter; |
||
591 | ObjCounter++; |
||
592 | PutDoc("<<\n/Filter /Standard\n"); |
||
593 | PutDoc( KeyLen > 5 ? "/R 3\n/V 2\n/Length 128\n" : "/R 2\n/V 1\n"); |
||
594 | PutDoc("/O <"+String2Hex(&ok)+">\n"); |
||
595 | PutDoc("/U <"+String2Hex(&uk)+">\n"); |
||
596 | PutDoc("/P "+IToStr(Options->Permissions)+"\n>>\nendobj\n"); |
||
597 | } |
||
598 | RealFonts = DocFonts; |
||
3544 | avox | 599 | QMap<QString,int> ReallyUsed; |
3133 | fschmid | 600 | ReallyUsed.clear(); |
601 | PageItem* pgit; |
||
4017 | fschmid | 602 | QMap<int, QString> ind2PDFabr; |
603 | const QString tmpf[] = {"/Courier", "/Courier-Bold", "/Courier-Oblique", "/Courier-BoldOblique", |
||
604 | "/Helvetica", "/Helvetica-Bold", "/Helvetica-Oblique", "/Helvetica-BoldOblique", |
||
605 | "/Times-Roman", "/Times-Bold", "/Times-Italic", "/Times-BoldItalic", |
||
606 | "/ZapfDingbats", "/Symbol"}; |
||
607 | size_t ar = sizeof(tmpf) / sizeof(*tmpf); |
||
608 | for (uint ax = 0; ax < ar; ++ax) |
||
609 | ind2PDFabr[ax] = tmpf[ax]; |
||
3133 | fschmid | 610 | for (uint c = 0; c < doc->FrameItems.count(); ++c) |
611 | { |
||
612 | pgit = doc->FrameItems.at(c); |
||
613 | if ((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) |
||
614 | { |
||
4084 | cbradney | 615 | if (pgit->isAnnotation()) |
616 | StdFonts.insert(ind2PDFabr[pgit->annotation().Font()], ""); |
||
3133 | fschmid | 617 | for (uint e = 0; e < pgit->itemText.count(); ++e) |
618 | { |
||
3544 | avox | 619 | ReallyUsed.insert(pgit->itemText.at(e)->cfont->scName(), DocFonts[pgit->itemText.at(e)->cfont->scName()]); |
3133 | fschmid | 620 | } |
621 | } |
||
622 | } |
||
623 | for (uint c = 0; c < doc->MasterItems.count(); ++c) |
||
624 | { |
||
625 | pgit = doc->MasterItems.at(c); |
||
626 | if ((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) |
||
627 | { |
||
4084 | cbradney | 628 | if (pgit->isAnnotation()) |
629 | StdFonts.insert(ind2PDFabr[pgit->annotation().Font()], ""); |
||
3133 | fschmid | 630 | for (uint e = 0; e < pgit->itemText.count(); ++e) |
631 | { |
||
3544 | avox | 632 | ReallyUsed.insert(pgit->itemText.at(e)->cfont->scName(), DocFonts[pgit->itemText.at(e)->cfont->scName()]); |
3133 | fschmid | 633 | } |
634 | } |
||
635 | } |
||
3727 | cbradney | 636 | for (uint d = 0; d < doc->Items->count(); ++d) |
3133 | fschmid | 637 | { |
3727 | cbradney | 638 | pgit = doc->Items->at(d); |
3133 | fschmid | 639 | if ((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) |
640 | { |
||
4084 | cbradney | 641 | if (pgit->isAnnotation()) |
642 | StdFonts.insert(ind2PDFabr[pgit->annotation().Font()], ""); |
||
3133 | fschmid | 643 | for (uint e = 0; e < pgit->itemText.count(); ++e) |
644 | { |
||
3544 | avox | 645 | ReallyUsed.insert(pgit->itemText.at(e)->cfont->scName(), DocFonts[pgit->itemText.at(e)->cfont->scName()]); |
3133 | fschmid | 646 | } |
647 | } |
||
648 | } |
||
4017 | fschmid | 649 | a = 0; |
650 | QMap<QString, QString>::Iterator itStd; |
||
651 | for (itStd = StdFonts.begin(); itStd != StdFonts.end(); ++itStd) |
||
652 | { |
||
653 | StartObj(ObjCounter); |
||
654 | PutDoc("<<\n/Type /Font\n/Subtype /Type1\n"); |
||
655 | PutDoc("/BaseFont "+itStd.key()+"\n"); |
||
656 | PutDoc(">>\nendobj\n"); |
||
657 | Seite.FObjects["FoStd"+IToStr(a)] = ObjCounter; |
||
658 | itStd.data() = "FoStd"+IToStr(a); |
||
659 | ObjCounter++; |
||
660 | a++; |
||
661 | } |
||
3544 | avox | 662 | QMap<QString,int>::Iterator it; |
3133 | fschmid | 663 | a = 0; |
664 | for (it = ReallyUsed.begin(); it != ReallyUsed.end(); ++it) |
||
665 | { |
||
666 | Foi::FontFormat fformat = AllFonts[it.key()]->formatCode; |
||
667 | if ((AllFonts[it.key()]->isOTF) || (!AllFonts[it.key()]->HasNames) || (AllFonts[it.key()]->Subset) || (Options->SubsetList.contains(it.key()))) |
||
668 | { |
||
3829 | cbradney | 669 | QString fon(""); |
3133 | fschmid | 670 | QMap<uint,FPointArray>::Iterator ig; |
671 | for (ig = AllFonts[it.key()]->RealGlyphs.begin(); ig != AllFonts[it.key()]->RealGlyphs.end(); ++ig) |
||
672 | { |
||
673 | FPoint np, np1, np2; |
||
674 | bool nPath = true; |
||
675 | if (ig.data().size() > 3) |
||
676 | { |
||
677 | FPointArray gly = ig.data().copy(); |
||
678 | QWMatrix mat; |
||
679 | mat.scale(0.1, 0.1); |
||
680 | gly.map(mat); |
||
681 | for (uint poi = 0; poi < gly.size()-3; poi += 4) |
||
682 | { |
||
683 | if (gly.point(poi).x() > 900000) |
||
684 | { |
||
685 | fon += "h\n"; |
||
686 | nPath = true; |
||
687 | continue; |
||
688 | } |
||
689 | if (nPath) |
||
690 | { |
||
691 | np = gly.point(poi); |
||
692 | fon += FToStr(np.x())+" "+FToStr(-np.y())+" m\n"; |
||
693 | nPath = false; |
||
694 | } |
||
695 | np = gly.point(poi+1); |
||
696 | np1 = gly.point(poi+3); |
||
697 | np2 = gly.point(poi+2); |
||
698 | fon += FToStr(np.x()) + " " + FToStr(-np.y()) + " " + |
||
699 | FToStr(np1.x()) + " " + FToStr(-np1.y()) + " " + |
||
700 | FToStr(np2.x()) + " " + FToStr(-np2.y()) + " c\n"; |
||
701 | } |
||
702 | fon += "h f*\n"; |
||
703 | StartObj(ObjCounter); |
||
704 | ObjCounter++; |
||
705 | np = getMinClipF(&gly); |
||
706 | np1 = getMaxClipF(&gly); |
||
707 | PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1\n"); |
||
708 | PutDoc("/BBox [ "+FToStr(np.x())+" "+FToStr(-np.y())+" "+FToStr(np1.x())+ " "+FToStr(-np1.y())+" ]\n"); |
||
709 | PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n"); |
||
710 | PutDoc(">>\n"); |
||
711 | if ((Options->Compress) && (CompAvail)) |
||
712 | fon = CompressStr(&fon); |
||
713 | PutDoc("/Length "+IToStr(fon.length()+1)); |
||
714 | if ((Options->Compress) && (CompAvail)) |
||
715 | PutDoc("\n/Filter /FlateDecode"); |
||
716 | PutDoc(" >>\nstream\n"+EncStream(&fon, ObjCounter-1)+"\nendstream\nendobj\n"); |
||
3440 | fschmid | 717 | Seite.XObjects[AllFonts[it.key()]->RealName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+IToStr(ig.key())] = ObjCounter-1; |
3133 | fschmid | 718 | fon = ""; |
719 | } |
||
720 | } |
||
721 | AllFonts[it.key()]->RealGlyphs.clear(); |
||
722 | } |
||
723 | else |
||
724 | { |
||
725 | UsedFontsP.insert(it.key(), "/Fo"+IToStr(a)); |
||
726 | if ((fformat == Foi::PFB) && (Options->EmbedList.contains(it.key()))) |
||
727 | { |
||
3829 | cbradney | 728 | QString fon(""); |
3133 | fschmid | 729 | StartObj(ObjCounter); |
730 | QByteArray bb; |
||
731 | AllFonts[it.key()]->RawData(bb); |
||
732 | uint posi; |
||
733 | for (posi = 6; posi < bb.size(); ++posi) |
||
734 | { |
||
735 | if ((bb[posi] == static_cast<char>(0x80)) && (static_cast<int>(bb[posi+1]) == 2)) |
||
736 | break; |
||
737 | fon += QChar(bb[posi]); |
||
738 | } |
||
739 | int len1 = fon.length(); |
||
740 | uint ulen; |
||
741 | ulen = bb[posi+2] & 0xff; |
||
742 | ulen |= (bb[posi+3] << 8) & 0xff00; |
||
743 | ulen |= (bb[posi+4] << 16) & 0xff0000; |
||
744 | ulen |= (bb[posi+5] << 24) & 0xff000000; |
||
745 | if (ulen > bb.size()) |
||
746 | ulen = bb.size()-7; |
||
747 | posi += 6; |
||
748 | for (uint j = 0; j < ulen; ++j) |
||
749 | fon += QChar(bb[posi++]); |
||
750 | posi += 6; |
||
751 | int len2 = fon.length()-len1; |
||
752 | for (uint j = posi; j < bb.size(); ++j) |
||
753 | { |
||
754 | if ((bb[j] == static_cast<char>(0x80)) && (static_cast<int>(bb[j+1]) == 3)) |
||
755 | break; |
||
756 | if (bb[j] == '\r') |
||
757 | fon += "\n"; |
||
758 | else |
||
759 | fon += QChar(bb[j]); |
||
760 | } |
||
761 | int len3 = fon.length()-len2-len1; |
||
762 | if ((Options->Compress) && (CompAvail)) |
||
763 | fon = CompressStr(&fon); |
||
764 | PutDoc("<<\n/Length "+IToStr(fon.length()+1)+"\n"); |
||
765 | PutDoc("/Length1 "+IToStr(len1)+"\n"); |
||
766 | PutDoc("/Length2 "+IToStr(len2)+"\n"); |
||
767 | PutDoc("/Length3 "+IToStr(len3)+"\n"); |
||
768 | if ((Options->Compress) && (CompAvail)) |
||
769 | PutDoc("/Filter /FlateDecode\n"); |
||
770 | PutDoc(">>\nstream\n"+EncStream(&fon,ObjCounter)+"\nendstream\nendobj\n"); |
||
771 | ObjCounter++; |
||
772 | } |
||
773 | if ((fformat == Foi::PFA) && (Options->EmbedList.contains(it.key()))) |
||
774 | { |
||
3829 | cbradney | 775 | QString fon(""); |
776 | QString fon2(""); |
||
777 | QString tm(""); |
||
3133 | fschmid | 778 | uint value; |
779 | bool ok = true; |
||
780 | StartObj(ObjCounter); |
||
781 | AllFonts[it.key()]->EmbedFont(fon); |
||
782 | int len1 = fon.find("eexec")+5; |
||
783 | fon2 = fon.left(len1)+"\n"; |
||
784 | int len2 = fon.find("0000000000000000000000000"); |
||
785 | if (len2 == -1) |
||
786 | len2 = fon.length()+1; |
||
787 | int count = 0; |
||
788 | for (int xx = len1; xx < len2-1; ++xx) |
||
789 | { |
||
790 | tm = fon.at(xx); |
||
791 | if ((tm == QChar(13)) || (tm == QChar(10))) |
||
792 | continue; |
||
793 | xx++; |
||
794 | count++; |
||
795 | tm += fon.at(xx); |
||
796 | value = tm.toUInt(&ok, 16); |
||
797 | fon2 += QChar(value); |
||
798 | } |
||
799 | fon2 += fon.mid(len2); |
||
800 | if ((Options->Compress) && (CompAvail)) |
||
801 | fon2 = CompressStr(&fon2); |
||
802 | PutDoc("<<\n/Length "+IToStr(fon2.length()+1)+"\n"); |
||
803 | PutDoc("/Length1 "+IToStr(len1+1)+"\n"); |
||
804 | PutDoc("/Length2 "+IToStr(count)+"\n"); |
||
805 | PutDoc(static_cast<int>(fon.length()-len2) == -1 ? QString("/Length3 0\n") : "/Length3 "+IToStr(fon.length()-len2)+"\n"); |
||
806 | if ((Options->Compress) && (CompAvail)) |
||
807 | PutDoc("/Filter /FlateDecode\n"); |
||
808 | PutDoc(">>\nstream\n"+EncStream(&fon2, ObjCounter)+"\nendstream\nendobj\n"); |
||
809 | ObjCounter++; |
||
810 | } |
||
811 | if ((fformat == Foi::SFNT || fformat == Foi::TTCF) && (Options->EmbedList.contains(it.key()))) |
||
812 | { |
||
3829 | cbradney | 813 | QString fon(""); |
3133 | fschmid | 814 | StartObj(ObjCounter); |
815 | QByteArray bb; |
||
816 | AllFonts[it.key()]->RawData(bb); |
||
817 | //AV: += and append() dont't work because they stop at '\0' :-( |
||
818 | for (unsigned int i=0; i < bb.size(); i++) |
||
819 | fon += QChar(bb[i]); |
||
820 | int len = fon.length(); |
||
821 | if ((Options->Compress) && (CompAvail)) |
||
822 | fon = CompressStr(&fon); |
||
823 | //qDebug(QString("sfnt data: size=%1 before=%2 compressed=%3").arg(bb.size()).arg(len).arg(fon.length())); |
||
824 | PutDoc("<<\n/Length "+IToStr(fon.length()+1)+"\n"); |
||
825 | PutDoc("/Length1 "+IToStr(len)+"\n"); |
||
826 | if ((Options->Compress) && (CompAvail)) |
||
827 | PutDoc("/Filter /FlateDecode\n"); |
||
828 | PutDoc(">>\nstream\n"+EncStream(&fon, ObjCounter)+"\nendstream\nendobj\n"); |
||
829 | ObjCounter++; |
||
830 | } |
||
831 | StartObj(ObjCounter); |
||
832 | PutDoc("<<\n/Type /FontDescriptor\n"); |
||
3440 | fschmid | 833 | PutDoc("/FontName /"+AllFonts[it.key()]->RealName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n"); |
3133 | fschmid | 834 | PutDoc("/FontBBox [ "+AllFonts[it.key()]->FontBBox+" ]\n"); |
835 | PutDoc("/Flags "); |
||
3544 | avox | 836 | //FIXME: isItalic() should be queried from Foi, not from Qt -- AV |
837 | //QFontInfo fo = QFontInfo(it.data()); |
||
3133 | fschmid | 838 | int pfl = 0; |
839 | if (AllFonts[it.key()]->IsFixedPitch) |
||
840 | pfl = pfl ^ 1; |
||
3544 | avox | 841 | //if (fo.italic()) |
842 | if (AllFonts[it.key()]->ItalicAngle != "0") |
||
3133 | fschmid | 843 | pfl = pfl ^ 64; |
844 | // pfl = pfl ^ 4; |
||
845 | pfl = pfl ^ 32; |
||
846 | PutDoc(IToStr(pfl)+"\n"); |
||
847 | PutDoc("/Ascent "+AllFonts[it.key()]->Ascent+"\n"); |
||
848 | PutDoc("/Descent "+AllFonts[it.key()]->Descender+"\n"); |
||
849 | PutDoc("/CapHeight "+AllFonts[it.key()]->CapHeight+"\n"); |
||
850 | PutDoc("/ItalicAngle "+AllFonts[it.key()]->ItalicAngle+"\n"); |
||
851 | PutDoc("/StemV "+AllFonts[it.key()]->StdVW+"\n"); |
||
852 | if ((fformat == Foi::SFNT || fformat == Foi::TTCF) && (Options->EmbedList.contains(it.key()))) |
||
853 | PutDoc("/FontFile2 "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
854 | if ((fformat == Foi::PFB) && (Options->EmbedList.contains(it.key()))) |
||
855 | PutDoc("/FontFile "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
856 | if ((fformat == Foi::PFA) && (Options->EmbedList.contains(it.key()))) |
||
857 | PutDoc("/FontFile "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
858 | PutDoc(">>\nendobj\n"); |
||
859 | ObjCounter++; |
||
860 | /* if (!FT_Has_PS_Glyph_Names(AllFonts[it.key()]) |
||
861 | { |
||
862 | StartObj(ObjCounter); |
||
863 | int chCount = 31; |
||
864 | PutDoc("[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "); |
||
865 | for (int ww = 31; ww < 256; ++ww) |
||
866 | { |
||
867 | PutDoc(IToStr(static_cast<int>(AllFonts[it.key()]->CharWidth[itg.key()]* |
||
868 | 1000))+" "); |
||
869 | if (itg == gl.end()) |
||
870 | break; |
||
871 | ++itg; |
||
872 | chCount++; |
||
873 | } |
||
874 | PutDoc("]\nendobj\n"); |
||
875 | ObjCounter++; |
||
876 | // put widths object |
||
877 | // encoding dictionary w/ base encoding w/o differences |
||
878 | StartObj(ObjCounter); |
||
879 | PutDoc("<<\n/Type /Font\n/Subtype "); |
||
880 | PutDoc((fformat == Foi::SFNT || fformat == Foi::TTCF) ? "/TrueType\n" : "/Type1\n"); |
||
881 | PutDoc("/Name /Fo"+IToStr(a)+"\n"); |
||
3304 | fschmid | 882 | PutDoc("/BaseFont /"+AllFonts[it.key()]->RealName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "" )+"\n"); |
3133 | fschmid | 883 | //cf. widths: |
884 | PutDoc("/FirstChar 0\n"); |
||
885 | PutDoc("/LastChar "+IToStr(chCount-1)+"\n"); |
||
886 | PutDoc("/Widths "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
887 | PutDoc("/FontDescriptor "+IToStr(ObjCounter-2)+" 0 R\n"); |
||
888 | PutDoc(">>\nendobj\n"); |
||
889 | Seite.FObjects["Fo"+IToStr(a)] = ObjCounter; |
||
890 | ObjCounter++; |
||
891 | } |
||
892 | else */ |
||
893 | // { |
||
894 | GListeInd gl; |
||
895 | GlyIndex(AllFonts[it.key()], &gl); |
||
896 | GlyphsIdxOfFont.insert(it.key(), gl); |
||
897 | uint FontDes = ObjCounter - 1; |
||
898 | GListeInd::Iterator itg; |
||
899 | itg = gl.begin(); |
||
900 | GListeInd::Iterator itg2; |
||
901 | itg2 = gl.begin(); |
||
902 | uint Fcc = gl.count() / 224; |
||
903 | if ((gl.count() % 224) != 0) |
||
904 | Fcc += 1; |
||
905 | for (uint Fc = 0; Fc < Fcc; ++Fc) |
||
906 | { |
||
907 | StartObj(ObjCounter); |
||
908 | int chCount = 31; |
||
909 | PutDoc("[ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 "); |
||
910 | for (int ww = 31; ww < 256; ++ww) |
||
911 | { |
||
912 | PutDoc(IToStr(static_cast<int>(AllFonts[it.key()]->CharWidth[itg.key()]* 1000))+" "); |
||
913 | if (itg == gl.end()) |
||
914 | break; |
||
915 | ++itg; |
||
916 | chCount++; |
||
917 | } |
||
918 | PutDoc("]\nendobj\n"); |
||
919 | ObjCounter++; |
||
920 | StartObj(ObjCounter); |
||
921 | ObjCounter++; |
||
922 | PutDoc("<< /Type /Encoding\n"); |
||
923 | // PutDoc("/BaseEncoding /" + AllFonts[it.key()]->FontEnc + "\n"); |
||
924 | PutDoc("/Differences [ 32\n"); |
||
925 | int crc = 0; |
||
926 | for (int ww2 = 32; ww2 < 256; ++ww2) |
||
927 | { |
||
928 | PutDoc(itg2.data().Name+" "); |
||
929 | if (itg2 == gl.end()) |
||
930 | break; |
||
931 | ++itg2; |
||
932 | crc++; |
||
933 | if (crc > 8) |
||
934 | { |
||
935 | PutDoc("\n"); |
||
936 | crc = 0; |
||
937 | } |
||
938 | } |
||
939 | PutDoc("]\n"); |
||
940 | |||
941 | PutDoc(">>\nendobj\n"); |
||
942 | StartObj(ObjCounter); |
||
943 | PutDoc("<<\n/Type /Font\n/Subtype "); |
||
944 | PutDoc((fformat == Foi::SFNT || fformat == Foi::TTCF) ? "/TrueType\n" : "/Type1\n"); |
||
945 | PutDoc("/Name /Fo"+IToStr(a)+"S"+IToStr(Fc)+"\n"); |
||
3440 | fschmid | 946 | PutDoc("/BaseFont /"+AllFonts[it.key()]->RealName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n"); |
3133 | fschmid | 947 | PutDoc("/FirstChar 0\n"); |
948 | PutDoc("/LastChar "+IToStr(chCount-1)+"\n"); |
||
949 | PutDoc("/Widths "+IToStr(ObjCounter-2)+" 0 R\n"); |
||
950 | PutDoc("/Encoding "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
951 | PutDoc("/FontDescriptor "+IToStr(FontDes)+" 0 R\n"); |
||
952 | PutDoc(">>\nendobj\n"); |
||
953 | Seite.FObjects["Fo"+IToStr(a)+"S"+IToStr(Fc)] = ObjCounter; |
||
954 | ObjCounter++; |
||
955 | } // for(Fc) |
||
956 | // } // FT_Has_PS_Glyph_Names |
||
957 | } |
||
958 | a++; |
||
959 | } |
||
960 | if (Options->UseLPI) |
||
961 | { |
||
962 | StartObj(ObjCounter); |
||
963 | PutDoc("<<\n/Type /Halftone\n/HalftoneType 5\n"); |
||
964 | QMap<QString,LPIData>::Iterator itlp; |
||
965 | for (itlp = Options->LPISettings.begin(); itlp != Options->LPISettings.end(); ++itlp) |
||
966 | { |
||
967 | PutDoc("/"+itlp.key()+"\n<<\n/Type /Halftone\n/HalftoneType 1\n/Frequency "); |
||
968 | PutDoc(IToStr(itlp.data().Frequency)+"\n/Angle "+IToStr(itlp.data().Angle)+"\n/SpotFunction "); |
||
3829 | cbradney | 969 | QString func (""); |
3133 | fschmid | 970 | switch (itlp.data().SpotFunc) |
971 | { |
||
972 | case 0: |
||
973 | func = "/SimpleDot"; |
||
974 | break; |
||
975 | case 1: |
||
976 | func = "/Line"; |
||
977 | break; |
||
978 | case 2: |
||
979 | func = "/Round"; |
||
980 | break; |
||
981 | case 3: |
||
982 | func = "/Ellipse"; |
||
983 | break; |
||
984 | default: |
||
985 | func = "/SimpleDot"; |
||
986 | break; |
||
987 | } |
||
988 | PutDoc(func+"\n>>\n"); |
||
989 | } |
||
990 | PutDoc("/Default\n<<\n/Type /Halftone\n/HalftoneType 1\n/Frequency 50\n/Angle 45\n/SpotFunction /Round\n>>\n"); |
||
991 | PutDoc(">>\nendobj\n"); |
||
992 | ObjCounter++; |
||
993 | StartObj(ObjCounter); |
||
994 | HTName = ResNam+IToStr(ResCount); |
||
995 | Transpar[HTName] = ObjCounter; |
||
996 | PutDoc("<< /Type /ExtGState\n/HT "+IToStr(ObjCounter-1)+" 0 R\n>>\nendobj\n"); |
||
997 | ResCount++; |
||
998 | ObjCounter++; |
||
999 | } |
||
1000 | #ifdef HAVE_CMS |
||
1001 | if ((CMSuse) && (Options->UseProfiles)) |
||
1002 | { |
||
1003 | StartObj(ObjCounter); |
||
1004 | ObjCounter++; |
||
1005 | QString dataP; |
||
1006 | struct ICCD dataD; |
||
4026 | craig | 1007 | loadText(ScMW->InputProfiles[Options->SolidProf], &dataP); |
3133 | fschmid | 1008 | PutDoc("<<\n"); |
1009 | if ((Options->Compress) && (CompAvail)) |
||
1010 | { |
||
1011 | PutDoc("/Filter /FlateDecode\n"); |
||
1012 | dataP = CompressStr(&dataP); |
||
1013 | } |
||
1014 | PutDoc("/Length "+IToStr(dataP.length()+1)+"\n"); |
||
1015 | PutDoc("/N "+IToStr(Options->SComp)+"\n"); |
||
1016 | PutDoc(">>\nstream\n"+EncStream(&dataP, ObjCounter-1)+"\nendstream\nendobj\n"); |
||
1017 | StartObj(ObjCounter); |
||
1018 | dataD.ResName = ResNam+IToStr(ResCount); |
||
1019 | dataD.ICCArray = "[ /ICCBased "+IToStr(ObjCounter-1)+" 0 R ]"; |
||
1020 | dataD.ResNum = ObjCounter; |
||
1021 | ICCProfiles[Options->SolidProf] = dataD; |
||
1022 | PutDoc("[ /ICCBased "+IToStr(ObjCounter-1)+" 0 R ]\n"); |
||
1023 | PutDoc("endobj\n"); |
||
1024 | ResCount++; |
||
1025 | ObjCounter++; |
||
1026 | } |
||
1027 | #endif |
||
1028 | if (((Options->isGrayscale == false) && (Options->UseRGB == false)) && (Options->UseSpotColors)) |
||
1029 | { |
||
1030 | doc->getUsedColors(colorsToUse); |
||
1031 | ColorList::Iterator itf; |
||
1032 | for (itf = colorsToUse.begin(); itf != colorsToUse.end(); ++itf) |
||
1033 | { |
||
1034 | if ((colorsToUse[itf.key()].isSpotColor()) || (colorsToUse[itf.key()].isRegistrationColor())) |
||
1035 | { |
||
1036 | int cc, cm, cy, ck; |
||
1037 | struct SpotC spotD; |
||
1038 | colorsToUse[itf.key()].getCMYK(&cc, &cm, &cy, &ck); |
||
1039 | QString colorDesc = "{\ndup "+FToStr(static_cast<double>(cc) / 255)+"\nmul exch dup "; |
||
1040 | colorDesc += FToStr(static_cast<double>(cm) / 255)+"\nmul exch dup "; |
||
1041 | colorDesc += FToStr(static_cast<double>(cy) / 255)+"\nmul exch "; |
||
1042 | colorDesc += FToStr(static_cast<double>(ck) / 255)+" mul }"; |
||
1043 | StartObj(ObjCounter); |
||
1044 | ObjCounter++; |
||
1045 | PutDoc("<<\n/FunctionType 4\n"); |
||
1046 | PutDoc("/Domain [0.0 1.0]\n"); |
||
1047 | PutDoc("/Range [0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]\n"); |
||
1048 | PutDoc("/Length "+IToStr(colorDesc.length()+1)+"\n"); |
||
1049 | PutDoc(">>\nstream\n"+EncStream(&colorDesc, ObjCounter-1)+"\nendstream\nendobj\n"); |
||
1050 | StartObj(ObjCounter); |
||
1051 | PutDoc("[ /Separation /"); |
||
1052 | if (colorsToUse[itf.key()].isRegistrationColor()) |
||
1053 | PutDoc("All"); |
||
1054 | else |
||
3440 | fschmid | 1055 | PutDoc(itf.key().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ).replace("#", "_")); |
3133 | fschmid | 1056 | PutDoc(" /DeviceCMYK "+IToStr(ObjCounter-1)+" 0 R ]\nendobj\n"); |
1057 | spotD.ResName = spotNam+IToStr(spotCount); |
||
1058 | spotD.ResNum = ObjCounter; |
||
1059 | spotMap.insert(itf.key(), spotD); |
||
1060 | spotCount++; |
||
1061 | ObjCounter++; |
||
1062 | } |
||
1063 | } |
||
1064 | } |
||
1065 | if ((Options->Version == 15) && (Options->useLayers)) |
||
1066 | { |
||
1067 | struct Layer ll; |
||
1068 | struct OCGInfo ocg; |
||
1069 | ll.isPrintable = false; |
||
1070 | ll.LNr = 0; |
||
1071 | int Lnr = 0; |
||
3829 | cbradney | 1072 | QString ocgNam("oc"); |
1073 | uint docLayersCount=doc->Layers.count(); |
||
1074 | for (uint la = 0; la < docLayersCount; ++la) |
||
3133 | fschmid | 1075 | { |
3829 | cbradney | 1076 | QString tmp(""); |
3133 | fschmid | 1077 | Level2Layer(doc, &ll, Lnr); |
1078 | ocg.Name = ocgNam+tmp.setNum(ll.LNr); |
||
1079 | ocg.ObjNum = ObjCounter; |
||
1080 | ocg.visible = ll.isViewable; |
||
1081 | OCGEntries.insert(ll.Name, ocg); |
||
1082 | StartObj(ObjCounter); |
||
1083 | ObjCounter++; |
||
1084 | PutDoc("<<\n"); |
||
1085 | PutDoc("/Type /OCG\n"); |
||
1086 | PutDoc("/Name ("+ll.Name+")\n"); |
||
1087 | PutDoc(">>\nendobj\n"); |
||
1088 | Lnr++; |
||
1089 | } |
||
1090 | } |
||
1091 | return true; |
||
1092 | } |
||
1093 | |||
1094 | void PDFlib::PDF_TemplatePage(Page* pag, bool ) |
||
1095 | { |
||
1096 | QString tmp; |
||
1097 | ActPageP = pag; |
||
1098 | PageItem* ite; |
||
1099 | QPtrList<PageItem> PItems; |
||
1100 | int Lnr = 0; |
||
1101 | struct Layer ll; |
||
1102 | ll.isPrintable = false; |
||
1103 | ll.LNr = 0; |
||
1104 | Inhalt = ""; |
||
1105 | Seite.AObjects.clear(); |
||
1106 | for (uint la = 0; la < doc->Layers.count(); ++la) |
||
1107 | { |
||
1108 | Level2Layer(doc, &ll, Lnr); |
||
1109 | PItems = doc->MasterItems; |
||
1110 | if (ll.isPrintable) |
||
1111 | { |
||
1112 | if ((Options->Version == 15) && (Options->useLayers)) |
||
1113 | PutPage("/OC /"+OCGEntries[ll.Name].Name+" BDC\n"); |
||
1114 | for (uint a = 0; a < PItems.count(); ++a) |
||
1115 | { |
||
1116 | Inhalt = ""; |
||
1117 | ite =PItems.at(a); |
||
1118 | if (ite->LayerNr != ll.LNr) |
||
1119 | continue; |
||
3200 | cbradney | 1120 | int x = static_cast<int>(pag->xOffset()); |
1121 | int y = static_cast<int>(pag->yOffset()); |
||
1122 | int w = static_cast<int>(pag->width()); |
||
1123 | int h1 = static_cast<int>(pag->height()); |
||
3133 | fschmid | 1124 | int x2 = static_cast<int>(ite->BoundingX - ite->Pwidth / 2.0); |
1125 | int y2 = static_cast<int>(ite->BoundingY - ite->Pwidth / 2.0); |
||
1126 | int w2 = static_cast<int>(ite->BoundingW + ite->Pwidth); |
||
1127 | int h2 = static_cast<int>(ite->BoundingH + ite->Pwidth); |
||
1128 | if (!QRect(x, y, w, h1).intersects(QRect(x2, y2, w2, h2))) |
||
1129 | continue; |
||
1130 | if (ite->ChangedMasterItem) |
||
1131 | continue; |
||
3200 | cbradney | 1132 | if ((!pag->PageNam.isEmpty()) && (ite->OwnPage != static_cast<int>(pag->pageNr())) && (ite->OwnPage != -1)) |
3133 | fschmid | 1133 | continue; |
1134 | PutPage("q\n"); |
||
1135 | if (((ite->fillTransparency() != 0) || (ite->lineTransparency() != 0)) && (Options->Version >= 14)) |
||
1136 | PutPage(PDF_Transparenz(ite)); |
||
1137 | if ((ite->isBookmark) && (Options->Bookmarks)) |
||
3903 | cbradney | 1138 | PDF_Bookmark(ite->BMnr, pag->height() - (ite->yPos() - pag->yOffset())); |
3133 | fschmid | 1139 | if (!ite->printable() || ((ite->itemType() == PageItem::TextFrame) && (!pag->PageNam.isEmpty()))) |
1140 | { |
||
1141 | PutPage("Q\n"); |
||
1142 | continue; |
||
1143 | } |
||
1144 | if (ite->fillColor() != "None") |
||
1145 | PutPage(putColor(ite->fillColor(), ite->fillShade(), true)); |
||
1146 | if (ite->lineColor() != "None") |
||
1147 | PutPage(putColor(ite->lineColor(), ite->lineShade(), false)); |
||
1148 | Inhalt += FToStr(fabs(ite->Pwidth))+" w\n"; |
||
1149 | if (ite->DashValues.count() != 0) |
||
1150 | { |
||
1151 | PutPage("[ "); |
||
1152 | QValueList<double>::iterator it; |
||
1153 | for ( it = ite->DashValues.begin(); it != ite->DashValues.end(); ++it ) |
||
1154 | { |
||
1155 | int da = static_cast<int>(*it); |
||
1156 | if (da != 0) |
||
1157 | PutPage(IToStr(da)+" "); |
||
1158 | } |
||
1159 | PutPage("] "+IToStr(static_cast<int>(ite->DashOffset))+" d\n"); |
||
1160 | } |
||
1161 | else |
||
1162 | { |
||
1163 | QString Dt = FToStr(QMAX(2*fabs(ite->Pwidth), 1)); |
||
1164 | QString Da = FToStr(QMAX(6*fabs(ite->Pwidth), 1)); |
||
1165 | switch (ite->PLineArt) |
||
1166 | { |
||
1167 | case Qt::SolidLine: |
||
1168 | PutPage("[] 0 d\n"); |
||
1169 | break; |
||
1170 | case Qt::DashLine: |
||
1171 | PutPage("["+Da+" "+Dt+"] 0 d\n"); |
||
1172 | break; |
||
1173 | case Qt::DotLine: |
||
1174 | PutPage("["+Dt+"] 0 d\n"); |
||
1175 | break; |
||
1176 | case Qt::DashDotLine: |
||
1177 | PutPage("["+Da+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n"); |
||
1178 | break; |
||
1179 | case Qt::DashDotDotLine: |
||
1180 | PutPage("["+Da+" "+Dt+" "+Dt+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n"); |
||
1181 | break; |
||
1182 | default: |
||
1183 | PutPage("[] 0 d\n"); |
||
1184 | break; |
||
1185 | } |
||
1186 | } |
||
1187 | switch (ite->PLineEnd) |
||
1188 | { |
||
1189 | case Qt::FlatCap: |
||
1190 | PutPage("0 J\n"); |
||
1191 | break; |
||
1192 | case Qt::SquareCap: |
||
1193 | PutPage("2 J\n"); |
||
1194 | break; |
||
1195 | case Qt::RoundCap: |
||
1196 | PutPage("1 J\n"); |
||
1197 | break; |
||
1198 | default: |
||
1199 | PutPage("0 J\n"); |
||
1200 | break; |
||
1201 | } |
||
1202 | switch (ite->PLineJoin) |
||
1203 | { |
||
1204 | case Qt::MiterJoin: |
||
1205 | PutPage("0 j\n"); |
||
1206 | break; |
||
1207 | case Qt::BevelJoin: |
||
1208 | PutPage("2 j\n"); |
||
1209 | break; |
||
1210 | case Qt::RoundJoin: |
||
1211 | PutPage("1 j\n"); |
||
1212 | break; |
||
1213 | default: |
||
1214 | PutPage("0 j\n"); |
||
1215 | break; |
||
1216 | } |
||
3903 | cbradney | 1217 | PutPage("1 0 0 1 "+FToStr(ite->xPos() - pag->xOffset())+" "+FToStr(pag->height() - (ite->yPos() - pag->yOffset()))+" cm\n"); |
3934 | cbradney | 1218 | if (ite->rotation() != 0) |
3133 | fschmid | 1219 | { |
3934 | cbradney | 1220 | double sr = sin(-ite->rotation()* M_PI / 180.0); |
1221 | double cr = cos(-ite->rotation()* M_PI / 180.0); |
||
3133 | fschmid | 1222 | if ((cr * cr) < 0.000001) |
1223 | cr = 0; |
||
1224 | if ((sr * sr) < 0.000001) |
||
1225 | sr = 0; |
||
1226 | PutPage(FToStr(cr)+" "+FToStr(sr)+" "+FToStr(-sr)+" "+FToStr(cr)+" 0 0 cm\n"); |
||
1227 | } |
||
1228 | switch (ite->itemType()) |
||
1229 | { |
||
1230 | case PageItem::ImageFrame: |
||
1231 | if ((ite->fillColor() != "None") || (ite->GrType != 0)) |
||
1232 | { |
||
1233 | if (ite->GrType != 0) |
||
1234 | PutPage(PDF_Gradient(ite)); |
||
1235 | else |
||
1236 | { |
||
1237 | PutPage(SetClipPath(ite)); |
||
1238 | PutPage("h\nf*\n"); |
||
1239 | } |
||
1240 | } |
||
1241 | PutPage("q\n"); |
||
1242 | if (ite->imageClip.size() != 0) |
||
1243 | PutPage(SetClipPathImage(ite)); |
||
1244 | else |
||
1245 | PutPage(SetClipPath(ite)); |
||
1246 | PutPage("h\nW*\nn\n"); |
||
1247 | if (ite->imageFlippedH()) |
||
3934 | cbradney | 1248 | PutPage("-1 0 0 1 "+FToStr(ite->width())+" 0 cm\n"); |
3133 | fschmid | 1249 | if (ite->imageFlippedV()) |
3934 | cbradney | 1250 | PutPage("1 0 0 -1 0 "+FToStr(-ite->height())+" cm\n"); |
3133 | fschmid | 1251 | if ((ite->PicAvail) && (!ite->Pfile.isEmpty())) |
3985 | cbradney | 1252 | PutPage(PDF_Image(ite, ite->Pfile, ite->imageXScale(), ite->imageYScale(), ite->imageXOffset(), -ite->imageYOffset(), false, ite->IProfile, ite->UseEmbedded, ite->IRender)); |
3133 | fschmid | 1253 | PutPage("Q\n"); |
1254 | if (((ite->lineColor() != "None") || (!ite->NamedLStyle.isEmpty())) && (!ite->isTableItem)) |
||
1255 | { |
||
1256 | if ((ite->NamedLStyle.isEmpty()) && (ite->Pwidth != 0.0)) |
||
1257 | { |
||
1258 | PutPage(SetClipPath(ite)); |
||
1259 | PutPage("h\nS\n"); |
||
1260 | } |
||
1261 | else |
||
1262 | { |
||
1263 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1264 | for (int it = ml.size()-1; it > -1; it--) |
||
1265 | { |
||
1266 | PutPage(setStrokeMulti(&ml[it])); |
||
1267 | PutPage(SetClipPath(ite)); |
||
1268 | PutPage("h\nS\n"); |
||
1269 | } |
||
1270 | } |
||
1271 | } |
||
1272 | break; |
||
1273 | case PageItem::TextFrame: |
||
1274 | break; |
||
1275 | case PageItem::Line: |
||
1276 | if (ite->NamedLStyle.isEmpty()) |
||
1277 | { |
||
1278 | PutPage("0 0 m\n"); |
||
3934 | cbradney | 1279 | PutPage(FToStr(ite->width())+" 0 l\n"); |
3133 | fschmid | 1280 | PutPage("S\n"); |
1281 | } |
||
1282 | else |
||
1283 | { |
||
1284 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1285 | for (int it = ml.size()-1; it > -1; it--) |
||
1286 | { |
||
1287 | PutPage(setStrokeMulti(&ml[it])); |
||
1288 | PutPage("0 0 m\n"); |
||
3934 | cbradney | 1289 | PutPage(FToStr(ite->width())+" 0 l\n"); |
3133 | fschmid | 1290 | PutPage("S\n"); |
1291 | } |
||
1292 | } |
||
4061 | craig | 1293 | if (ite->startArrowIndex() != 0) |
3133 | fschmid | 1294 | { |
1295 | QWMatrix arrowTrans; |
||
4061 | craig | 1296 | FPointArray arrow = (*doc->arrowStyles.at(ite->startArrowIndex()-1)).points.copy(); |
3133 | fschmid | 1297 | arrowTrans.translate(0, 0); |
1298 | arrowTrans.scale(ite->Pwidth, ite->Pwidth); |
||
1299 | arrowTrans.scale(-1,1); |
||
1300 | arrow.map(arrowTrans); |
||
1301 | if ((ite->lineTransparency() != 0) && (Options->Version >= 14)) |
||
1302 | { |
||
1303 | StartObj(ObjCounter); |
||
1304 | QString ShName = ResNam+IToStr(ResCount); |
||
1305 | Transpar[ShName] = ObjCounter; |
||
1306 | ResCount++; |
||
1307 | ObjCounter++; |
||
1308 | PutDoc("<< /Type /ExtGState\n"); |
||
1309 | PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1310 | PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1311 | PutDoc("/SMask /None\n/AIS false\n/OPM 1\n"); |
||
1312 | PutDoc("/BM /Normal\n>>\nendobj\n"); |
||
1313 | PutPage("/"+ShName+" gs\n"); |
||
1314 | } |
||
4016 | fschmid | 1315 | PutPage(putColor(ite->lineColor(), ite->lineShade(), true)); |
3133 | fschmid | 1316 | PutPage(SetClipPathArray(&arrow)); |
1317 | PutPage("h\nf*\n"); |
||
1318 | } |
||
4061 | craig | 1319 | if (ite->endArrowIndex() != 0) |
3133 | fschmid | 1320 | { |
1321 | QWMatrix arrowTrans; |
||
4061 | craig | 1322 | FPointArray arrow = (*doc->arrowStyles.at(ite->endArrowIndex()-1)).points.copy(); |
3934 | cbradney | 1323 | arrowTrans.translate(ite->width(), 0); |
3133 | fschmid | 1324 | arrowTrans.scale(ite->Pwidth, ite->Pwidth); |
1325 | arrow.map(arrowTrans); |
||
1326 | if ((ite->lineTransparency() != 0) && (Options->Version >= 14)) |
||
1327 | { |
||
1328 | StartObj(ObjCounter); |
||
1329 | QString ShName = ResNam+IToStr(ResCount); |
||
1330 | Transpar[ShName] = ObjCounter; |
||
1331 | ResCount++; |
||
1332 | ObjCounter++; |
||
1333 | PutDoc("<< /Type /ExtGState\n"); |
||
1334 | PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1335 | PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1336 | PutDoc("/SMask /None\n/AIS false\n/OPM 1\n"); |
||
1337 | PutDoc("/BM /Normal\n>>\nendobj\n"); |
||
1338 | PutPage("/"+ShName+" gs\n"); |
||
1339 | } |
||
4016 | fschmid | 1340 | PutPage(putColor(ite->lineColor(), ite->lineShade(), true)); |
3133 | fschmid | 1341 | PutPage(SetClipPathArray(&arrow)); |
1342 | PutPage("h\nf*\n"); |
||
1343 | } |
||
1344 | break; |
||
3232 | cbradney | 1345 | case PageItem::ItemType1: |
1346 | case PageItem::ItemType3: |
||
3133 | fschmid | 1347 | case PageItem::Polygon: |
1348 | if (ite->GrType != 0) |
||
1349 | PutPage(PDF_Gradient(ite)); |
||
1350 | else |
||
1351 | { |
||
1352 | if (ite->fillColor() != "None") |
||
1353 | { |
||
1354 | PutPage(SetClipPath(ite)); |
||
1355 | PutPage("h\nf*\n"); |
||
1356 | } |
||
1357 | } |
||
1358 | if ((ite->lineColor() != "None") || (!ite->NamedLStyle.isEmpty())) |
||
1359 | { |
||
1360 | if ((ite->NamedLStyle.isEmpty()) && (ite->Pwidth != 0.0)) |
||
1361 | { |
||
1362 | PutPage(SetClipPath(ite)); |
||
1363 | PutPage("h\nS\n"); |
||
1364 | } |
||
1365 | else |
||
1366 | { |
||
1367 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1368 | for (int it = ml.size()-1; it > -1; it--) |
||
1369 | { |
||
1370 | PutPage(setStrokeMulti(&ml[it])); |
||
1371 | PutPage(SetClipPath(ite)); |
||
1372 | PutPage("h\nS\n"); |
||
1373 | } |
||
1374 | } |
||
1375 | } |
||
1376 | break; |
||
1377 | case PageItem::PolyLine: |
||
1378 | if ((ite->PoLine.size() > 3) && ((ite->PoLine.point(0) != ite->PoLine.point(1)) || (ite->PoLine.point(2) != ite->PoLine.point(3)))) |
||
1379 | { |
||
1380 | if (ite->GrType != 0) |
||
1381 | PutPage(PDF_Gradient(ite)); |
||
1382 | else |
||
1383 | { |
||
1384 | if (ite->fillColor() != "None") |
||
1385 | { |
||
1386 | PutPage(SetClipPath(ite)); |
||
1387 | PutPage("h\nf*\n"); |
||
1388 | } |
||
1389 | } |
||
1390 | } |
||
1391 | if ((ite->lineColor() != "None") || (!ite->NamedLStyle.isEmpty())) |
||
1392 | { |
||
1393 | if ((ite->NamedLStyle.isEmpty()) && (ite->Pwidth != 0.0)) |
||
1394 | { |
||
1395 | PutPage(SetClipPath(ite, false)); |
||
1396 | PutPage("S\n"); |
||
1397 | } |
||
1398 | else |
||
1399 | { |
||
1400 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1401 | for (int it = ml.size()-1; it > -1; it--) |
||
1402 | { |
||
1403 | PutPage(setStrokeMulti(&ml[it])); |
||
1404 | PutPage(SetClipPath(ite, false)); |
||
1405 | PutPage("S\n"); |
||
1406 | } |
||
1407 | } |
||
1408 | } |
||
4061 | craig | 1409 | if (ite->startArrowIndex() != 0) |
3133 | fschmid | 1410 | { |
1411 | FPoint Start = ite->PoLine.point(0); |
||
1412 | for (uint xx = 1; xx < ite->PoLine.size(); xx += 2) |
||
1413 | { |
||
1414 | FPoint Vector = ite->PoLine.point(xx); |
||
1415 | if ((Start.x() != Vector.x()) || (Start.y() != Vector.y())) |
||
1416 | { |
||
1417 | double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI); |
||
1418 | QWMatrix arrowTrans; |
||
4061 | craig | 1419 | FPointArray arrow = (*doc->arrowStyles.at(ite->startArrowIndex()-1)).points.copy(); |
3133 | fschmid | 1420 | arrowTrans.translate(Start.x(), Start.y()); |
1421 | arrowTrans.rotate(r); |
||
1422 | arrowTrans.scale(ite->Pwidth, ite->Pwidth); |
||
1423 | arrow.map(arrowTrans); |
||
1424 | if ((ite->lineTransparency() != 0) && (Options->Version >= 14)) |
||
1425 | { |
||
1426 | StartObj(ObjCounter); |
||
1427 | QString ShName = ResNam+IToStr(ResCount); |
||
1428 | Transpar[ShName] = ObjCounter; |
||
1429 | ResCount++; |
||
1430 | ObjCounter++; |
||
1431 | PutDoc("<< /Type /ExtGState\n"); |
||
1432 | PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1433 | PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1434 | PutDoc("/SMask /None\n/AIS false\n/OPM 1\n"); |
||
1435 | PutDoc("/BM /Normal\n>>\nendobj\n"); |
||
1436 | PutPage("/"+ShName+" gs\n"); |
||
1437 | } |
||
4016 | fschmid | 1438 | PutPage(putColor(ite->lineColor(), ite->lineShade(), true)); |
3133 | fschmid | 1439 | PutPage(SetClipPathArray(&arrow)); |
1440 | PutPage("h\nf*\n"); |
||
1441 | break; |
||
1442 | } |
||
1443 | } |
||
1444 | } |
||
4061 | craig | 1445 | if (ite->endArrowIndex() != 0) |
3133 | fschmid | 1446 | { |
1447 | FPoint End = ite->PoLine.point(ite->PoLine.size()-2); |
||
1448 | for (uint xx = ite->PoLine.size()-1; xx > 0; xx -= 2) |
||
1449 | { |
||
1450 | FPoint Vector = ite->PoLine.point(xx); |
||
1451 | if ((End.x() != Vector.x()) || (End.y() != Vector.y())) |
||
1452 | { |
||
1453 | double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI); |
||
1454 | QWMatrix arrowTrans; |
||
4061 | craig | 1455 | FPointArray arrow = (*doc->arrowStyles.at(ite->endArrowIndex()-1)).points.copy(); |
3133 | fschmid | 1456 | arrowTrans.translate(End.x(), End.y()); |
1457 | arrowTrans.rotate(r); |
||
1458 | arrowTrans.scale(ite->Pwidth, ite->Pwidth); |
||
1459 | arrow.map(arrowTrans); |
||
1460 | if ((ite->lineTransparency() != 0) && (Options->Version >= 14)) |
||
1461 | { |
||
1462 | StartObj(ObjCounter); |
||
1463 | QString ShName = ResNam+IToStr(ResCount); |
||
1464 | Transpar[ShName] = ObjCounter; |
||
1465 | ResCount++; |
||
1466 | ObjCounter++; |
||
1467 | PutDoc("<< /Type /ExtGState\n"); |
||
1468 | PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1469 | PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1470 | PutDoc("/SMask /None\n/AIS false\n/OPM 1\n"); |
||
1471 | PutDoc("/BM /Normal\n>>\nendobj\n"); |
||
1472 | PutPage("/"+ShName+" gs\n"); |
||
1473 | } |
||
4016 | fschmid | 1474 | PutPage(putColor(ite->lineColor(), ite->lineShade(), true)); |
3133 | fschmid | 1475 | PutPage(SetClipPathArray(&arrow)); |
1476 | PutPage("h\nf*\n"); |
||
1477 | break; |
||
1478 | } |
||
1479 | } |
||
1480 | } |
||
1481 | break; |
||
1482 | case PageItem::PathText: |
||
1483 | if (ite->PoShow) |
||
1484 | { |
||
1485 | if (ite->PoLine.size() > 3) |
||
1486 | { |
||
1487 | PutPage("q\n"); |
||
1488 | if ((ite->lineColor() != "None") || (!ite->NamedLStyle.isEmpty())) |
||
1489 | { |
||
1490 | if ((ite->NamedLStyle.isEmpty()) && (ite->Pwidth != 0.0)) |
||
1491 | { |
||
1492 | PutPage(SetClipPath(ite, false)); |
||
1493 | PutPage("S\n"); |
||
1494 | } |
||
1495 | else |
||
1496 | { |
||
1497 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1498 | for (int it = ml.size()-1; |
||
1499 | it > -1; it--) |
||
1500 | { |
||
1501 | PutPage(setStrokeMulti(&ml[it])); |
||
1502 | PutPage(SetClipPath(ite, false)); |
||
1503 | PutPage("S\n"); |
||
1504 | } |
||
1505 | } |
||
1506 | } |
||
1507 | PutPage("Q\n"); |
||
1508 | } |
||
1509 | } |
||
3200 | cbradney | 1510 | PutPage(setTextSt(ite, pag->pageNr(), pag)); |
3133 | fschmid | 1511 | break; |
1512 | } |
||
1513 | PutPage("Q\n"); |
||
1514 | StartObj(ObjCounter); |
||
1515 | ObjCounter++; |
||
1516 | PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1\n"); |
||
3200 | cbradney | 1517 | PutDoc("/BBox [ 0 0 "+FToStr(ActPageP->width())+" "+FToStr(ActPageP->height())+" ]\n"); |
3133 | fschmid | 1518 | PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n"); |
1519 | if (Seite.ImgObjects.count() != 0) |
||
1520 | { |
||
1521 | PutDoc("/XObject <<\n"); |
||
1522 | QMap<QString,int>::Iterator it; |
||
1523 | for (it = Seite.ImgObjects.begin(); it != Seite.ImgObjects.end(); ++it) |
||
1524 | PutDoc("/"+it.key()+" "+IToStr(it.data())+" 0 R\n"); |
||
1525 | PutDoc(">>\n"); |
||
1526 | } |
||
1527 | if (Seite.FObjects.count() != 0) |
||
1528 | { |
||
1529 | PutDoc("/Font << \n"); |
||
1530 | QMap<QString,int>::Iterator it2; |
||
1531 | for (it2 = Seite.FObjects.begin(); it2 != Seite.FObjects.end(); ++it2) |
||
1532 | PutDoc("/"+it2.key()+" "+IToStr(it2.data())+" 0 R\n"); |
||
1533 | PutDoc(">>\n"); |
||
1534 | } |
||
1535 | if (Shadings.count() != 0) |
||
1536 | { |
||
1537 | PutDoc("/Shading << \n"); |
||
1538 | QMap<QString,int>::Iterator it3; |
||
1539 | for (it3 = Shadings.begin(); it3 != Shadings.end(); ++it3) |
||
1540 | PutDoc("/"+it3.key()+" "+IToStr(it3.data())+" 0 R\n"); |
||
1541 | PutDoc(">>\n"); |
||
1542 | } |
||
1543 | if (Transpar.count() != 0) |
||
1544 | { |
||
1545 | PutDoc("/ExtGState << \n"); |
||
1546 | QMap<QString,int>::Iterator it3t; |
||
1547 | for (it3t = Transpar.begin(); it3t != Transpar.end(); ++it3t) |
||
1548 | PutDoc("/"+it3t.key()+" "+IToStr(it3t.data())+" 0 R\n"); |
||
1549 | PutDoc(">>\n"); |
||
1550 | } |
||
1551 | if ((ICCProfiles.count() != 0) || (spotMap.count() != 0)) |
||
1552 | { |
||
1553 | PutDoc("/ColorSpace << \n"); |
||
1554 | QMap<QString,ICCD>::Iterator it3c; |
||
1555 | if (ICCProfiles.count() != 0) |
||
1556 | { |
||
1557 | for (it3c = ICCProfiles.begin(); it3c != ICCProfiles.end(); ++it3c) |
||
1558 | PutDoc("/"+it3c.data().ResName+" "+IToStr(it3c.data().ResNum)+" 0 R\n"); |
||
1559 | } |
||
1560 | QMap<QString,SpotC>::Iterator it3sc; |
||
1561 | if (spotMap.count() != 0) |
||
1562 | { |
||
1563 | for (it3sc = spotMap.begin(); it3sc != spotMap.end(); ++it3sc) |
||
1564 | PutDoc("/"+it3sc.data().ResName+" "+IToStr(it3sc.data().ResNum)+" 0 R\n"); |
||
1565 | } |
||
1566 | PutDoc(">>\n"); |
||
1567 | } |
||
1568 | PutDoc(">>\n"); |
||
1569 | if ((Options->Compress) && (CompAvail)) |
||
1570 | Inhalt = CompressStr(&Inhalt); |
||
1571 | PutDoc("/Length "+IToStr(Inhalt.length()+1)); |
||
1572 | if ((Options->Compress) && (CompAvail)) |
||
1573 | PutDoc("\n/Filter /FlateDecode"); |
||
1574 | PutDoc(" >>\nstream\n"+EncStream(&Inhalt, ObjCounter-1)+"\nendstream\nendobj\n"); |
||
3440 | fschmid | 1575 | QString name = pag->PageNam.simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ) + IToStr(ite->ItemNr); |
3133 | fschmid | 1576 | Seite.XObjects[name] = ObjCounter-1; |
1577 | } |
||
1578 | if ((Options->Version == 15) && (Options->useLayers)) |
||
1579 | PutPage("EMC\n"); |
||
1580 | } |
||
1581 | Lnr++; |
||
1582 | } |
||
1583 | } |
||
1584 | |||
1585 | void PDFlib::PDF_Begin_Page(Page* pag, QPixmap pm) |
||
1586 | { |
||
1587 | QString tmp; |
||
1588 | ActPageP = pag; |
||
1589 | Inhalt = ""; |
||
1590 | Seite.AObjects.clear(); |
||
1591 | if (Options->Thumbnails) |
||
1592 | { |
||
1593 | ScImage img = pm.convertToImage(); |
||
1594 | QString im = img.ImageToTxt(); |
||
1595 | if ((Options->Compress) && (CompAvail)) |
||
1596 | im = CompressStr(&im); |
||
1597 | StartObj(ObjCounter); |
||
1598 | PutDoc("<<\n/Width "+IToStr(img.width())+"\n"); |
||
1599 | PutDoc("/Height "+IToStr(img.height())+"\n"); |
||
1600 | PutDoc("/ColorSpace /DeviceRGB\n/BitsPerComponent 8\n"); |
||
1601 | PutDoc("/Length "+IToStr(im.length()+1)+"\n"); |
||
1602 | if ((Options->Compress) && (CompAvail)) |
||
1603 | PutDoc("/Filter /FlateDecode\n"); |
||
1604 | PutDoc(">>\nstream\n"+EncStream(&im, ObjCounter)+"\nendstream\nendobj\n"); |
||
1605 | Seite.Thumb = ObjCounter; |
||
1606 | ObjCounter++; |
||
1607 | } |
||
1608 | } |
||
1609 | |||
1610 | void PDFlib::PDF_End_Page() |
||
1611 | { |
||
3200 | cbradney | 1612 | uint PgNr = ActPageP->pageNr(); |
3133 | fschmid | 1613 | Seite.ObjNum = ObjCounter; |
4084 | cbradney | 1614 | WritePDFStream(Inhalt); |
3133 | fschmid | 1615 | StartObj(ObjCounter); |
1616 | PutDoc("<<\n/Type /Page\n/Parent 4 0 R\n"); |
||
3200 | cbradney | 1617 | PutDoc("/MediaBox [0 0 "+FToStr(ActPageP->width())+" "+FToStr(ActPageP->height())+"]\n"); |
3133 | fschmid | 1618 | PutDoc("/TrimBox ["+FToStr(Options->BleedLeft)+" "+FToStr(Options->BleedBottom)+ |
3200 | cbradney | 1619 | " "+FToStr(ActPageP->width()-Options->BleedRight)+" "+FToStr(ActPageP->height()-Options->BleedTop)+"]\n"); |
3133 | fschmid | 1620 | PutDoc("/Rotate "+IToStr(Options->RotateDeg)+"\n"); |
1621 | PutDoc("/Contents "+IToStr(Seite.ObjNum)+" 0 R\n"); |
||
1622 | if (Options->Thumbnails) |
||
1623 | PutDoc("/Thumb "+IToStr(Seite.Thumb)+" 0 R\n"); |
||
1624 | if (Seite.AObjects.count() != 0) |
||
1625 | { |
||
1626 | PutDoc("/Annots [ "); |
||
1627 | for (uint b = 0; b < Seite.AObjects.count(); ++b) |
||
1628 | PutDoc(IToStr(Seite.AObjects[b])+" 0 R "); |
||
1629 | PutDoc("]\n"); |
||
1630 | } |
||
1631 | if (Options->PresentMode) |
||
1632 | { |
||
1633 | PutDoc("/Dur "+IToStr(Options->PresentVals[PgNr].pageViewDuration)+"\n"); |
||
1634 | if (Options->PresentVals[PgNr].effectType != 0) |
||
1635 | { |
||
1636 | PutDoc("/Trans << /Type /Trans\n"); |
||
1637 | PutDoc("/D "+IToStr(Options->PresentVals[PgNr].pageEffectDuration)+"\n"); |
||
1638 | switch (Options->PresentVals[PgNr].effectType) |
||
1639 | { |
||
1640 | case 1: |
||
1641 | PutDoc("/S /Blinds\n"); |
||
1642 | PutDoc(Options->PresentVals[PgNr].Dm == 0 ? "/Dm /H\n" : "/Dm /V\n"); |
||
1643 | break; |
||
1644 | case 2: |
||
1645 | PutDoc("/S /Box\n"); |
||
1646 | PutDoc(Options->PresentVals[PgNr].M == 0 ? "/M /I\n" : "/M /O\n"); |
||
1647 | break; |
||
1648 | case 3: |
||
1649 | PutDoc("/S /Dissolve\n"); |
||
1650 | break; |
||
1651 | case 4: |
||
1652 | PutDoc("/S /Glitter\n"); |
||
1653 | PutDoc("/Di "); |
||
1654 | switch (Options->PresentVals[PgNr].Di) |
||
1655 | { |
||
1656 | case 0: |
||
1657 | PutDoc("0"); |
||
1658 | break; |
||
1659 | case 1: |
||
1660 | PutDoc("270"); |
||
1661 | break; |
||
1662 | case 4: |
||
1663 | PutDoc("315"); |
||
1664 | break; |
||
1665 | default: |
||
1666 | PutDoc("0"); |
||
1667 | break; |
||
1668 | } |
||
1669 | PutDoc("\n"); |
||
1670 | break; |
||
1671 | case 5: |
||
1672 | PutDoc("/S /Split\n"); |
||
1673 | PutDoc(Options->PresentVals[PgNr].Dm == 0 ? "/Dm /H\n" : "/Dm /V\n"); |
||
1674 | PutDoc(Options->PresentVals[PgNr].M == 0 ? "/M /I\n" : "/M /O\n"); |
||
1675 | break; |
||
1676 | case 6: |
||
1677 | PutDoc("/S /Wipe\n"); |
||
1678 | PutDoc("/Di "); |
||
1679 | switch (Options->PresentVals[PgNr].Di) |
||
1680 | { |
||
1681 | case 0: |
||
1682 | PutDoc("0"); |
||
1683 | break; |
||
1684 | case 1: |
||
1685 | PutDoc("270"); |
||
1686 | break; |
||
1687 | case 2: |
||
1688 | PutDoc("90"); |
||
1689 | break; |
||
1690 | case 3: |
||
1691 | PutDoc("180"); |
||
1692 | break; |
||
1693 | default: |
||
1694 | PutDoc("0"); |
||
1695 | break; |
||
1696 | } |
||
1697 | PutDoc("\n"); |
||
1698 | break; |
||
1699 | } |
||
1700 | PutDoc(">>\n"); |
||
1701 | } |
||
1702 | } |
||
1703 | PutDoc(">>\nendobj\n"); |
||
1704 | PageTree.Count++; |
||
1705 | PageTree.Kids.append(ObjCounter); |
||
1706 | ObjCounter++; |
||
1707 | } |
||
1708 | |||
1709 | void PDFlib::PDF_ProcessPage(Page* pag, uint PNr, bool clip) |
||
1710 | { |
||
1711 | QString tmp; |
||
1712 | ActPageP = pag; |
||
1713 | PageItem* ite; |
||
1714 | QPtrList<PageItem> PItems; |
||
1715 | int Lnr = 0; |
||
1716 | struct Layer ll; |
||
1717 | ll.isPrintable = false; |
||
1718 | ll.LNr = 0; |
||
1719 | if (Options->UseLPI) |
||
1720 | PutPage("/"+HTName+" gs\n"); |
||
1721 | if ( (Options->MirrorH) && (!pag->MPageNam.isEmpty()) ) |
||
3200 | cbradney | 1722 | PutPage("-1 0 0 1 "+FToStr(ActPageP->width())+" 0 cm\n"); |
3133 | fschmid | 1723 | if ( (Options->MirrorV) && (!pag->MPageNam.isEmpty()) ) |
3200 | cbradney | 1724 | PutPage("1 0 0 -1 0 "+FToStr(ActPageP->height())+" cm\n"); |
3133 | fschmid | 1725 | if (clip) |
1726 | { |
||
1727 | PutPage(FToStr(pag->Margins.Left) + " " + FToStr(pag->Margins.Bottom) + " m\n"); |
||
3200 | cbradney | 1728 | PutPage(FToStr(ActPageP->width() - pag->Margins.Right) + " " + FToStr(pag->Margins.Bottom) + " l\n"); |
1729 | PutPage(FToStr(ActPageP->width() - pag->Margins.Right) + " " + FToStr(ActPageP->height() - pag->Margins.Top) + " l\n"); |
||
1730 | PutPage(FToStr(pag->Margins.Left) + " " + FToStr(ActPageP->height() - pag->Margins.Top) + " l h W n\n"); |
||
3133 | fschmid | 1731 | } |
1732 | else |
||
3200 | cbradney | 1733 | PutPage("0 0 "+FToStr(ActPageP->width())+" "+FToStr(ActPageP->height())+" re W n\n"); |
4030 | cbradney | 1734 | |
3133 | fschmid | 1735 | if (!pag->MPageNam.isEmpty()) |
1736 | { |
||
3724 | cbradney | 1737 | Page* mPage = doc->MasterPages.at(doc->MasterNames[doc->Pages->at(PNr)->MPageNam]); |
3133 | fschmid | 1738 | if (doc->MasterItems.count() != 0) |
1739 | { |
||
1740 | if (!Options->MirrorH) |
||
1741 | PutPage("1 0 0 1 0 0 cm\n"); |
||
1742 | for (uint lam = 0; lam < doc->Layers.count(); ++lam) |
||
1743 | { |
||
1744 | Level2Layer(doc, &ll, Lnr); |
||
1745 | Lnr++; |
||
1746 | if (ll.isPrintable) |
||
1747 | { |
||
1748 | if ((Options->Version == 15) && (Options->useLayers)) |
||
1749 | PutPage("/OC /"+OCGEntries[ll.Name].Name+" BDC\n"); |
||
1750 | for (uint am = 0; am < pag->FromMaster.count(); ++am) |
||
1751 | { |
||
1752 | ite = pag->FromMaster.at(am); |
||
1753 | if ((ite->LayerNr != ll.LNr) || (!ite->printable())) |
||
1754 | continue; |
||
3200 | cbradney | 1755 | if ((!pag->PageNam.isEmpty()) && (ite->OwnPage != static_cast<int>(pag->pageNr())) && (ite->OwnPage != -1)) |
3133 | fschmid | 1756 | continue; |
3440 | fschmid | 1757 | QString name = "/"+pag->MPageNam.simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ) + IToStr(ite->ItemNr); |
3625 | avox | 1758 | if (! ite->asTextFrame()) |
3133 | fschmid | 1759 | PutPage(name+" Do\n"); |
1760 | else |
||
1761 | { |
||
1762 | PutPage("q\n"); |
||
1763 | if (((ite->fillTransparency() != 0) || (ite->lineTransparency() != 0)) && (Options->Version >= 14)) |
||
1764 | PutPage(PDF_Transparenz(ite)); |
||
1765 | if (ite->fillColor() != "None") |
||
1766 | PutPage(putColor(ite->fillColor(), ite->fillShade(), true)); |
||
1767 | if (ite->lineColor() != "None") |
||
1768 | PutPage(putColor(ite->lineColor(), ite->lineShade(), false)); |
||
1769 | Inhalt += FToStr(fabs(ite->Pwidth))+" w\n"; |
||
1770 | if (ite->DashValues.count() != 0) |
||
1771 | { |
||
1772 | PutPage("[ "); |
||
1773 | QValueList<double>::iterator it; |
||
1774 | for ( it = ite->DashValues.begin(); it != ite->DashValues.end(); ++it ) |
||
1775 | { |
||
1776 | int da = static_cast<int>(*it); |
||
1777 | if (da != 0) |
||
1778 | PutPage(IToStr(da)+" "); |
||
1779 | PutPage(IToStr(static_cast<int>(*it))+" "); |
||
1780 | } |
||
1781 | } |
||
1782 | else |
||
1783 | { |
||
1784 | QString Dt = FToStr(QMAX(2*fabs(ite->Pwidth), 1)); |
||
1785 | QString Da = FToStr(QMAX(6*fabs(ite->Pwidth), 1)); |
||
1786 | switch (ite->PLineArt) |
||
1787 | { |
||
1788 | case Qt::SolidLine: |
||
1789 | PutPage("[] 0 d\n"); |
||
1790 | break; |
||
1791 | case Qt::DashLine: |
||
1792 | PutPage("["+Da+" "+Dt+"] 0 d\n"); |
||
1793 | break; |
||
1794 | case Qt::DotLine: |
||
1795 | PutPage("["+Dt+"] 0 d\n"); |
||
1796 | break; |
||
1797 | case Qt::DashDotLine: |
||
1798 | PutPage("["+Da+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n"); |
||
1799 | break; |
||
1800 | case Qt::DashDotDotLine: |
||
1801 | PutPage("["+Da+" "+Dt+" "+Dt+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n"); |
||
1802 | break; |
||
1803 | default: |
||
1804 | PutPage("[] 0 d\n"); |
||
1805 | break; |
||
1806 | } |
||
1807 | } |
||
1808 | PutPage("2 J\n"); |
||
1809 | switch (ite->PLineJoin) |
||
1810 | { |
||
1811 | case Qt::MiterJoin: |
||
1812 | PutPage("0 j\n"); |
||
1813 | break; |
||
1814 | case Qt::BevelJoin: |
||
1815 | PutPage("2 j\n"); |
||
1816 | break; |
||
1817 | case Qt::RoundJoin: |
||
1818 | PutPage("1 j\n"); |
||
1819 | break; |
||
1820 | default: |
||
1821 | PutPage("0 j\n"); |
||
1822 | break; |
||
1823 | } |
||
3903 | cbradney | 1824 | PutPage("1 0 0 1 "+FToStr(ite->xPos() - mPage->xOffset())+" "+FToStr(mPage->height() - (ite->yPos() - mPage->yOffset()))+" cm\n"); |
3934 | cbradney | 1825 | if (ite->rotation() != 0) |
3133 | fschmid | 1826 | { |
3934 | cbradney | 1827 | double sr = sin(-ite->rotation()* M_PI / 180.0); |
1828 | double cr = cos(-ite->rotation()* M_PI / 180.0); |
||
3133 | fschmid | 1829 | if |