Rev 4184 | Rev 4201 | 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"); |
||
4197 | fschmid | 498 | PutDoc("/PageLayout "); |
499 | switch (Options->PageLayout) |
||
3133 | fschmid | 500 | { |
4197 | fschmid | 501 | case PDFOptions::SinglePage: |
502 | PutDoc("/SinglePage\n"); |
||
503 | break; |
||
504 | case PDFOptions::OneColumn: |
||
505 | PutDoc("/OneColumn\n"); |
||
506 | break; |
||
507 | case PDFOptions::TwoColumnLeft: |
||
508 | PutDoc("/TwoColumnLeft\n"); |
||
509 | break; |
||
510 | case PDFOptions::TwoColumnRight: |
||
511 | PutDoc("/TwoColumnRight\n"); |
||
512 | break; |
||
513 | } |
||
514 | if (Options->displayBookmarks) |
||
515 | PutDoc("/PageMode /UseOutlines\n"); |
||
516 | else if (Options->displayFullscreen) |
||
517 | PutDoc("/PageMode /FullScreen\n"); |
||
518 | else if (Options->displayThumbs) |
||
519 | PutDoc("/PageMode /UseThumbs\n"); |
||
520 | else if ((Options->Version == 15) && (Options->displayLayers)) |
||
521 | PutDoc("/PageMode /UseOC\n"); |
||
522 | /* if (doc->currentPageLayout == doublePage) |
||
523 | { |
||
3133 | fschmid | 524 | PutDoc("/PageLayout "); |
3904 | fschmid | 525 | if (doc->pageSets[doc->currentPageLayout].FirstPage == 0) |
3133 | fschmid | 526 | PutDoc("/TwoColumnLeft\n"); |
527 | else |
||
528 | PutDoc("/TwoColumnRight\n"); |
||
529 | } |
||
530 | if (Options->PresentMode) |
||
531 | PutDoc("/PageMode /FullScreen\n"); |
||
532 | else |
||
533 | { |
||
534 | if ((Options->Version == 15) && (Options->useLayers)) |
||
535 | PutDoc("/PageMode /UseOC\n"); |
||
4197 | fschmid | 536 | } */ |
3133 | fschmid | 537 | PutDoc("/ViewerPreferences\n<<\n/PageDirection "); |
538 | PutDoc( Options->Binding == 0 ? "/L2R\n" : "/R2L\n"); |
||
539 | PutDoc(" >>\n>>\nendobj\n"); |
||
3829 | cbradney | 540 | QString IDg(Datum); |
3133 | fschmid | 541 | IDg += Options->Datei; |
542 | IDg += "Scribus "+QString(VERSION); |
||
543 | IDg += "Libpdf for Scribus "+QString(VERSION); |
||
544 | IDg += doc->documentInfo.getTitle(); |
||
545 | IDg += doc->documentInfo.getAuthor(); |
||
546 | IDg += "/False"; |
||
547 | FileID = ComputeMD5(IDg); |
||
548 | if (Options->Encrypt) |
||
549 | { |
||
550 | KeyLen = Options->Version == 14 ? 16 : 5; |
||
551 | CalcOwnerKey(Options->PassOwner, Options->PassUser); |
||
552 | CalcUserKey(Options->PassUser, Options->Permissions); |
||
553 | for (uint cl2 = 0; cl2 < 32; ++cl2) |
||
554 | ok += QChar(OwnerKey[cl2]); |
||
555 | if (KeyLen > 5) |
||
556 | { |
||
557 | for (uint cl3 = 0; cl3 < 16; ++cl3) |
||
558 | uk += QChar(UserKey[cl3]); |
||
559 | for (uint cl3r = 0; cl3r < 16; ++cl3r) |
||
560 | uk += QChar(KeyGen[cl3r]); |
||
561 | } |
||
562 | else |
||
563 | { |
||
564 | for (uint cl = 0; cl < 32; ++cl) |
||
565 | uk += QChar(UserKey[cl]); |
||
566 | } |
||
567 | } |
||
568 | QDate d = QDate::currentDate(); |
||
569 | Datum = "D:"; |
||
570 | tmp.sprintf("%4d", d.year()); |
||
571 | tmp.replace(QRegExp(" "), "0"); |
||
572 | Datum += tmp; |
||
573 | tmp.sprintf("%2d", d.month()); |
||
574 | tmp.replace(QRegExp(" "), "0"); |
||
575 | Datum += tmp; |
||
576 | tmp.sprintf("%2d", d.day()); |
||
577 | tmp.replace(QRegExp(" "), "0"); |
||
578 | Datum += tmp; |
||
579 | QTime t = QTime::currentTime(); |
||
580 | tmp = t.toString(); |
||
581 | tmp.replace(QRegExp(":"), ""); |
||
582 | Datum += tmp; |
||
583 | StartObj(2); |
||
584 | PutDoc("<<\n/Creator "+EncString("(Scribus "+QString(VERSION)+")",2)+"\n"); |
||
585 | PutDoc("/Producer "+EncString("(Libpdf for Scribus "+QString(VERSION)+")",2)+"\n"); |
||
586 | PutDoc("/Title "+EncString("("+doc->documentInfo.getTitle()+")",2)+"\n"); |
||
587 | PutDoc("/Author "+EncString("("+doc->documentInfo.getAuthor()+")",2)+"\n"); |
||
588 | PutDoc("/Keywords "+EncString("("+doc->documentInfo.getKeywords()+")",2)+"\n"); |
||
589 | PutDoc("/CreationDate "+EncString("("+Datum+")",2)+"\n"); |
||
590 | PutDoc("/ModDate "+EncString("("+Datum+")",2)+"\n"); |
||
591 | if (Options->Version == 12) |
||
592 | PutDoc("/GTS_PDFXVersion (PDF/X-3:2002)\n"); |
||
593 | PutDoc("/Trapped /False\n>>\nendobj\n"); |
||
594 | for (int t = 0; t < 6; ++t) |
||
595 | XRef.append(Dokument); |
||
596 | if ((Options->Version == 15) && (Options->useLayers)) |
||
597 | XRef.append(Dokument); |
||
598 | if (Options->Version == 12) |
||
599 | XRef.append(Dokument); |
||
600 | if (Options->Encrypt) |
||
601 | { |
||
602 | StartObj(ObjCounter); |
||
603 | Encrypt = ObjCounter; |
||
604 | ObjCounter++; |
||
605 | PutDoc("<<\n/Filter /Standard\n"); |
||
606 | PutDoc( KeyLen > 5 ? "/R 3\n/V 2\n/Length 128\n" : "/R 2\n/V 1\n"); |
||
607 | PutDoc("/O <"+String2Hex(&ok)+">\n"); |
||
608 | PutDoc("/U <"+String2Hex(&uk)+">\n"); |
||
609 | PutDoc("/P "+IToStr(Options->Permissions)+"\n>>\nendobj\n"); |
||
610 | } |
||
611 | RealFonts = DocFonts; |
||
3544 | avox | 612 | QMap<QString,int> ReallyUsed; |
3133 | fschmid | 613 | ReallyUsed.clear(); |
614 | PageItem* pgit; |
||
4017 | fschmid | 615 | QMap<int, QString> ind2PDFabr; |
616 | const QString tmpf[] = {"/Courier", "/Courier-Bold", "/Courier-Oblique", "/Courier-BoldOblique", |
||
617 | "/Helvetica", "/Helvetica-Bold", "/Helvetica-Oblique", "/Helvetica-BoldOblique", |
||
618 | "/Times-Roman", "/Times-Bold", "/Times-Italic", "/Times-BoldItalic", |
||
619 | "/ZapfDingbats", "/Symbol"}; |
||
620 | size_t ar = sizeof(tmpf) / sizeof(*tmpf); |
||
621 | for (uint ax = 0; ax < ar; ++ax) |
||
622 | ind2PDFabr[ax] = tmpf[ax]; |
||
3133 | fschmid | 623 | for (uint c = 0; c < doc->FrameItems.count(); ++c) |
624 | { |
||
625 | pgit = doc->FrameItems.at(c); |
||
626 | if ((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) |
||
627 | { |
||
4084 | cbradney | 628 | if (pgit->isAnnotation()) |
629 | StdFonts.insert(ind2PDFabr[pgit->annotation().Font()], ""); |
||
3133 | fschmid | 630 | for (uint e = 0; e < pgit->itemText.count(); ++e) |
631 | { |
||
3544 | avox | 632 | ReallyUsed.insert(pgit->itemText.at(e)->cfont->scName(), DocFonts[pgit->itemText.at(e)->cfont->scName()]); |
3133 | fschmid | 633 | } |
634 | } |
||
635 | } |
||
636 | for (uint c = 0; c < doc->MasterItems.count(); ++c) |
||
637 | { |
||
638 | pgit = doc->MasterItems.at(c); |
||
639 | if ((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) |
||
640 | { |
||
4084 | cbradney | 641 | if (pgit->isAnnotation()) |
642 | StdFonts.insert(ind2PDFabr[pgit->annotation().Font()], ""); |
||
3133 | fschmid | 643 | for (uint e = 0; e < pgit->itemText.count(); ++e) |
644 | { |
||
3544 | avox | 645 | ReallyUsed.insert(pgit->itemText.at(e)->cfont->scName(), DocFonts[pgit->itemText.at(e)->cfont->scName()]); |
3133 | fschmid | 646 | } |
647 | } |
||
648 | } |
||
3727 | cbradney | 649 | for (uint d = 0; d < doc->Items->count(); ++d) |
3133 | fschmid | 650 | { |
3727 | cbradney | 651 | pgit = doc->Items->at(d); |
3133 | fschmid | 652 | if ((pgit->itemType() == PageItem::TextFrame) || (pgit->itemType() == PageItem::PathText)) |
653 | { |
||
4084 | cbradney | 654 | if (pgit->isAnnotation()) |
655 | StdFonts.insert(ind2PDFabr[pgit->annotation().Font()], ""); |
||
3133 | fschmid | 656 | for (uint e = 0; e < pgit->itemText.count(); ++e) |
657 | { |
||
3544 | avox | 658 | ReallyUsed.insert(pgit->itemText.at(e)->cfont->scName(), DocFonts[pgit->itemText.at(e)->cfont->scName()]); |
3133 | fschmid | 659 | } |
660 | } |
||
661 | } |
||
4017 | fschmid | 662 | a = 0; |
663 | QMap<QString, QString>::Iterator itStd; |
||
664 | for (itStd = StdFonts.begin(); itStd != StdFonts.end(); ++itStd) |
||
665 | { |
||
666 | StartObj(ObjCounter); |
||
667 | PutDoc("<<\n/Type /Font\n/Subtype /Type1\n"); |
||
668 | PutDoc("/BaseFont "+itStd.key()+"\n"); |
||
669 | PutDoc(">>\nendobj\n"); |
||
670 | Seite.FObjects["FoStd"+IToStr(a)] = ObjCounter; |
||
671 | itStd.data() = "FoStd"+IToStr(a); |
||
672 | ObjCounter++; |
||
673 | a++; |
||
674 | } |
||
3544 | avox | 675 | QMap<QString,int>::Iterator it; |
3133 | fschmid | 676 | a = 0; |
677 | for (it = ReallyUsed.begin(); it != ReallyUsed.end(); ++it) |
||
678 | { |
||
679 | Foi::FontFormat fformat = AllFonts[it.key()]->formatCode; |
||
680 | if ((AllFonts[it.key()]->isOTF) || (!AllFonts[it.key()]->HasNames) || (AllFonts[it.key()]->Subset) || (Options->SubsetList.contains(it.key()))) |
||
681 | { |
||
3829 | cbradney | 682 | QString fon(""); |
3133 | fschmid | 683 | QMap<uint,FPointArray>::Iterator ig; |
684 | for (ig = AllFonts[it.key()]->RealGlyphs.begin(); ig != AllFonts[it.key()]->RealGlyphs.end(); ++ig) |
||
685 | { |
||
686 | FPoint np, np1, np2; |
||
687 | bool nPath = true; |
||
688 | if (ig.data().size() > 3) |
||
689 | { |
||
690 | FPointArray gly = ig.data().copy(); |
||
691 | QWMatrix mat; |
||
692 | mat.scale(0.1, 0.1); |
||
693 | gly.map(mat); |
||
694 | for (uint poi = 0; poi < gly.size()-3; poi += 4) |
||
695 | { |
||
696 | if (gly.point(poi).x() > 900000) |
||
697 | { |
||
698 | fon += "h\n"; |
||
699 | nPath = true; |
||
700 | continue; |
||
701 | } |
||
702 | if (nPath) |
||
703 | { |
||
704 | np = gly.point(poi); |
||
705 | fon += FToStr(np.x())+" "+FToStr(-np.y())+" m\n"; |
||
706 | nPath = false; |
||
707 | } |
||
708 | np = gly.point(poi+1); |
||
709 | np1 = gly.point(poi+3); |
||
710 | np2 = gly.point(poi+2); |
||
711 | fon += FToStr(np.x()) + " " + FToStr(-np.y()) + " " + |
||
712 | FToStr(np1.x()) + " " + FToStr(-np1.y()) + " " + |
||
713 | FToStr(np2.x()) + " " + FToStr(-np2.y()) + " c\n"; |
||
714 | } |
||
715 | fon += "h f*\n"; |
||
716 | StartObj(ObjCounter); |
||
717 | ObjCounter++; |
||
718 | np = getMinClipF(&gly); |
||
719 | np1 = getMaxClipF(&gly); |
||
720 | PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1\n"); |
||
721 | PutDoc("/BBox [ "+FToStr(np.x())+" "+FToStr(-np.y())+" "+FToStr(np1.x())+ " "+FToStr(-np1.y())+" ]\n"); |
||
722 | PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n"); |
||
723 | PutDoc(">>\n"); |
||
724 | if ((Options->Compress) && (CompAvail)) |
||
725 | fon = CompressStr(&fon); |
||
726 | PutDoc("/Length "+IToStr(fon.length()+1)); |
||
727 | if ((Options->Compress) && (CompAvail)) |
||
728 | PutDoc("\n/Filter /FlateDecode"); |
||
729 | PutDoc(" >>\nstream\n"+EncStream(&fon, ObjCounter-1)+"\nendstream\nendobj\n"); |
||
3440 | fschmid | 730 | Seite.XObjects[AllFonts[it.key()]->RealName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+IToStr(ig.key())] = ObjCounter-1; |
3133 | fschmid | 731 | fon = ""; |
732 | } |
||
733 | } |
||
734 | AllFonts[it.key()]->RealGlyphs.clear(); |
||
735 | } |
||
736 | else |
||
737 | { |
||
738 | UsedFontsP.insert(it.key(), "/Fo"+IToStr(a)); |
||
739 | if ((fformat == Foi::PFB) && (Options->EmbedList.contains(it.key()))) |
||
740 | { |
||
3829 | cbradney | 741 | QString fon(""); |
3133 | fschmid | 742 | StartObj(ObjCounter); |
743 | QByteArray bb; |
||
744 | AllFonts[it.key()]->RawData(bb); |
||
745 | uint posi; |
||
746 | for (posi = 6; posi < bb.size(); ++posi) |
||
747 | { |
||
748 | if ((bb[posi] == static_cast<char>(0x80)) && (static_cast<int>(bb[posi+1]) == 2)) |
||
749 | break; |
||
750 | fon += QChar(bb[posi]); |
||
751 | } |
||
752 | int len1 = fon.length(); |
||
753 | uint ulen; |
||
754 | ulen = bb[posi+2] & 0xff; |
||
755 | ulen |= (bb[posi+3] << 8) & 0xff00; |
||
756 | ulen |= (bb[posi+4] << 16) & 0xff0000; |
||
757 | ulen |= (bb[posi+5] << 24) & 0xff000000; |
||
758 | if (ulen > bb.size()) |
||
759 | ulen = bb.size()-7; |
||
760 | posi += 6; |
||
761 | for (uint j = 0; j < ulen; ++j) |
||
762 | fon += QChar(bb[posi++]); |
||
763 | posi += 6; |
||
764 | int len2 = fon.length()-len1; |
||
765 | for (uint j = posi; j < bb.size(); ++j) |
||
766 | { |
||
767 | if ((bb[j] == static_cast<char>(0x80)) && (static_cast<int>(bb[j+1]) == 3)) |
||
768 | break; |
||
769 | if (bb[j] == '\r') |
||
770 | fon += "\n"; |
||
771 | else |
||
772 | fon += QChar(bb[j]); |
||
773 | } |
||
774 | int len3 = fon.length()-len2-len1; |
||
775 | if ((Options->Compress) && (CompAvail)) |
||
776 | fon = CompressStr(&fon); |
||
777 | PutDoc("<<\n/Length "+IToStr(fon.length()+1)+"\n"); |
||
778 | PutDoc("/Length1 "+IToStr(len1)+"\n"); |
||
779 | PutDoc("/Length2 "+IToStr(len2)+"\n"); |
||
780 | PutDoc("/Length3 "+IToStr(len3)+"\n"); |
||
781 | if ((Options->Compress) && (CompAvail)) |
||
782 | PutDoc("/Filter /FlateDecode\n"); |
||
783 | PutDoc(">>\nstream\n"+EncStream(&fon,ObjCounter)+"\nendstream\nendobj\n"); |
||
784 | ObjCounter++; |
||
785 | } |
||
786 | if ((fformat == Foi::PFA) && (Options->EmbedList.contains(it.key()))) |
||
787 | { |
||
3829 | cbradney | 788 | QString fon(""); |
789 | QString fon2(""); |
||
790 | QString tm(""); |
||
3133 | fschmid | 791 | uint value; |
792 | bool ok = true; |
||
793 | StartObj(ObjCounter); |
||
794 | AllFonts[it.key()]->EmbedFont(fon); |
||
795 | int len1 = fon.find("eexec")+5; |
||
796 | fon2 = fon.left(len1)+"\n"; |
||
797 | int len2 = fon.find("0000000000000000000000000"); |
||
798 | if (len2 == -1) |
||
799 | len2 = fon.length()+1; |
||
800 | int count = 0; |
||
801 | for (int xx = len1; xx < len2-1; ++xx) |
||
802 | { |
||
803 | tm = fon.at(xx); |
||
804 | if ((tm == QChar(13)) || (tm == QChar(10))) |
||
805 | continue; |
||
806 | xx++; |
||
807 | count++; |
||
808 | tm += fon.at(xx); |
||
809 | value = tm.toUInt(&ok, 16); |
||
810 | fon2 += QChar(value); |
||
811 | } |
||
812 | fon2 += fon.mid(len2); |
||
813 | if ((Options->Compress) && (CompAvail)) |
||
814 | fon2 = CompressStr(&fon2); |
||
815 | PutDoc("<<\n/Length "+IToStr(fon2.length()+1)+"\n"); |
||
816 | PutDoc("/Length1 "+IToStr(len1+1)+"\n"); |
||
817 | PutDoc("/Length2 "+IToStr(count)+"\n"); |
||
818 | PutDoc(static_cast<int>(fon.length()-len2) == -1 ? QString("/Length3 0\n") : "/Length3 "+IToStr(fon.length()-len2)+"\n"); |
||
819 | if ((Options->Compress) && (CompAvail)) |
||
820 | PutDoc("/Filter /FlateDecode\n"); |
||
821 | PutDoc(">>\nstream\n"+EncStream(&fon2, ObjCounter)+"\nendstream\nendobj\n"); |
||
822 | ObjCounter++; |
||
823 | } |
||
824 | if ((fformat == Foi::SFNT || fformat == Foi::TTCF) && (Options->EmbedList.contains(it.key()))) |
||
825 | { |
||
3829 | cbradney | 826 | QString fon(""); |
3133 | fschmid | 827 | StartObj(ObjCounter); |
828 | QByteArray bb; |
||
829 | AllFonts[it.key()]->RawData(bb); |
||
830 | //AV: += and append() dont't work because they stop at '\0' :-( |
||
831 | for (unsigned int i=0; i < bb.size(); i++) |
||
832 | fon += QChar(bb[i]); |
||
833 | int len = fon.length(); |
||
834 | if ((Options->Compress) && (CompAvail)) |
||
835 | fon = CompressStr(&fon); |
||
836 | //qDebug(QString("sfnt data: size=%1 before=%2 compressed=%3").arg(bb.size()).arg(len).arg(fon.length())); |
||
837 | PutDoc("<<\n/Length "+IToStr(fon.length()+1)+"\n"); |
||
838 | PutDoc("/Length1 "+IToStr(len)+"\n"); |
||
839 | if ((Options->Compress) && (CompAvail)) |
||
840 | PutDoc("/Filter /FlateDecode\n"); |
||
841 | PutDoc(">>\nstream\n"+EncStream(&fon, ObjCounter)+"\nendstream\nendobj\n"); |
||
842 | ObjCounter++; |
||
843 | } |
||
844 | StartObj(ObjCounter); |
||
845 | PutDoc("<<\n/Type /FontDescriptor\n"); |
||
3440 | fschmid | 846 | PutDoc("/FontName /"+AllFonts[it.key()]->RealName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n"); |
3133 | fschmid | 847 | PutDoc("/FontBBox [ "+AllFonts[it.key()]->FontBBox+" ]\n"); |
848 | PutDoc("/Flags "); |
||
3544 | avox | 849 | //FIXME: isItalic() should be queried from Foi, not from Qt -- AV |
850 | //QFontInfo fo = QFontInfo(it.data()); |
||
3133 | fschmid | 851 | int pfl = 0; |
852 | if (AllFonts[it.key()]->IsFixedPitch) |
||
853 | pfl = pfl ^ 1; |
||
3544 | avox | 854 | //if (fo.italic()) |
855 | if (AllFonts[it.key()]->ItalicAngle != "0") |
||
3133 | fschmid | 856 | pfl = pfl ^ 64; |
857 | // pfl = pfl ^ 4; |
||
858 | pfl = pfl ^ 32; |
||
859 | PutDoc(IToStr(pfl)+"\n"); |
||
860 | PutDoc("/Ascent "+AllFonts[it.key()]->Ascent+"\n"); |
||
861 | PutDoc("/Descent "+AllFonts[it.key()]->Descender+"\n"); |
||
862 | PutDoc("/CapHeight "+AllFonts[it.key()]->CapHeight+"\n"); |
||
863 | PutDoc("/ItalicAngle "+AllFonts[it.key()]->ItalicAngle+"\n"); |
||
864 | PutDoc("/StemV "+AllFonts[it.key()]->StdVW+"\n"); |
||
865 | if ((fformat == Foi::SFNT || fformat == Foi::TTCF) && (Options->EmbedList.contains(it.key()))) |
||
866 | PutDoc("/FontFile2 "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
867 | if ((fformat == Foi::PFB) && (Options->EmbedList.contains(it.key()))) |
||
868 | PutDoc("/FontFile "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
869 | if ((fformat == Foi::PFA) && (Options->EmbedList.contains(it.key()))) |
||
870 | PutDoc("/FontFile "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
871 | PutDoc(">>\nendobj\n"); |
||
872 | ObjCounter++; |
||
873 | /* if (!FT_Has_PS_Glyph_Names(AllFonts[it.key()]) |
||
874 | { |
||
875 | StartObj(ObjCounter); |
||
876 | int chCount = 31; |
||
877 | 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 "); |
||
878 | for (int ww = 31; ww < 256; ++ww) |
||
879 | { |
||
880 | PutDoc(IToStr(static_cast<int>(AllFonts[it.key()]->CharWidth[itg.key()]* |
||
881 | 1000))+" "); |
||
882 | if (itg == gl.end()) |
||
883 | break; |
||
884 | ++itg; |
||
885 | chCount++; |
||
886 | } |
||
887 | PutDoc("]\nendobj\n"); |
||
888 | ObjCounter++; |
||
889 | // put widths object |
||
890 | // encoding dictionary w/ base encoding w/o differences |
||
891 | StartObj(ObjCounter); |
||
892 | PutDoc("<<\n/Type /Font\n/Subtype "); |
||
893 | PutDoc((fformat == Foi::SFNT || fformat == Foi::TTCF) ? "/TrueType\n" : "/Type1\n"); |
||
894 | PutDoc("/Name /Fo"+IToStr(a)+"\n"); |
||
3304 | fschmid | 895 | PutDoc("/BaseFont /"+AllFonts[it.key()]->RealName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "" )+"\n"); |
3133 | fschmid | 896 | //cf. widths: |
897 | PutDoc("/FirstChar 0\n"); |
||
898 | PutDoc("/LastChar "+IToStr(chCount-1)+"\n"); |
||
899 | PutDoc("/Widths "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
900 | PutDoc("/FontDescriptor "+IToStr(ObjCounter-2)+" 0 R\n"); |
||
901 | PutDoc(">>\nendobj\n"); |
||
902 | Seite.FObjects["Fo"+IToStr(a)] = ObjCounter; |
||
903 | ObjCounter++; |
||
904 | } |
||
905 | else */ |
||
906 | // { |
||
907 | GListeInd gl; |
||
908 | GlyIndex(AllFonts[it.key()], &gl); |
||
909 | GlyphsIdxOfFont.insert(it.key(), gl); |
||
910 | uint FontDes = ObjCounter - 1; |
||
911 | GListeInd::Iterator itg; |
||
912 | itg = gl.begin(); |
||
913 | GListeInd::Iterator itg2; |
||
914 | itg2 = gl.begin(); |
||
915 | uint Fcc = gl.count() / 224; |
||
916 | if ((gl.count() % 224) != 0) |
||
917 | Fcc += 1; |
||
918 | for (uint Fc = 0; Fc < Fcc; ++Fc) |
||
919 | { |
||
920 | StartObj(ObjCounter); |
||
921 | int chCount = 31; |
||
922 | 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 "); |
||
923 | for (int ww = 31; ww < 256; ++ww) |
||
924 | { |
||
925 | PutDoc(IToStr(static_cast<int>(AllFonts[it.key()]->CharWidth[itg.key()]* 1000))+" "); |
||
926 | if (itg == gl.end()) |
||
927 | break; |
||
928 | ++itg; |
||
929 | chCount++; |
||
930 | } |
||
931 | PutDoc("]\nendobj\n"); |
||
932 | ObjCounter++; |
||
933 | StartObj(ObjCounter); |
||
934 | ObjCounter++; |
||
935 | PutDoc("<< /Type /Encoding\n"); |
||
936 | // PutDoc("/BaseEncoding /" + AllFonts[it.key()]->FontEnc + "\n"); |
||
937 | PutDoc("/Differences [ 32\n"); |
||
938 | int crc = 0; |
||
939 | for (int ww2 = 32; ww2 < 256; ++ww2) |
||
940 | { |
||
941 | PutDoc(itg2.data().Name+" "); |
||
942 | if (itg2 == gl.end()) |
||
943 | break; |
||
944 | ++itg2; |
||
945 | crc++; |
||
946 | if (crc > 8) |
||
947 | { |
||
948 | PutDoc("\n"); |
||
949 | crc = 0; |
||
950 | } |
||
951 | } |
||
952 | PutDoc("]\n"); |
||
953 | |||
954 | PutDoc(">>\nendobj\n"); |
||
955 | StartObj(ObjCounter); |
||
956 | PutDoc("<<\n/Type /Font\n/Subtype "); |
||
957 | PutDoc((fformat == Foi::SFNT || fformat == Foi::TTCF) ? "/TrueType\n" : "/Type1\n"); |
||
958 | PutDoc("/Name /Fo"+IToStr(a)+"S"+IToStr(Fc)+"\n"); |
||
3440 | fschmid | 959 | PutDoc("/BaseFont /"+AllFonts[it.key()]->RealName().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" )+"\n"); |
3133 | fschmid | 960 | PutDoc("/FirstChar 0\n"); |
961 | PutDoc("/LastChar "+IToStr(chCount-1)+"\n"); |
||
962 | PutDoc("/Widths "+IToStr(ObjCounter-2)+" 0 R\n"); |
||
963 | PutDoc("/Encoding "+IToStr(ObjCounter-1)+" 0 R\n"); |
||
964 | PutDoc("/FontDescriptor "+IToStr(FontDes)+" 0 R\n"); |
||
965 | PutDoc(">>\nendobj\n"); |
||
966 | Seite.FObjects["Fo"+IToStr(a)+"S"+IToStr(Fc)] = ObjCounter; |
||
967 | ObjCounter++; |
||
968 | } // for(Fc) |
||
969 | // } // FT_Has_PS_Glyph_Names |
||
970 | } |
||
971 | a++; |
||
972 | } |
||
973 | if (Options->UseLPI) |
||
974 | { |
||
975 | StartObj(ObjCounter); |
||
976 | PutDoc("<<\n/Type /Halftone\n/HalftoneType 5\n"); |
||
977 | QMap<QString,LPIData>::Iterator itlp; |
||
978 | for (itlp = Options->LPISettings.begin(); itlp != Options->LPISettings.end(); ++itlp) |
||
979 | { |
||
980 | PutDoc("/"+itlp.key()+"\n<<\n/Type /Halftone\n/HalftoneType 1\n/Frequency "); |
||
981 | PutDoc(IToStr(itlp.data().Frequency)+"\n/Angle "+IToStr(itlp.data().Angle)+"\n/SpotFunction "); |
||
3829 | cbradney | 982 | QString func (""); |
3133 | fschmid | 983 | switch (itlp.data().SpotFunc) |
984 | { |
||
985 | case 0: |
||
986 | func = "/SimpleDot"; |
||
987 | break; |
||
988 | case 1: |
||
989 | func = "/Line"; |
||
990 | break; |
||
991 | case 2: |
||
992 | func = "/Round"; |
||
993 | break; |
||
994 | case 3: |
||
995 | func = "/Ellipse"; |
||
996 | break; |
||
997 | default: |
||
998 | func = "/SimpleDot"; |
||
999 | break; |
||
1000 | } |
||
1001 | PutDoc(func+"\n>>\n"); |
||
1002 | } |
||
1003 | PutDoc("/Default\n<<\n/Type /Halftone\n/HalftoneType 1\n/Frequency 50\n/Angle 45\n/SpotFunction /Round\n>>\n"); |
||
1004 | PutDoc(">>\nendobj\n"); |
||
1005 | ObjCounter++; |
||
1006 | StartObj(ObjCounter); |
||
1007 | HTName = ResNam+IToStr(ResCount); |
||
1008 | Transpar[HTName] = ObjCounter; |
||
1009 | PutDoc("<< /Type /ExtGState\n/HT "+IToStr(ObjCounter-1)+" 0 R\n>>\nendobj\n"); |
||
1010 | ResCount++; |
||
1011 | ObjCounter++; |
||
1012 | } |
||
1013 | #ifdef HAVE_CMS |
||
1014 | if ((CMSuse) && (Options->UseProfiles)) |
||
1015 | { |
||
1016 | StartObj(ObjCounter); |
||
1017 | ObjCounter++; |
||
1018 | QString dataP; |
||
1019 | struct ICCD dataD; |
||
4026 | craig | 1020 | loadText(ScMW->InputProfiles[Options->SolidProf], &dataP); |
3133 | fschmid | 1021 | PutDoc("<<\n"); |
1022 | if ((Options->Compress) && (CompAvail)) |
||
1023 | { |
||
1024 | PutDoc("/Filter /FlateDecode\n"); |
||
1025 | dataP = CompressStr(&dataP); |
||
1026 | } |
||
1027 | PutDoc("/Length "+IToStr(dataP.length()+1)+"\n"); |
||
1028 | PutDoc("/N "+IToStr(Options->SComp)+"\n"); |
||
1029 | PutDoc(">>\nstream\n"+EncStream(&dataP, ObjCounter-1)+"\nendstream\nendobj\n"); |
||
1030 | StartObj(ObjCounter); |
||
1031 | dataD.ResName = ResNam+IToStr(ResCount); |
||
1032 | dataD.ICCArray = "[ /ICCBased "+IToStr(ObjCounter-1)+" 0 R ]"; |
||
1033 | dataD.ResNum = ObjCounter; |
||
1034 | ICCProfiles[Options->SolidProf] = dataD; |
||
1035 | PutDoc("[ /ICCBased "+IToStr(ObjCounter-1)+" 0 R ]\n"); |
||
1036 | PutDoc("endobj\n"); |
||
1037 | ResCount++; |
||
1038 | ObjCounter++; |
||
1039 | } |
||
1040 | #endif |
||
1041 | if (((Options->isGrayscale == false) && (Options->UseRGB == false)) && (Options->UseSpotColors)) |
||
1042 | { |
||
1043 | doc->getUsedColors(colorsToUse); |
||
1044 | ColorList::Iterator itf; |
||
1045 | for (itf = colorsToUse.begin(); itf != colorsToUse.end(); ++itf) |
||
1046 | { |
||
1047 | if ((colorsToUse[itf.key()].isSpotColor()) || (colorsToUse[itf.key()].isRegistrationColor())) |
||
1048 | { |
||
1049 | int cc, cm, cy, ck; |
||
1050 | struct SpotC spotD; |
||
1051 | colorsToUse[itf.key()].getCMYK(&cc, &cm, &cy, &ck); |
||
1052 | QString colorDesc = "{\ndup "+FToStr(static_cast<double>(cc) / 255)+"\nmul exch dup "; |
||
1053 | colorDesc += FToStr(static_cast<double>(cm) / 255)+"\nmul exch dup "; |
||
1054 | colorDesc += FToStr(static_cast<double>(cy) / 255)+"\nmul exch "; |
||
1055 | colorDesc += FToStr(static_cast<double>(ck) / 255)+" mul }"; |
||
1056 | StartObj(ObjCounter); |
||
1057 | ObjCounter++; |
||
1058 | PutDoc("<<\n/FunctionType 4\n"); |
||
1059 | PutDoc("/Domain [0.0 1.0]\n"); |
||
1060 | PutDoc("/Range [0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]\n"); |
||
1061 | PutDoc("/Length "+IToStr(colorDesc.length()+1)+"\n"); |
||
1062 | PutDoc(">>\nstream\n"+EncStream(&colorDesc, ObjCounter-1)+"\nendstream\nendobj\n"); |
||
1063 | StartObj(ObjCounter); |
||
1064 | PutDoc("[ /Separation /"); |
||
1065 | if (colorsToUse[itf.key()].isRegistrationColor()) |
||
1066 | PutDoc("All"); |
||
1067 | else |
||
3440 | fschmid | 1068 | PutDoc(itf.key().simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ).replace("#", "_")); |
3133 | fschmid | 1069 | PutDoc(" /DeviceCMYK "+IToStr(ObjCounter-1)+" 0 R ]\nendobj\n"); |
1070 | spotD.ResName = spotNam+IToStr(spotCount); |
||
1071 | spotD.ResNum = ObjCounter; |
||
1072 | spotMap.insert(itf.key(), spotD); |
||
1073 | spotCount++; |
||
1074 | ObjCounter++; |
||
1075 | } |
||
1076 | } |
||
1077 | } |
||
1078 | if ((Options->Version == 15) && (Options->useLayers)) |
||
1079 | { |
||
1080 | struct Layer ll; |
||
1081 | struct OCGInfo ocg; |
||
1082 | ll.isPrintable = false; |
||
1083 | ll.LNr = 0; |
||
1084 | int Lnr = 0; |
||
3829 | cbradney | 1085 | QString ocgNam("oc"); |
1086 | uint docLayersCount=doc->Layers.count(); |
||
1087 | for (uint la = 0; la < docLayersCount; ++la) |
||
3133 | fschmid | 1088 | { |
3829 | cbradney | 1089 | QString tmp(""); |
3133 | fschmid | 1090 | Level2Layer(doc, &ll, Lnr); |
1091 | ocg.Name = ocgNam+tmp.setNum(ll.LNr); |
||
1092 | ocg.ObjNum = ObjCounter; |
||
1093 | ocg.visible = ll.isViewable; |
||
1094 | OCGEntries.insert(ll.Name, ocg); |
||
1095 | StartObj(ObjCounter); |
||
1096 | ObjCounter++; |
||
1097 | PutDoc("<<\n"); |
||
1098 | PutDoc("/Type /OCG\n"); |
||
1099 | PutDoc("/Name ("+ll.Name+")\n"); |
||
1100 | PutDoc(">>\nendobj\n"); |
||
1101 | Lnr++; |
||
1102 | } |
||
1103 | } |
||
1104 | return true; |
||
1105 | } |
||
1106 | |||
1107 | void PDFlib::PDF_TemplatePage(Page* pag, bool ) |
||
1108 | { |
||
1109 | QString tmp; |
||
1110 | ActPageP = pag; |
||
1111 | PageItem* ite; |
||
1112 | QPtrList<PageItem> PItems; |
||
1113 | int Lnr = 0; |
||
1114 | struct Layer ll; |
||
1115 | ll.isPrintable = false; |
||
1116 | ll.LNr = 0; |
||
1117 | Inhalt = ""; |
||
1118 | Seite.AObjects.clear(); |
||
1119 | for (uint la = 0; la < doc->Layers.count(); ++la) |
||
1120 | { |
||
1121 | Level2Layer(doc, &ll, Lnr); |
||
1122 | PItems = doc->MasterItems; |
||
1123 | if (ll.isPrintable) |
||
1124 | { |
||
1125 | if ((Options->Version == 15) && (Options->useLayers)) |
||
1126 | PutPage("/OC /"+OCGEntries[ll.Name].Name+" BDC\n"); |
||
1127 | for (uint a = 0; a < PItems.count(); ++a) |
||
1128 | { |
||
1129 | Inhalt = ""; |
||
1130 | ite =PItems.at(a); |
||
1131 | if (ite->LayerNr != ll.LNr) |
||
1132 | continue; |
||
3200 | cbradney | 1133 | int x = static_cast<int>(pag->xOffset()); |
1134 | int y = static_cast<int>(pag->yOffset()); |
||
1135 | int w = static_cast<int>(pag->width()); |
||
1136 | int h1 = static_cast<int>(pag->height()); |
||
3133 | fschmid | 1137 | int x2 = static_cast<int>(ite->BoundingX - ite->Pwidth / 2.0); |
1138 | int y2 = static_cast<int>(ite->BoundingY - ite->Pwidth / 2.0); |
||
1139 | int w2 = static_cast<int>(ite->BoundingW + ite->Pwidth); |
||
1140 | int h2 = static_cast<int>(ite->BoundingH + ite->Pwidth); |
||
1141 | if (!QRect(x, y, w, h1).intersects(QRect(x2, y2, w2, h2))) |
||
1142 | continue; |
||
1143 | if (ite->ChangedMasterItem) |
||
1144 | continue; |
||
3200 | cbradney | 1145 | if ((!pag->PageNam.isEmpty()) && (ite->OwnPage != static_cast<int>(pag->pageNr())) && (ite->OwnPage != -1)) |
3133 | fschmid | 1146 | continue; |
1147 | PutPage("q\n"); |
||
1148 | if (((ite->fillTransparency() != 0) || (ite->lineTransparency() != 0)) && (Options->Version >= 14)) |
||
1149 | PutPage(PDF_Transparenz(ite)); |
||
1150 | if ((ite->isBookmark) && (Options->Bookmarks)) |
||
3903 | cbradney | 1151 | PDF_Bookmark(ite->BMnr, pag->height() - (ite->yPos() - pag->yOffset())); |
3133 | fschmid | 1152 | if (!ite->printable() || ((ite->itemType() == PageItem::TextFrame) && (!pag->PageNam.isEmpty()))) |
1153 | { |
||
1154 | PutPage("Q\n"); |
||
1155 | continue; |
||
1156 | } |
||
1157 | if (ite->fillColor() != "None") |
||
1158 | PutPage(putColor(ite->fillColor(), ite->fillShade(), true)); |
||
1159 | if (ite->lineColor() != "None") |
||
1160 | PutPage(putColor(ite->lineColor(), ite->lineShade(), false)); |
||
1161 | Inhalt += FToStr(fabs(ite->Pwidth))+" w\n"; |
||
1162 | if (ite->DashValues.count() != 0) |
||
1163 | { |
||
1164 | PutPage("[ "); |
||
1165 | QValueList<double>::iterator it; |
||
1166 | for ( it = ite->DashValues.begin(); it != ite->DashValues.end(); ++it ) |
||
1167 | { |
||
1168 | int da = static_cast<int>(*it); |
||
1169 | if (da != 0) |
||
1170 | PutPage(IToStr(da)+" "); |
||
1171 | } |
||
1172 | PutPage("] "+IToStr(static_cast<int>(ite->DashOffset))+" d\n"); |
||
1173 | } |
||
1174 | else |
||
1175 | { |
||
1176 | QString Dt = FToStr(QMAX(2*fabs(ite->Pwidth), 1)); |
||
1177 | QString Da = FToStr(QMAX(6*fabs(ite->Pwidth), 1)); |
||
1178 | switch (ite->PLineArt) |
||
1179 | { |
||
1180 | case Qt::SolidLine: |
||
1181 | PutPage("[] 0 d\n"); |
||
1182 | break; |
||
1183 | case Qt::DashLine: |
||
1184 | PutPage("["+Da+" "+Dt+"] 0 d\n"); |
||
1185 | break; |
||
1186 | case Qt::DotLine: |
||
1187 | PutPage("["+Dt+"] 0 d\n"); |
||
1188 | break; |
||
1189 | case Qt::DashDotLine: |
||
1190 | PutPage("["+Da+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n"); |
||
1191 | break; |
||
1192 | case Qt::DashDotDotLine: |
||
1193 | PutPage("["+Da+" "+Dt+" "+Dt+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n"); |
||
1194 | break; |
||
1195 | default: |
||
1196 | PutPage("[] 0 d\n"); |
||
1197 | break; |
||
1198 | } |
||
1199 | } |
||
1200 | switch (ite->PLineEnd) |
||
1201 | { |
||
1202 | case Qt::FlatCap: |
||
1203 | PutPage("0 J\n"); |
||
1204 | break; |
||
1205 | case Qt::SquareCap: |
||
1206 | PutPage("2 J\n"); |
||
1207 | break; |
||
1208 | case Qt::RoundCap: |
||
1209 | PutPage("1 J\n"); |
||
1210 | break; |
||
1211 | default: |
||
1212 | PutPage("0 J\n"); |
||
1213 | break; |
||
1214 | } |
||
1215 | switch (ite->PLineJoin) |
||
1216 | { |
||
1217 | case Qt::MiterJoin: |
||
1218 | PutPage("0 j\n"); |
||
1219 | break; |
||
1220 | case Qt::BevelJoin: |
||
1221 | PutPage("2 j\n"); |
||
1222 | break; |
||
1223 | case Qt::RoundJoin: |
||
1224 | PutPage("1 j\n"); |
||
1225 | break; |
||
1226 | default: |
||
1227 | PutPage("0 j\n"); |
||
1228 | break; |
||
1229 | } |
||
3903 | cbradney | 1230 | PutPage("1 0 0 1 "+FToStr(ite->xPos() - pag->xOffset())+" "+FToStr(pag->height() - (ite->yPos() - pag->yOffset()))+" cm\n"); |
3934 | cbradney | 1231 | if (ite->rotation() != 0) |
3133 | fschmid | 1232 | { |
3934 | cbradney | 1233 | double sr = sin(-ite->rotation()* M_PI / 180.0); |
1234 | double cr = cos(-ite->rotation()* M_PI / 180.0); |
||
3133 | fschmid | 1235 | if ((cr * cr) < 0.000001) |
1236 | cr = 0; |
||
1237 | if ((sr * sr) < 0.000001) |
||
1238 | sr = 0; |
||
1239 | PutPage(FToStr(cr)+" "+FToStr(sr)+" "+FToStr(-sr)+" "+FToStr(cr)+" 0 0 cm\n"); |
||
1240 | } |
||
1241 | switch (ite->itemType()) |
||
1242 | { |
||
1243 | case PageItem::ImageFrame: |
||
1244 | if ((ite->fillColor() != "None") || (ite->GrType != 0)) |
||
1245 | { |
||
1246 | if (ite->GrType != 0) |
||
1247 | PutPage(PDF_Gradient(ite)); |
||
1248 | else |
||
1249 | { |
||
1250 | PutPage(SetClipPath(ite)); |
||
1251 | PutPage("h\nf*\n"); |
||
1252 | } |
||
1253 | } |
||
1254 | PutPage("q\n"); |
||
1255 | if (ite->imageClip.size() != 0) |
||
1256 | PutPage(SetClipPathImage(ite)); |
||
1257 | else |
||
1258 | PutPage(SetClipPath(ite)); |
||
1259 | PutPage("h\nW*\nn\n"); |
||
1260 | if (ite->imageFlippedH()) |
||
3934 | cbradney | 1261 | PutPage("-1 0 0 1 "+FToStr(ite->width())+" 0 cm\n"); |
3133 | fschmid | 1262 | if (ite->imageFlippedV()) |
3934 | cbradney | 1263 | PutPage("1 0 0 -1 0 "+FToStr(-ite->height())+" cm\n"); |
3133 | fschmid | 1264 | if ((ite->PicAvail) && (!ite->Pfile.isEmpty())) |
3985 | cbradney | 1265 | PutPage(PDF_Image(ite, ite->Pfile, ite->imageXScale(), ite->imageYScale(), ite->imageXOffset(), -ite->imageYOffset(), false, ite->IProfile, ite->UseEmbedded, ite->IRender)); |
3133 | fschmid | 1266 | PutPage("Q\n"); |
1267 | if (((ite->lineColor() != "None") || (!ite->NamedLStyle.isEmpty())) && (!ite->isTableItem)) |
||
1268 | { |
||
1269 | if ((ite->NamedLStyle.isEmpty()) && (ite->Pwidth != 0.0)) |
||
1270 | { |
||
1271 | PutPage(SetClipPath(ite)); |
||
1272 | PutPage("h\nS\n"); |
||
1273 | } |
||
1274 | else |
||
1275 | { |
||
1276 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1277 | for (int it = ml.size()-1; it > -1; it--) |
||
1278 | { |
||
1279 | PutPage(setStrokeMulti(&ml[it])); |
||
1280 | PutPage(SetClipPath(ite)); |
||
1281 | PutPage("h\nS\n"); |
||
1282 | } |
||
1283 | } |
||
1284 | } |
||
1285 | break; |
||
1286 | case PageItem::TextFrame: |
||
1287 | break; |
||
1288 | case PageItem::Line: |
||
1289 | if (ite->NamedLStyle.isEmpty()) |
||
1290 | { |
||
1291 | PutPage("0 0 m\n"); |
||
3934 | cbradney | 1292 | PutPage(FToStr(ite->width())+" 0 l\n"); |
3133 | fschmid | 1293 | PutPage("S\n"); |
1294 | } |
||
1295 | else |
||
1296 | { |
||
1297 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1298 | for (int it = ml.size()-1; it > -1; it--) |
||
1299 | { |
||
1300 | PutPage(setStrokeMulti(&ml[it])); |
||
1301 | PutPage("0 0 m\n"); |
||
3934 | cbradney | 1302 | PutPage(FToStr(ite->width())+" 0 l\n"); |
3133 | fschmid | 1303 | PutPage("S\n"); |
1304 | } |
||
1305 | } |
||
4061 | craig | 1306 | if (ite->startArrowIndex() != 0) |
3133 | fschmid | 1307 | { |
1308 | QWMatrix arrowTrans; |
||
4061 | craig | 1309 | FPointArray arrow = (*doc->arrowStyles.at(ite->startArrowIndex()-1)).points.copy(); |
3133 | fschmid | 1310 | arrowTrans.translate(0, 0); |
1311 | arrowTrans.scale(ite->Pwidth, ite->Pwidth); |
||
1312 | arrowTrans.scale(-1,1); |
||
1313 | arrow.map(arrowTrans); |
||
1314 | if ((ite->lineTransparency() != 0) && (Options->Version >= 14)) |
||
1315 | { |
||
1316 | StartObj(ObjCounter); |
||
1317 | QString ShName = ResNam+IToStr(ResCount); |
||
1318 | Transpar[ShName] = ObjCounter; |
||
1319 | ResCount++; |
||
1320 | ObjCounter++; |
||
1321 | PutDoc("<< /Type /ExtGState\n"); |
||
1322 | PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1323 | PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1324 | PutDoc("/SMask /None\n/AIS false\n/OPM 1\n"); |
||
1325 | PutDoc("/BM /Normal\n>>\nendobj\n"); |
||
1326 | PutPage("/"+ShName+" gs\n"); |
||
1327 | } |
||
4016 | fschmid | 1328 | PutPage(putColor(ite->lineColor(), ite->lineShade(), true)); |
3133 | fschmid | 1329 | PutPage(SetClipPathArray(&arrow)); |
1330 | PutPage("h\nf*\n"); |
||
1331 | } |
||
4061 | craig | 1332 | if (ite->endArrowIndex() != 0) |
3133 | fschmid | 1333 | { |
1334 | QWMatrix arrowTrans; |
||
4061 | craig | 1335 | FPointArray arrow = (*doc->arrowStyles.at(ite->endArrowIndex()-1)).points.copy(); |
3934 | cbradney | 1336 | arrowTrans.translate(ite->width(), 0); |
3133 | fschmid | 1337 | arrowTrans.scale(ite->Pwidth, ite->Pwidth); |
1338 | arrow.map(arrowTrans); |
||
1339 | if ((ite->lineTransparency() != 0) && (Options->Version >= 14)) |
||
1340 | { |
||
1341 | StartObj(ObjCounter); |
||
1342 | QString ShName = ResNam+IToStr(ResCount); |
||
1343 | Transpar[ShName] = ObjCounter; |
||
1344 | ResCount++; |
||
1345 | ObjCounter++; |
||
1346 | PutDoc("<< /Type /ExtGState\n"); |
||
1347 | PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1348 | PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1349 | PutDoc("/SMask /None\n/AIS false\n/OPM 1\n"); |
||
1350 | PutDoc("/BM /Normal\n>>\nendobj\n"); |
||
1351 | PutPage("/"+ShName+" gs\n"); |
||
1352 | } |
||
4016 | fschmid | 1353 | PutPage(putColor(ite->lineColor(), ite->lineShade(), true)); |
3133 | fschmid | 1354 | PutPage(SetClipPathArray(&arrow)); |
1355 | PutPage("h\nf*\n"); |
||
1356 | } |
||
1357 | break; |
||
3232 | cbradney | 1358 | case PageItem::ItemType1: |
1359 | case PageItem::ItemType3: |
||
3133 | fschmid | 1360 | case PageItem::Polygon: |
1361 | if (ite->GrType != 0) |
||
1362 | PutPage(PDF_Gradient(ite)); |
||
1363 | else |
||
1364 | { |
||
1365 | if (ite->fillColor() != "None") |
||
1366 | { |
||
1367 | PutPage(SetClipPath(ite)); |
||
1368 | PutPage("h\nf*\n"); |
||
1369 | } |
||
1370 | } |
||
1371 | if ((ite->lineColor() != "None") || (!ite->NamedLStyle.isEmpty())) |
||
1372 | { |
||
1373 | if ((ite->NamedLStyle.isEmpty()) && (ite->Pwidth != 0.0)) |
||
1374 | { |
||
1375 | PutPage(SetClipPath(ite)); |
||
1376 | PutPage("h\nS\n"); |
||
1377 | } |
||
1378 | else |
||
1379 | { |
||
1380 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1381 | for (int it = ml.size()-1; it > -1; it--) |
||
1382 | { |
||
1383 | PutPage(setStrokeMulti(&ml[it])); |
||
1384 | PutPage(SetClipPath(ite)); |
||
1385 | PutPage("h\nS\n"); |
||
1386 | } |
||
1387 | } |
||
1388 | } |
||
1389 | break; |
||
1390 | case PageItem::PolyLine: |
||
1391 | if ((ite->PoLine.size() > 3) && ((ite->PoLine.point(0) != ite->PoLine.point(1)) || (ite->PoLine.point(2) != ite->PoLine.point(3)))) |
||
1392 | { |
||
1393 | if (ite->GrType != 0) |
||
1394 | PutPage(PDF_Gradient(ite)); |
||
1395 | else |
||
1396 | { |
||
1397 | if (ite->fillColor() != "None") |
||
1398 | { |
||
1399 | PutPage(SetClipPath(ite)); |
||
1400 | PutPage("h\nf*\n"); |
||
1401 | } |
||
1402 | } |
||
1403 | } |
||
1404 | if ((ite->lineColor() != "None") || (!ite->NamedLStyle.isEmpty())) |
||
1405 | { |
||
1406 | if ((ite->NamedLStyle.isEmpty()) && (ite->Pwidth != 0.0)) |
||
1407 | { |
||
1408 | PutPage(SetClipPath(ite, false)); |
||
1409 | PutPage("S\n"); |
||
1410 | } |
||
1411 | else |
||
1412 | { |
||
1413 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1414 | for (int it = ml.size()-1; it > -1; it--) |
||
1415 | { |
||
1416 | PutPage(setStrokeMulti(&ml[it])); |
||
1417 | PutPage(SetClipPath(ite, false)); |
||
1418 | PutPage("S\n"); |
||
1419 | } |
||
1420 | } |
||
1421 | } |
||
4061 | craig | 1422 | if (ite->startArrowIndex() != 0) |
3133 | fschmid | 1423 | { |
1424 | FPoint Start = ite->PoLine.point(0); |
||
1425 | for (uint xx = 1; xx < ite->PoLine.size(); xx += 2) |
||
1426 | { |
||
1427 | FPoint Vector = ite->PoLine.point(xx); |
||
1428 | if ((Start.x() != Vector.x()) || (Start.y() != Vector.y())) |
||
1429 | { |
||
1430 | double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI); |
||
1431 | QWMatrix arrowTrans; |
||
4061 | craig | 1432 | FPointArray arrow = (*doc->arrowStyles.at(ite->startArrowIndex()-1)).points.copy(); |
3133 | fschmid | 1433 | arrowTrans.translate(Start.x(), Start.y()); |
1434 | arrowTrans.rotate(r); |
||
1435 | arrowTrans.scale(ite->Pwidth, ite->Pwidth); |
||
1436 | arrow.map(arrowTrans); |
||
1437 | if ((ite->lineTransparency() != 0) && (Options->Version >= 14)) |
||
1438 | { |
||
1439 | StartObj(ObjCounter); |
||
1440 | QString ShName = ResNam+IToStr(ResCount); |
||
1441 | Transpar[ShName] = ObjCounter; |
||
1442 | ResCount++; |
||
1443 | ObjCounter++; |
||
1444 | PutDoc("<< /Type /ExtGState\n"); |
||
1445 | PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1446 | PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1447 | PutDoc("/SMask /None\n/AIS false\n/OPM 1\n"); |
||
1448 | PutDoc("/BM /Normal\n>>\nendobj\n"); |
||
1449 | PutPage("/"+ShName+" gs\n"); |
||
1450 | } |
||
4016 | fschmid | 1451 | PutPage(putColor(ite->lineColor(), ite->lineShade(), true)); |
3133 | fschmid | 1452 | PutPage(SetClipPathArray(&arrow)); |
1453 | PutPage("h\nf*\n"); |
||
1454 | break; |
||
1455 | } |
||
1456 | } |
||
1457 | } |
||
4061 | craig | 1458 | if (ite->endArrowIndex() != 0) |
3133 | fschmid | 1459 | { |
1460 | FPoint End = ite->PoLine.point(ite->PoLine.size()-2); |
||
1461 | for (uint xx = ite->PoLine.size()-1; xx > 0; xx -= 2) |
||
1462 | { |
||
1463 | FPoint Vector = ite->PoLine.point(xx); |
||
1464 | if ((End.x() != Vector.x()) || (End.y() != Vector.y())) |
||
1465 | { |
||
1466 | double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI); |
||
1467 | QWMatrix arrowTrans; |
||
4061 | craig | 1468 | FPointArray arrow = (*doc->arrowStyles.at(ite->endArrowIndex()-1)).points.copy(); |
3133 | fschmid | 1469 | arrowTrans.translate(End.x(), End.y()); |
1470 | arrowTrans.rotate(r); |
||
1471 | arrowTrans.scale(ite->Pwidth, ite->Pwidth); |
||
1472 | arrow.map(arrowTrans); |
||
1473 | if ((ite->lineTransparency() != 0) && (Options->Version >= 14)) |
||
1474 | { |
||
1475 | StartObj(ObjCounter); |
||
1476 | QString ShName = ResNam+IToStr(ResCount); |
||
1477 | Transpar[ShName] = ObjCounter; |
||
1478 | ResCount++; |
||
1479 | ObjCounter++; |
||
1480 | PutDoc("<< /Type /ExtGState\n"); |
||
1481 | PutDoc("/CA "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1482 | PutDoc("/ca "+FToStr(1.0 - ite->lineTransparency())+"\n"); |
||
1483 | PutDoc("/SMask /None\n/AIS false\n/OPM 1\n"); |
||
1484 | PutDoc("/BM /Normal\n>>\nendobj\n"); |
||
1485 | PutPage("/"+ShName+" gs\n"); |
||
1486 | } |
||
4016 | fschmid | 1487 | PutPage(putColor(ite->lineColor(), ite->lineShade(), true)); |
3133 | fschmid | 1488 | PutPage(SetClipPathArray(&arrow)); |
1489 | PutPage("h\nf*\n"); |
||
1490 | break; |
||
1491 | } |
||
1492 | } |
||
1493 | } |
||
1494 | break; |
||
1495 | case PageItem::PathText: |
||
1496 | if (ite->PoShow) |
||
1497 | { |
||
1498 | if (ite->PoLine.size() > 3) |
||
1499 | { |
||
1500 | PutPage("q\n"); |
||
1501 | if ((ite->lineColor() != "None") || (!ite->NamedLStyle.isEmpty())) |
||
1502 | { |
||
1503 | if ((ite->NamedLStyle.isEmpty()) && (ite->Pwidth != 0.0)) |
||
1504 | { |
||
1505 | PutPage(SetClipPath(ite, false)); |
||
1506 | PutPage("S\n"); |
||
1507 | } |
||
1508 | else |
||
1509 | { |
||
1510 | multiLine ml = doc->MLineStyles[ite->NamedLStyle]; |
||
1511 | for (int it = ml.size()-1; |
||
1512 | it > -1; it--) |
||
1513 | { |
||
1514 | PutPage(setStrokeMulti(&ml[it])); |
||
1515 | PutPage(SetClipPath(ite, false)); |
||
1516 | PutPage("S\n"); |
||
1517 | } |
||
1518 | } |
||
1519 | } |
||
1520 | PutPage("Q\n"); |
||
1521 | } |
||
1522 | } |
||
3200 | cbradney | 1523 | PutPage(setTextSt(ite, pag->pageNr(), pag)); |
3133 | fschmid | 1524 | break; |
1525 | } |
||
1526 | PutPage("Q\n"); |
||
1527 | StartObj(ObjCounter); |
||
1528 | ObjCounter++; |
||
1529 | PutDoc("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1\n"); |
||
3200 | cbradney | 1530 | PutDoc("/BBox [ 0 0 "+FToStr(ActPageP->width())+" "+FToStr(ActPageP->height())+" ]\n"); |
3133 | fschmid | 1531 | PutDoc("/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n"); |
1532 | if (Seite.ImgObjects.count() != 0) |
||
1533 | { |
||
1534 | PutDoc("/XObject <<\n"); |
||
1535 | QMap<QString,int>::Iterator it; |
||
1536 | for (it = Seite.ImgObjects.begin(); it != Seite.ImgObjects.end(); ++it) |
||
1537 | PutDoc("/"+it.key()+" "+IToStr(it.data())+" 0 R\n"); |
||
1538 | PutDoc(">>\n"); |
||
1539 | } |
||
1540 | if (Seite.FObjects.count() != 0) |
||
1541 | { |
||
1542 | PutDoc("/Font << \n"); |
||
1543 | QMap<QString,int>::Iterator it2; |
||
1544 | for (it2 = Seite.FObjects.begin(); it2 != Seite.FObjects.end(); ++it2) |
||
1545 | PutDoc("/"+it2.key()+" "+IToStr(it2.data())+" 0 R\n"); |
||
1546 | PutDoc(">>\n"); |
||
1547 | } |
||
1548 | if (Shadings.count() != 0) |
||
1549 | { |
||
1550 | PutDoc("/Shading << \n"); |
||
1551 | QMap<QString,int>::Iterator it3; |
||
1552 | for (it3 = Shadings.begin(); it3 != Shadings.end(); ++it3) |
||
1553 | PutDoc("/"+it3.key()+" "+IToStr(it3.data())+" 0 R\n"); |
||
1554 | PutDoc(">>\n"); |
||
1555 | } |
||
1556 | if (Transpar.count() != 0) |
||
1557 | { |
||
1558 | PutDoc("/ExtGState << \n"); |
||
1559 | QMap<QString,int>::Iterator it3t; |
||
1560 | for (it3t = Transpar.begin(); it3t != Transpar.end(); ++it3t) |
||
1561 | PutDoc("/"+it3t.key()+" "+IToStr(it3t.data())+" 0 R\n"); |
||
1562 | PutDoc(">>\n"); |
||
1563 | } |
||
1564 | if ((ICCProfiles.count() != 0) || (spotMap.count() != 0)) |
||
1565 | { |
||
1566 | PutDoc("/ColorSpace << \n"); |
||
1567 | QMap<QString,ICCD>::Iterator it3c; |
||
1568 | if (ICCProfiles.count() != 0) |
||
1569 | { |
||
1570 | for (it3c = ICCProfiles.begin(); it3c != ICCProfiles.end(); ++it3c) |
||
1571 | PutDoc("/"+it3c.data().ResName+" "+IToStr(it3c.data().ResNum)+" 0 R\n"); |
||
1572 | } |
||
1573 | QMap<QString,SpotC>::Iterator it3sc; |
||
1574 | if (spotMap.count() != 0) |
||
1575 | { |
||
1576 | for (it3sc = spotMap.begin(); it3sc != spotMap.end(); ++it3sc) |
||
1577 | PutDoc("/"+it3sc.data().ResName+" "+IToStr(it3sc.data().ResNum)+" 0 R\n"); |
||
1578 | } |
||
1579 | PutDoc(">>\n"); |
||
1580 | } |
||
1581 | PutDoc(">>\n"); |
||
1582 | if ((Options->Compress) && (CompAvail)) |
||
1583 | Inhalt = CompressStr(&Inhalt); |
||
1584 | PutDoc("/Length "+IToStr(Inhalt.length()+1)); |
||
1585 | if ((Options->Compress) && (CompAvail)) |
||
1586 | PutDoc("\n/Filter /FlateDecode"); |
||
1587 | PutDoc(" >>\nstream\n"+EncStream(&Inhalt, ObjCounter-1)+"\nendstream\nendobj\n"); |
||
3440 | fschmid | 1588 | QString name = pag->PageNam.simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ) + IToStr(ite->ItemNr); |
3133 | fschmid | 1589 | Seite.XObjects[name] = ObjCounter-1; |
1590 | } |
||
1591 | if ((Options->Version == 15) && (Options->useLayers)) |
||
1592 | PutPage("EMC\n"); |
||
1593 | } |
||
1594 | Lnr++; |
||
1595 | } |
||
1596 | } |
||
1597 | |||
1598 | void PDFlib::PDF_Begin_Page(Page* pag, QPixmap pm) |
||
1599 | { |
||
1600 | QString tmp; |
||
1601 | ActPageP = pag; |
||
1602 | Inhalt = ""; |
||
1603 | Seite.AObjects.clear(); |
||
1604 | if (Options->Thumbnails) |
||
1605 | { |
||
1606 | ScImage img = pm.convertToImage(); |
||
1607 | QString im = img.ImageToTxt(); |
||
1608 | if ((Options->Compress) && (CompAvail)) |
||
1609 | im = CompressStr(&im); |
||
1610 | StartObj(ObjCounter); |
||
1611 | PutDoc("<<\n/Width "+IToStr(img.width())+"\n"); |
||
1612 | PutDoc("/Height "+IToStr(img.height())+"\n"); |
||
1613 | PutDoc("/ColorSpace /DeviceRGB\n/BitsPerComponent 8\n"); |
||
1614 | PutDoc("/Length "+IToStr(im.length()+1)+"\n"); |
||
1615 | if ((Options->Compress) && (CompAvail)) |
||
1616 | PutDoc("/Filter /FlateDecode\n"); |
||
1617 | PutDoc(">>\nstream\n"+EncStream(&im, ObjCounter)+"\nendstream\nendobj\n"); |
||
1618 | Seite.Thumb = ObjCounter; |
||
1619 | ObjCounter++; |
||
1620 | } |
||
1621 | } |
||
1622 | |||
1623 | void PDFlib::PDF_End_Page() |
||
1624 | { |
||
3200 | cbradney | 1625 | uint PgNr = ActPageP->pageNr(); |
3133 | fschmid | 1626 | Seite.ObjNum = ObjCounter; |
4084 | cbradney | 1627 | WritePDFStream(Inhalt); |
3133 | fschmid | 1628 | StartObj(ObjCounter); |
1629 | PutDoc("<<\n/Type /Page\n/Parent 4 0 R\n"); |
||
3200 | cbradney | 1630 | PutDoc("/MediaBox [0 0 "+FToStr(ActPageP->width())+" "+FToStr(ActPageP->height())+"]\n"); |
3133 | fschmid | 1631 | PutDoc("/TrimBox ["+FToStr(Options->BleedLeft)+" "+FToStr(Options->BleedBottom)+ |
3200 | cbradney | 1632 | " "+FToStr(ActPageP->width()-Options->BleedRight)+" "+FToStr(ActPageP->height()-Options->BleedTop)+"]\n"); |
3133 | fschmid | 1633 | PutDoc("/Rotate "+IToStr(Options->RotateDeg)+"\n"); |
1634 | PutDoc("/Contents "+IToStr(Seite.ObjNum)+" 0 R\n"); |
||
1635 | if (Options->Thumbnails) |
||
1636 | PutDoc("/Thumb "+IToStr(Seite.Thumb)+" 0 R\n"); |
||
1637 | if (Seite.AObjects.count() != 0) |
||
1638 | { |
||
1639 | PutDoc("/Annots [ "); |
||
1640 | for (uint b = 0; b < Seite.AObjects.count(); ++b) |
||
1641 | PutDoc(IToStr(Seite.AObjects[b])+" 0 R "); |
||
1642 | PutDoc("]\n"); |
||
1643 | } |
||
1644 | if (Options->PresentMode) |
||
1645 | { |
||
1646 | PutDoc("/Dur "+IToStr(Options->PresentVals[PgNr].pageViewDuration)+"\n"); |
||
1647 | if (Options->PresentVals[PgNr].effectType != 0) |
||
1648 | { |
||
1649 | PutDoc("/Trans << /Type /Trans\n"); |
||
1650 | PutDoc("/D "+IToStr(Options->PresentVals[PgNr].pageEffectDuration)+"\n"); |
||
1651 | switch (Options->PresentVals[PgNr].effectType) |
||
1652 | { |
||
1653 | case 1: |
||
1654 | PutDoc("/S /Blinds\n"); |
||
1655 | PutDoc(Options->PresentVals[PgNr].Dm == 0 ? "/Dm /H\n" : "/Dm /V\n"); |
||
1656 | break; |
||
1657 | case 2: |
||
1658 | PutDoc("/S /Box\n"); |
||
1659 | PutDoc(Options->PresentVals[PgNr].M == 0 ? "/M /I\n" : "/M /O\n"); |
||
1660 | break; |
||
1661 | case 3: |
||
1662 | PutDoc("/S /Dissolve\n"); |
||
1663 | break; |
||
1664 | case 4: |
||
1665 | PutDoc("/S /Glitter\n"); |
||
1666 | PutDoc("/Di "); |
||
1667 | switch (Options->PresentVals[PgNr].Di) |
||
1668 | { |
||
1669 | case 0: |
||
1670 | PutDoc("0"); |
||
1671 | break; |
||
1672 | case 1: |
||
1673 | PutDoc("270"); |
||
1674 | break; |
||
1675 | case 4: |
||
1676 | PutDoc("315"); |
||
1677 | break; |
||
1678 | default: |
||
1679 | PutDoc("0"); |
||
1680 | break; |
||
1681 | } |
||
1682 | PutDoc("\n"); |
||
1683 | break; |
||
1684 | case 5: |
||
1685 | PutDoc("/S /Split\n"); |
||
1686 | PutDoc(Options->PresentVals[PgNr].Dm == 0 ? "/Dm /H\n" : "/Dm /V\n"); |
||
1687 | PutDoc(Options->PresentVals[PgNr].M == 0 ? "/M /I\n" : "/M /O\n"); |
||
1688 | break; |
||
1689 | case 6: |
||
1690 | PutDoc("/S /Wipe\n"); |
||
1691 | PutDoc("/Di "); |
||
1692 | switch (Options->PresentVals[PgNr].Di) |
||
1693 | { |
||
1694 | case 0: |
||
1695 | PutDoc("0"); |
||
1696 | break; |
||
1697 | case 1: |
||
1698 | PutDoc("270"); |
||
1699 | break; |
||
1700 | case 2: |
||
1701 | PutDoc("90"); |
||
1702 | break; |
||
1703 | case 3: |
||
1704 | PutDoc("180"); |
||
1705 | break; |
||
1706 | default: |
||
1707 | PutDoc("0"); |
||
1708 | break; |
||
1709 | } |
||
1710 | PutDoc("\n"); |
||
1711 | break; |
||
1712 | } |
||
1713 | PutDoc(">>\n"); |
||
1714 | } |
||
1715 | } |
||
1716 | PutDoc(">>\nendobj\n"); |
||
1717 | PageTree.Count++; |
||
1718 | PageTree.Kids.append(ObjCounter); |
||
1719 | ObjCounter++; |
||
1720 | } |
||
1721 | |||
1722 | void PDFlib::PDF_ProcessPage(Page* pag, uint PNr, bool clip) |
||
1723 | { |
||
1724 | QString tmp; |
||
1725 | ActPageP = pag; |
||
1726 | PageItem* ite; |
||
1727 | QPtrList<PageItem> PItems; |
||
1728 | int Lnr = 0; |
||
1729 | struct Layer ll; |
||
1730 | ll.isPrintable = false; |
||
1731 | ll.LNr = 0; |
||
1732 | if (Options->UseLPI) |
||
1733 | PutPage("/"+HTName+" gs\n"); |
||
1734 | if ( (Options->MirrorH) && (!pag->MPageNam.isEmpty()) ) |
||
3200 | cbradney | 1735 | PutPage("-1 0 0 1 "+FToStr(ActPageP->width())+" 0 cm\n"); |
3133 | fschmid | 1736 | if ( (Options->MirrorV) && (!pag->MPageNam.isEmpty()) ) |
3200 | cbradney | 1737 | PutPage("1 0 0 -1 0 "+FToStr(ActPageP->height())+" cm\n"); |
3133 | fschmid | 1738 | if (clip) |
1739 | { |
||
1740 | PutPage(FToStr(pag->Margins.Left) + " " + FToStr(pag->Margins.Bottom) + " m\n"); |
||
3200 | cbradney | 1741 | PutPage(FToStr(ActPageP->width() - pag->Margins.Right) + " " + FToStr(pag->Margins.Bottom) + " l\n"); |
1742 | PutPage(FToStr(ActPageP->width() - pag->Margins.Right) + " " + FToStr(ActPageP->height() - pag->Margins.Top) + " l\n"); |
||
1743 | PutPage(FToStr(pag->Margins.Left) + " " + FToStr(ActPageP->height() - pag->Margins.Top) + " l h W n\n"); |
||
3133 | fschmid | 1744 | } |
1745 | else |
||
3200 | cbradney | 1746 | PutPage("0 0 "+FToStr(ActPageP->width())+" "+FToStr(ActPageP->height())+" re W n\n"); |
4030 | cbradney | 1747 | |
3133 | fschmid | 1748 | if (!pag->MPageNam.isEmpty()) |
1749 | { |
||
3724 | cbradney | 1750 | Page* mPage = doc->MasterPages.at(doc->MasterNames[doc->Pages->at(PNr)->MPageNam]); |
3133 | fschmid | 1751 | if (doc->MasterItems.count() != 0) |
1752 | { |
||
1753 | if (!Options->MirrorH) |
||
1754 | PutPage("1 0 0 1 0 0 cm\n"); |
||
1755 | for (uint lam = 0; lam < doc->Layers.count(); ++lam) |
||
1756 | { |
||
1757 | Level2Layer(doc, &ll, Lnr); |
||
1758 | Lnr++; |
||
1759 | if (ll.isPrintable) |
||
1760 | { |
||
1761 | if ((Options->Version == 15) && (Options->useLayers)) |
||
1762 | PutPage("/OC /"+OCGEntries[ll.Name].Name+" BDC\n"); |
||
1763 | for (uint am = 0; am < pag->FromMaster.count(); ++am) |
||
1764 | { |
||
1765 | ite = pag->FromMaster.at(am); |
||
1766 | if ((ite->LayerNr != ll.LNr) || (!ite->printable())) |
||
1767 | continue; |
||
3200 | cbradney | 1768 | if ((!pag->PageNam.isEmpty()) && (ite->OwnPage != static_cast<int>(pag->pageNr())) && (ite->OwnPage != -1)) |
3133 | fschmid | 1769 | continue; |
3440 | fschmid | 1770 | QString name = "/"+pag->MPageNam.simplifyWhiteSpace().replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ) + IToStr(ite->ItemNr); |
3625 | avox | 1771 | if (! ite->asTextFrame()) |
3133 | fschmid | 1772 | PutPage(name+" Do\n"); |
1773 | else |
||
1774 | { |
||
1775 | PutPage("q\n"); |
||
1776 | if (((ite->fillTransparency() != 0) || (ite->lineTransparency() != 0)) && (Options->Version >= 14)) |
||
1777 | PutPage(PDF_Transparenz(ite)); |
||
1778 | if (ite->fillColor() != "None") |
||
1779 | PutPage(putColor(ite->fillColor(), ite->fillShade(), true)); |
||
1780 | if (ite->lineColor() != "None") |
||
1781 | PutPage(putColor(ite->lineColor(), ite->lineShade(), false)); |
||
1782 | Inhalt += FToStr(fabs(ite->Pwidth))+" w\n"; |
||
1783 | if (ite->DashValues.count() != 0) |
||
1784 | { |
||
1785 | PutPage("[ "); |
||
1786 | QValueList<double>::iterator it; |
||
1787 | for ( it = ite->DashValues.begin(); it != ite->DashValues.end(); ++it ) |
||
1788 | { |
||
1789 | int da = static_cast<int>(*it); |
||
1790 | if (da != 0) |
||
1791 | PutPage(IToStr(da)+" "); |
||
1792 | PutPage(IToStr(static_cast<int>(*it))+" "); |
||
1793 | } |
||
1794 | } |
||
1795 | else |
||
1796 | { |
||
1797 | QString Dt = FToStr(QMAX(2*fabs(ite->Pwidth), 1)); |
||
1798 | QString Da = FToStr(QMAX(6*fabs(ite->Pwidth), 1)); |
||
1799 | switch (ite->PLineArt) |
||
1800 | { |
||
1801 | case Qt::SolidLine: |
||
1802 | PutPage("[] 0 d\n"); |
||
1803 | break; |
||
1804 | case Qt::DashLine: |
||
1805 | PutPage("["+Da+" "+Dt+"] 0 d\n"); |
||
1806 | break; |
||
1807 | case Qt::DotLine: |
||
1808 | PutPage("["+Dt+"] 0 d\n"); |
||
1809 | break; |
||
1810 | case Qt::DashDotLine: |
||
1811 | PutPage("["+Da+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n"); |
||
1812 | break; |
||
1813 | case Qt::DashDotDotLine: |
||
1814 | PutPage("["+Da+" "+Dt+" "+Dt+" "+Dt+" "+Dt+" "+Dt+"] 0 d\n"); |
||
1815 | break; |
||
1816 | default: |
||
1817 | PutPage("[] 0 d\n"); |
||
1818 | break; |
||
1819 | } |
||
1820 | } |
||
1821 | PutPage("2 J\n"); |
||
1822 | switch (ite->PLineJoin) |
||
1823 | { |
||
1824 | case Qt::MiterJoin: |
||
1825 | PutPage("0 j\n"); |
||
1826 | break; |
||
1827 | case Qt::BevelJoin: |
||
1828 | PutPage("2 j\n"); |
||
1829 | break; |
||
1830 | case Qt::RoundJoin: |
||
1831 | PutPage("1 j\n"); |
||
1832 | break; |
||
1833 | default: |
||
1834 | PutPage("0 j\n"); |
||
1835 | break; |
||
1836 | } |
||
3903 | cbradney | 1837 | PutPage("1 0 0 1 "+FToStr(ite->xPos() - mPage->xOffset())+" "+FToStr(mPage->height() - (ite->yPos() - mPage->yOffset()))+" cm\n"); |
3934 | cbradney | 1838 | if (ite->rotation() != 0) |
3133 | fschmid | 1839 | { |
3934 | cbradney | 1840 | double sr = sin(-ite->rotation()* M_PI / 180.0) |