[poppler] poppler/PSOutputDev.cc poppler/PSOutputDev.h utils/pdftops.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Tue Nov 29 23:00:42 UTC 2016
poppler/PSOutputDev.cc | 38 ++++++++++++++++----------------------
poppler/PSOutputDev.h | 5 +++++
utils/pdftops.cc | 6 +++++-
3 files changed, 26 insertions(+), 23 deletions(-)
New commits:
commit c448e16dc4f2f3c55b06e3f1e098f45f8abacc18
Author: William Bader <william at newspapersystems.com>
Date: Wed Nov 30 00:00:15 2016 +0100
patch to add -passlevel1customcolor
Bug #97193
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 403bf02..195616a 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -1248,6 +1248,7 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA,
embedCIDTrueType = gTrue;
fontPassthrough = gFalse;
optimizeColorSpace = gFalse;
+ passLevel1CustomColor = gFalse;
preloadImagesForms = gFalse;
generateOPI = gFalse;
useASCIIHex = gFalse;
@@ -1650,6 +1651,7 @@ void PSOutputDev::writeXpdfProcset() {
}
} else if ((level == psLevel1 && lev1 && nonSep) ||
(level == psLevel1Sep && lev1 && sep) ||
+ (level == psLevel1Sep && lev2 && sep && getPassLevel1CustomColor()) ||
(level == psLevel2 && lev2 && nonSep) ||
(level == psLevel2Sep && lev2 && sep) ||
(level == psLevel3 && lev3 && nonSep) ||
@@ -4124,15 +4126,6 @@ void PSOutputDev::updateFillColor(GfxState *state) {
state->getFillGray(&gray);
writePSFmt("{0:.4g} g\n", colToDbl(gray));
break;
- case psLevel1Sep:
- state->getFillCMYK(&cmyk);
- c = colToDbl(cmyk.c);
- m = colToDbl(cmyk.m);
- y = colToDbl(cmyk.y);
- k = colToDbl(cmyk.k);
- writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} k\n", c, m, y, k);
- addProcessColor(c, m, y, k);
- break;
case psLevel2:
case psLevel3:
if (state->getFillColorSpace()->getMode() != csPattern) {
@@ -4147,9 +4140,10 @@ void PSOutputDev::updateFillColor(GfxState *state) {
writePS("] sc\n");
}
break;
+ case psLevel1Sep:
case psLevel2Sep:
case psLevel3Sep:
- if (state->getFillColorSpace()->getMode() == csSeparation) {
+ if (state->getFillColorSpace()->getMode() == csSeparation && (level > psLevel1Sep || getPassLevel1CustomColor())) {
sepCS = (GfxSeparationColorSpace *)state->getFillColorSpace();
color.c[0] = gfxColorComp1;
sepCS->getCMYK(&color, &cmyk);
@@ -4190,15 +4184,6 @@ void PSOutputDev::updateStrokeColor(GfxState *state) {
state->getStrokeGray(&gray);
writePSFmt("{0:.4g} G\n", colToDbl(gray));
break;
- case psLevel1Sep:
- state->getStrokeCMYK(&cmyk);
- c = colToDbl(cmyk.c);
- m = colToDbl(cmyk.m);
- y = colToDbl(cmyk.y);
- k = colToDbl(cmyk.k);
- writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} K\n", c, m, y, k);
- addProcessColor(c, m, y, k);
- break;
case psLevel2:
case psLevel3:
if (state->getStrokeColorSpace()->getMode() != csPattern) {
@@ -4213,9 +4198,10 @@ void PSOutputDev::updateStrokeColor(GfxState *state) {
writePS("] SC\n");
}
break;
+ case psLevel1Sep:
case psLevel2Sep:
case psLevel3Sep:
- if (state->getStrokeColorSpace()->getMode() == csSeparation) {
+ if (state->getStrokeColorSpace()->getMode() == csSeparation && (level > psLevel1Sep || getPassLevel1CustomColor())) {
sepCS = (GfxSeparationColorSpace *)state->getStrokeColorSpace();
color.c[0] = gfxColorComp1;
sepCS->getCMYK(&color, &cmyk);
@@ -5889,7 +5875,11 @@ void PSOutputDev::doImageL2(Object *ref, GfxImageColorMap *colorMap,
// color space
if (colorMap) {
- dumpColorSpaceL2(colorMap->getColorSpace(), gFalse, gTrue, gFalse);
+ // Do not update the process color list for custom colors
+ GBool isCustomColor =
+ (level == psLevel1Sep || level == psLevel2Sep || level == psLevel3Sep) &&
+ colorMap->getColorSpace()->getMode() == csDeviceN;
+ dumpColorSpaceL2(colorMap->getColorSpace(), gFalse, !isCustomColor, gFalse);
writePS(" setcolorspace\n");
}
@@ -6288,7 +6278,11 @@ void PSOutputDev::doImageL3(Object *ref, GfxImageColorMap *colorMap,
// color space
if (colorMap) {
- dumpColorSpaceL2(colorMap->getColorSpace(), gFalse, gTrue, gFalse);
+ // Do not update the process color list for custom colors
+ GBool isCustomColor =
+ (level == psLevel1Sep || level == psLevel2Sep || level == psLevel3Sep) &&
+ colorMap->getColorSpace()->getMode() == csDeviceN;
+ dumpColorSpaceL2(colorMap->getColorSpace(), gFalse, !isCustomColor, gFalse);
writePS(" setcolorspace\n");
}
diff --git a/poppler/PSOutputDev.h b/poppler/PSOutputDev.h
index 3aea223..c27c90f 100644
--- a/poppler/PSOutputDev.h
+++ b/poppler/PSOutputDev.h
@@ -320,6 +320,7 @@ public:
GBool getEmbedCIDTrueType() const { return embedCIDTrueType; }
GBool getFontPassthrough() const { return fontPassthrough; }
GBool getOptimizeColorSpace() const { return optimizeColorSpace; }
+ GBool getPassLevel1CustomColor() const { return passLevel1CustomColor; }
GBool getEnableLZW() const { return enableLZW; };
GBool getEnableFlate() const
#if ENABLE_ZLIB
@@ -333,6 +334,7 @@ public:
void setEmbedCIDTrueType(GBool b) { embedCIDTrueType = b; }
void setFontPassthrough(GBool b) { fontPassthrough = b; }
void setOptimizeColorSpace(GBool b) { optimizeColorSpace = b; }
+ void setPassLevel1CustomColor(GBool b) { passLevel1CustomColor = b; }
void setPreloadImagesForms(GBool b) { preloadImagesForms = b; }
void setGenerateOPI(GBool b) { generateOPI = b; }
void setUseASCIIHex(GBool b) { useASCIIHex = b; }
@@ -536,6 +538,9 @@ private:
GBool fontPassthrough; // pass all fonts through as-is?
GBool optimizeColorSpace; // false to keep gray RGB images in their original color space
// true to optimize gray images to DeviceGray color space
+ GBool passLevel1CustomColor; // false to convert all custom colors to CMYK
+ // true to pass custom colors
+ // has effect only when doing a level1sep
GBool preloadImagesForms; // preload PostScript images and forms into
// memory
GBool generateOPI; // generate PostScript OPI comments?
diff --git a/utils/pdftops.cc b/utils/pdftops.cc
index dfeaa14..2eeba19 100644
--- a/utils/pdftops.cc
+++ b/utils/pdftops.cc
@@ -19,7 +19,7 @@
// Copyright (C) 2007-2008, 2010, 2015 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2009 Till Kamppeter <till.kamppeter at gmail.com>
// Copyright (C) 2009 Sanjoy Mahajan <sanjoy at mit.edu>
-// Copyright (C) 2009, 2011, 2012, 2014, 2015 William Bader <williambader at hotmail.com>
+// Copyright (C) 2009, 2011, 2012, 2014-2016 William Bader <williambader at hotmail.com>
// Copyright (C) 2010 Hib Eris <hib at hiberis.nl>
// Copyright (C) 2012 Thomas Freitag <Thomas.Freitag at alfa.de>
// Copyright (C) 2013 Suzuki Toshiya <mpsuzuki at hiroshima-u.ac.jp>
@@ -96,6 +96,7 @@ static GBool noEmbedCIDPSFonts = gFalse;
static GBool noEmbedCIDTTFonts = gFalse;
static GBool fontPassthrough = gFalse;
static GBool optimizeColorSpace = gFalse;
+static GBool passLevel1CustomColor = gFalse;
static char rasterAntialiasStr[16] = "";
static GBool preload = gFalse;
static char paperSize[15] = "";
@@ -160,6 +161,8 @@ static const ArgDesc argDesc[] = {
"enable anti-aliasing on rasterization: yes, no"},
{"-optimizecolorspace", argFlag, &optimizeColorSpace,0,
"convert gray RGB images to gray color space"},
+ {"-passlevel1customcolor", argFlag, &passLevel1CustomColor, 0,
+ "pass custom color in level1sep"},
{"-preload", argFlag, &preload, 0,
"preload images and forms"},
{"-paper", argString, paperSize, sizeof(paperSize),
@@ -407,6 +410,7 @@ int main(int argc, char *argv[]) {
psOut->setFontPassthrough(fontPassthrough);
psOut->setPreloadImagesForms(preload);
psOut->setOptimizeColorSpace(optimizeColorSpace);
+ psOut->setPassLevel1CustomColor(passLevel1CustomColor);
#if OPI_SUPPORT
psOut->setGenerateOPI(doOPI);
#endif
More information about the poppler
mailing list