201
201
if (!abortExport)
203
203
if (doc.PDF_Options.Version == PDFOptions::PDFVersion_X3)
204
PDF_End_Doc(ScMW->PrinterProfiles[doc.PDF_Options.PrintProf], nam, Components);
204
ret = PDF_End_Doc(ScMW->PrinterProfiles[doc.PDF_Options.PrintProf], nam, Components);
209
209
closeAndCleanup();
983
GListeInd glyphIndexes;
984
983
struct GlNamInd glIndexName;
985
GlyphsIdxOfFont.insert(it.key(), glyphIndexes);
984
QMap<uint,uint> glUniToIndex;
985
QMap<uint, GlNamInd> glIndexToNames;
986
986
QMap<uint,std::pair<uint,QString> > gl;
987
GlyNames2(AllFonts[it.key()], &gl);
987
GlyMaps(AllFonts[it.key()], &glUniToIndex, &gl);
989
989
QMap<uint,std::pair<uint,QString> >::Iterator gli;
990
990
for (gli = gl.begin(); gli != gl.end(); ++gli)
1011
1011
PutDoc(QString::number(static_cast<int>(AllFonts[it.key()]->CharWidth[gl[glyph].first] * 1000))+" ");
1012
1012
glIndexName.Code = chCount + Fc * 256;
1013
1013
glIndexName.Name = "/" + gl[glyph].second;
1014
glyphIndexes[gl[glyph].first] = glIndexName;
1014
glIndexToNames[glyph] = glIndexName;
1116
1116
Seite.FObjects["Fo"+QString::number(a)+"S"+QString::number(Fc)] = ObjCounter;
1119
GListeInd glyphIndexes;
1120
glyphIndexes.uniToIndex = glUniToIndex;
1121
glyphIndexes.indexToNames = glIndexToNames;
1119
1122
GlyphsIdxOfFont.insert(it.key(), glyphIndexes);
1120
1123
StartObj(ObjCounter);
1121
1124
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 0 ");
1240
1243
dataD.ResName = ResNam+QString::number(ResCount);
1241
1244
dataD.ICCArray = "[ /ICCBased "+QString::number(ObjCounter-1)+" 0 R ]";
1242
1245
dataD.ResNum = ObjCounter;
1246
dataD.components = Options.SComp;
1243
1247
ICCProfiles[Options.SolidProf] = dataD;
1244
1248
PutDoc("[ /ICCBased "+QString::number(ObjCounter-1)+" 0 R ]\n");
1245
1249
PutDoc("endobj\n");
3440
3444
chx = out2.mid(d-za2, 1);
3442
3446
uint cc = chx[0].unicode();
3444
if (GlyphsIdxOfFont[hl->cfont->scName()].contains(cc))
3445
idx = GlyphsIdxOfFont[hl->cfont->scName()][cc].Code;
3448
const GListeInd& listIndexes = GlyphsIdxOfFont[hl->cfont->scName()];
3449
QMap<uint, uint>::ConstIterator itl = listIndexes.uniToIndex.find(cc);
3450
if (itl != listIndexes.uniToIndex.end())
3453
QMap<uint, GlNamInd>::ConstIterator itx = listIndexes.indexToNames.find(ind);
3454
if( itx != listIndexes.indexToNames.end())
3455
idx = itx.data().Code;
3446
3457
uint idx1 = (idx >> 8) & 0xFF;
3447
3458
if (hl->cstyle & 32)
3597
cc = chx[0].unicode();
3608
cc = chx[0].unicode();
3599
if (GlyphsIdxOfFont[hl->cfont->scName()].contains(cc))
3600
idx = GlyphsIdxOfFont[hl->cfont->scName()][cc].Code;
3610
itl = listIndexes.uniToIndex.find(cc);
3611
if (itl != listIndexes.uniToIndex.end())
3614
QMap<uint, GlNamInd>::ConstIterator itx = listIndexes.indexToNames.find(ind);
3615
if( itx != listIndexes.indexToNames.end())
3616
idx = itx.data().Code;
3601
3618
idx1 = (idx >> 8) & 0xFF;
3602
3619
tmp += UsedFontsP[hl->cfont->scName()]+"S"+QString::number(idx1)+" "+FToStr(tsz / 10.0)+" Tf\n";
3603
3620
if (hl->cstroke != CommonStrings::None)
3651
3668
double wtr = Cwidth(&doc, hl->cfont, chx, chs) * (hl->cscale / 1000.0);
3652
3669
tmp += "1 0 0 1 "+FToStr(hl->xp+wtr)+" "+FToStr(-hl->yp+(hl->csize / 10.0) * (hl->cbase / 1000.0))+" Tm\n";
3654
cc = chx[0].unicode();
3671
cc = chx[0].unicode();
3656
if (GlyphsIdxOfFont[hl->cfont->scName()].contains(cc))
3657
idx = GlyphsIdxOfFont[hl->cfont->scName()][cc].Code;
3673
itl = listIndexes.uniToIndex.find(cc);
3674
if (itl != listIndexes.uniToIndex.end())
3677
QMap<uint, GlNamInd>::ConstIterator itx = listIndexes.indexToNames.find(ind);
3678
if( itx != listIndexes.indexToNames.end())
3679
idx = itx.data().Code;
3658
3681
idx1 = (idx >> 8) & 0xFF;
3659
3682
tmp += UsedFontsP[hl->cfont->scName()]+"S"+QString::number(idx1)+" "+FToStr(tsz / 10.0)+" Tf\n";
3660
3683
idx2 = idx & 0xFF;
5193
5216
bool found = false;
5194
5217
bool alphaM = false;
5195
5218
bool realCMYK = false;
5219
bool hasGrayProfile = false;
5220
QString profInUse = Profil;
5196
5221
int afl = Options.Resolution;
5197
5222
double x2, ax, ay, a2, a1;
5198
5223
double sxn = 0;
5387
5421
QString dataP = "";
5388
5422
struct ICCD dataD;
5389
5423
if ((Embedded) && (!Options.EmbeddedI))
5391
5424
img3.getEmbeddedProfile(fn, &dataP, &components);
5392
if (dataP.isEmpty())
5394
if (img.imgInfo.colorspace == 1)
5396
loadText((Embedded ? ScMW->InputProfilesCMYK[Options.ImageProf] : ScMW->InputProfilesCMYK[Profil]), &dataP);
5401
loadText((Embedded ? ScMW->InputProfiles[Options.ImageProf] : ScMW->InputProfiles[Profil]), &dataP);
5425
if ((dataP.isEmpty()) || ((img.imgInfo.colorspace == 2) && (hasColorEffect) && (components == 1)))
5408
5428
if (img.imgInfo.colorspace == 1)
5410
loadText((Embedded ? ScMW->InputProfilesCMYK[Options.ImageProf] : ScMW->InputProfilesCMYK[Profil]), &dataP);
5430
QString profilePath;
5431
if (Embedded && ScMW->InputProfilesCMYK.contains(Options.ImageProf))
5433
profilePath = ScMW->InputProfilesCMYK[Options.ImageProf];
5434
profInUse = Options.ImageProf;
5436
else if (ScMW->InputProfilesCMYK.contains(Profil))
5437
profilePath = ScMW->InputProfilesCMYK[Profil];
5440
profilePath = ScMW->InputProfilesCMYK[c->document()->CMSSettings.DefaultImageCMYKProfile];
5441
profInUse = c->document()->CMSSettings.DefaultImageCMYKProfile;
5443
loadText(profilePath, &dataP);
5411
5444
components = 4;
5448
QString profilePath;
5449
if (Embedded && ScMW->InputProfiles.contains(Options.ImageProf))
5451
profilePath = ScMW->InputProfiles[Options.ImageProf];
5452
profInUse = Options.ImageProf;
5454
else if (ScMW->InputProfiles.contains(Profil))
5455
profilePath = ScMW->InputProfiles[Profil];
5458
profilePath = ScMW->InputProfiles[c->document()->CMSSettings.DefaultImageRGBProfile];
5459
profInUse = c->document()->CMSSettings.DefaultImageRGBProfile;
5415
5461
loadText((Embedded ? ScMW->InputProfiles[Options.ImageProf] : ScMW->InputProfiles[Profil]), &dataP);
5416
5462
components = 3;
5429
5475
dataD.ResName = ResNam+QString::number(ResCount);
5430
5476
dataD.ICCArray = "[ /ICCBased "+QString::number(ObjCounter-1)+" 0 R ]";
5431
5477
dataD.ResNum = ObjCounter;
5432
ICCProfiles[Profil] = dataD;
5478
dataD.components = components;
5479
ICCProfiles[profInUse] = dataD;
5433
5480
PutDoc("[ /ICCBased "+QString::number(ObjCounter-1)+" 0 R ]\n");
5434
5481
PutDoc("endobj\n");
5484
hasGrayProfile = (components == 1);
5488
if (ICCProfiles[Profil].components == 1)
5490
if ((img.imgInfo.colorspace == 2) && (hasColorEffect))
5492
profInUse = c->document()->CMSSettings.DefaultImageRGBProfile;
5493
if (!ICCProfiles.contains(profInUse))
5496
StartObj(ObjCounter);
5500
loadText(ScMW->InputProfiles[c->document()->CMSSettings.DefaultImageRGBProfile], &dataP);
5503
if ((Options.CompressMethod != 3) && (CompAvail) && Options.Compress)
5505
PutDoc("/Filter /FlateDecode\n");
5506
dataP = CompressStr(&dataP);
5508
PutDoc("/Length "+QString::number(dataP.length()+1)+"\n");
5509
PutDoc("/N "+QString::number(components)+"\n");
5510
PutDoc(">>\nstream\n"+EncStream(dataP, ObjCounter-1)+"\nendstream\nendobj\n");
5511
StartObj(ObjCounter);
5512
dataD.ResName = ResNam+QString::number(ResCount);
5513
dataD.ICCArray = "[ /ICCBased "+QString::number(ObjCounter-1)+" 0 R ]";
5514
dataD.ResNum = ObjCounter;
5515
dataD.components = components;
5516
ICCProfiles[profInUse] = dataD;
5517
PutDoc("[ /ICCBased "+QString::number(ObjCounter-1)+" 0 R ]\n");
5524
hasGrayProfile = true;
5493
5582
Seite.ImgObjects[ResNam+QString::number(ResCount)] = ObjCounter-1;
5585
bool exportToGrayscale = Options.isGrayscale;
5586
if ((hasGrayProfile) && (doc.HasCMS) && (Options.UseProfiles2) && (!hasColorEffect))
5587
exportToGrayscale = true;
5496
5588
if (Options.UseRGB)
5497
5589
im = img.ImageToTxt();
5566
5658
QString tmpFile = QDir::convertSeparators(QDir::homeDirPath()+"/.scribus/sc.jpg");
5567
5659
if ((Options.UseRGB) || (Options.UseProfiles2) && (!realCMYK))
5568
img.Convert2JPG(tmpFile, Options.Quality, false, false);
5660
img.Convert2JPG(tmpFile, Options.Quality, false, (hasGrayProfile) && (!hasColorEffect));
5571
5663
if (Options.isGrayscale)
5592
5684
QString tmpFile = QDir::convertSeparators(QDir::homeDirPath()+"/.scribus/sc.jpg");
5593
5685
if ((Options.UseRGB) || (Options.UseProfiles2) && (!realCMYK))
5594
img.Convert2JPG(tmpFile, Options.Quality, false, false);
5686
img.Convert2JPG(tmpFile, Options.Quality, false, (hasGrayProfile) && (!hasColorEffect));
5597
5689
if (Options.isGrayscale)
6066
6158
PutDoc("/Encrypt "+QString::number(Encrypt)+" 0 R\n");
6067
6159
PutDoc(">>\nstartxref\n");
6068
6160
PutDoc(QString::number(StX)+"\n%%EOF\n");
6161
return closeAndCleanup();
6072
void PDFlib::closeAndCleanup()
6164
bool PDFlib::closeAndCleanup()
6166
bool writeSucceed = (Spool.status() == IO_Ok);
6168
PDF_Error_WriteFailure();
6170
if (abortExport || !writeSucceed)
6077
6172
if (Spool.exists())
6078
6173
Spool.remove();
6086
6181
Shadings.clear();
6087
6182
Transpar.clear();
6088
6183
ICCProfiles.clear();
6184
return writeSucceed;
6187
void PDFlib::PDF_Error(const QString& errorMsg)
6189
ErrorMessage = errorMsg;
6190
if (!ScQApp->usingGUI())
6191
qDebug(errorMsg.local8Bit().data());
6194
void PDFlib::PDF_Error_WriteFailure(void)
6196
PDF_Error( tr("A write error occured, please check available disk space"));
6092
6199
void PDFlib::cancelRequested()