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