[poppler] poppler/GlobalParams.cc poppler/GlobalParams.h poppler/PSOutputDev.cc utils/pdftops.1 utils/pdftops.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Tue Feb 8 12:25:29 PST 2011
poppler/GlobalParams.cc | 15 +++++++++++++++
poppler/GlobalParams.h | 3 +++
poppler/PSOutputDev.cc | 7 ++++++-
utils/pdftops.1 | 6 ++++++
utils/pdftops.cc | 6 ++++++
5 files changed, 36 insertions(+), 1 deletion(-)
New commits:
commit 1125cc8ccf386d8e0a0679aa73614bc2cb8037b0
Author: William Bader <williambader at hotmail.com>
Date: Tue Feb 8 20:27:16 2011 +0000
Allow setting the rasterization resolution
More info at bug 34001
diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 02db0da..e624aee 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -692,6 +692,7 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir)
printCommands = gFalse;
profileCommands = gFalse;
errQuiet = gFalse;
+ splashResolution = 0.0;
cidToUnicodeCache = new CharCodeToUnicodeCache(cidToUnicodeCacheSize);
unicodeToUnicodeCache =
@@ -1583,6 +1584,14 @@ GBool GlobalParams::getErrQuiet() {
return errQuiet;
}
+double GlobalParams::getSplashResolution() {
+ double r;
+ lockGlobalParams;
+ r = splashResolution;
+ unlockGlobalParams;
+ return r;
+}
+
CharCodeToUnicode *GlobalParams::getCIDToUnicode(GooString *collection) {
GooString *fileName;
CharCodeToUnicode *ctu;
@@ -1895,6 +1904,12 @@ void GlobalParams::setErrQuiet(GBool errQuietA) {
unlockGlobalParams;
}
+void GlobalParams::setSplashResolution(double SplashResolutionA) {
+ lockGlobalParams;
+ splashResolution = SplashResolutionA;
+ unlockGlobalParams;
+}
+
void GlobalParams::addSecurityHandler(XpdfSecurityHandler *handler) {
#ifdef ENABLE_PLUGINS
lockGlobalParams;
diff --git a/poppler/GlobalParams.h b/poppler/GlobalParams.h
index 97db687..e14360a 100644
--- a/poppler/GlobalParams.h
+++ b/poppler/GlobalParams.h
@@ -220,6 +220,7 @@ public:
GBool getPrintCommands();
GBool getProfileCommands();
GBool getErrQuiet();
+ double getSplashResolution();
CharCodeToUnicode *getCIDToUnicode(GooString *collection);
CharCodeToUnicode *getUnicodeToUnicode(GooString *fontName);
@@ -265,6 +266,7 @@ public:
void setPrintCommands(GBool printCommandsA);
void setProfileCommands(GBool profileCommandsA);
void setErrQuiet(GBool errQuietA);
+ void setSplashResolution(double splashResolutionA);
//----- security handlers
@@ -350,6 +352,7 @@ private:
GBool printCommands; // print the drawing commands
GBool profileCommands; // profile the drawing commands
GBool errQuiet; // suppress error messages?
+ double splashResolution; // resolution when rasterizing images
CharCodeToUnicodeCache *cidToUnicodeCache;
CharCodeToUnicodeCache *unicodeToUnicodeCache;
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc
index 1c49f81..34f09a5 100644
--- a/poppler/PSOutputDev.cc
+++ b/poppler/PSOutputDev.cc
@@ -85,7 +85,7 @@
//------------------------------------------------------------------------
// Resolution at which pages with transparency will be rasterized.
-#define splashDPI 300
+#define defaultSplashDPI 300
//------------------------------------------------------------------------
// PostScript prolog and setup
@@ -2991,6 +2991,7 @@ GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/,
Guchar col[4];
double m0, m1, m2, m3, m4, m5;
int c, w, h, x, y, comp, i;
+ double splashDPI;
char hexBuf[32*2 + 2]; // 32 values X 2 chars/value + line ending + null
Guchar digit;
GBool useBinary;
@@ -3030,6 +3031,10 @@ GBool PSOutputDev::checkPageSlice(Page *page, double /*hDPI*/, double /*vDPI*/,
paperColor, gTrue, gFalse);
}
splashOut->startDoc(xref);
+ splashDPI = globalParams->getSplashResolution();
+ if (splashDPI < 1.0) {
+ splashDPI = defaultSplashDPI;
+ }
page->displaySlice(splashOut, splashDPI, splashDPI, rotateA,
useMediaBox, crop,
sliceX, sliceY, sliceW, sliceH,
diff --git a/utils/pdftops.1 b/utils/pdftops.1
index c57dbb4..5a7543e 100644
--- a/utils/pdftops.1
+++ b/utils/pdftops.1
@@ -102,6 +102,12 @@ in Level 1 PostScript but reduces the file size and can be useful
when Level 1 PostScript is required only for its restricted use
of PostScript operators.
.TP
+.BI \-r " number"
+Set the resolution in DPI when pdftops rasterizes images with
+transparencies or, for Level 1 PostScript, when pdftops
+rasterizes images with color masks.
+By default, pdftops rasterizes images to 300 DPI.
+.TP
.B \-noembt1
By default, any Type 1 fonts which are embedded in the PDF file are
copied into the PostScript file. This option causes pdftops to
diff --git a/utils/pdftops.cc b/utils/pdftops.cc
index 01fa60d..863fb98 100644
--- a/utils/pdftops.cc
+++ b/utils/pdftops.cc
@@ -85,6 +85,7 @@ static GBool doForm = gFalse;
#if OPI_SUPPORT
static GBool doOPI = gFalse;
#endif
+static int splashResolution = 0;
static GBool psBinary = gFalse;
static GBool noEmbedT1Fonts = gFalse;
static GBool noEmbedTTFonts = gFalse;
@@ -133,6 +134,8 @@ static const ArgDesc argDesc[] = {
{"-opi", argFlag, &doOPI, 0,
"generate OPI comments"},
#endif
+ {"-r", argInt, &splashResolution, 0,
+ "resolution for rasterization, in DPI (default is 300)"},
{"-binary", argFlag, &psBinary, 0,
"write binary data in Level 1 PostScript"},
{"-noembt1", argFlag, &noEmbedT1Fonts, 0,
@@ -269,6 +272,9 @@ int main(int argc, char *argv[]) {
if (level1 || level1Sep || level2 || level2Sep || level3 || level3Sep) {
globalParams->setPSLevel(level);
}
+ if (splashResolution > 0) {
+ globalParams->setSplashResolution(splashResolution);
+ }
if (noEmbedT1Fonts) {
globalParams->setPSEmbedType1(!noEmbedT1Fonts);
}
More information about the poppler
mailing list