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