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