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