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