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