diff --git a/README.md b/README.md
index 716d962..838775e 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,6 @@
# xpdf
+Xpdf is an open source viewer for Portable Document Format (PDF) files.
+(These are also sometimes also called 'Acrobat' files, from the name of Adobe's PDF software.)
+The Xpdf project also includes a PDF text extractor, PDF-to-PostScript converter, and various other utilities.
+
diff --git a/xpdf-2.03-fonts.patch b/xpdf-2.03-fonts.patch
new file mode 100644
index 0000000..91b5199
--- /dev/null
+++ b/xpdf-2.03-fonts.patch
@@ -0,0 +1,11 @@
+--- xpdf-2.03/xpdf/XPDFViewer.cc 2003-10-11 22:39:12.000000000 +0200
++++ xpdf-2.03/xpdf/XPDFViewer.cc.fixed 2004-10-29 16:58:16.000000000 +0200
+@@ -1743,7 +1743,7 @@ void XPDFViewer::initAboutDialog() {
+ aboutBigFont =
+ createFontList("-*-times-bold-i-normal--20-*-*-*-*-*-iso8859-1");
+ aboutVersionFont =
+- createFontList("-*-times-medium-r-normal--16-*-*-*-*-*-iso8859-1");
++ createFontList("-*-times-medium-r-normal--17-*-*-*-*-*-iso8859-1");
+ aboutFixedFont =
+ createFontList("-*-courier-medium-r-normal--12-*-*-*-*-*-iso8859-1");
+
diff --git a/xpdf-3.00-can_2005_0206.patch b/xpdf-3.00-can_2005_0206.patch
new file mode 100644
index 0000000..c44d0ba
--- /dev/null
+++ b/xpdf-3.00-can_2005_0206.patch
@@ -0,0 +1,55 @@
+--- xpdf-3.00/goo/gmem.h.can-2005-0206 2004-01-21 18:26:44.000000000 -0700
++++ xpdf-3.00/goo/gmem.h 2005-02-15 06:55:02.201587908 -0700
+@@ -19,13 +19,13 @@
+ * Same as malloc, but prints error message and exits if malloc()
+ * returns NULL.
+ */
+-extern void *gmalloc(int size);
++extern void *gmalloc(size_t size);
+
+ /*
+ * Same as realloc, but prints error message and exits if realloc()
+ * returns NULL. If
is NULL, calls malloc instead of realloc().
+ */
+-extern void *grealloc(void *p, int size);
++extern void *grealloc(void *p, size_t size);
+
+ /*
+ * Same as free, but checks for and ignores NULL pointers.
+--- xpdf-3.00/goo/gmem.c.can-2005-0206 2004-01-21 18:26:44.000000000 -0700
++++ xpdf-3.00/goo/gmem.c 2005-02-15 06:55:02.202587704 -0700
+@@ -53,9 +53,9 @@
+
+ #endif /* DEBUG_MEM */
+
+-void *gmalloc(int size) {
++void *gmalloc(size_t size) {
+ #ifdef DEBUG_MEM
+- int size1;
++ size_t size1;
+ char *mem;
+ GMemHdr *hdr;
+ void *data;
+@@ -94,11 +94,11 @@
+ #endif
+ }
+
+-void *grealloc(void *p, int size) {
++void *grealloc(void *p, size_t size) {
+ #ifdef DEBUG_MEM
+ GMemHdr *hdr;
+ void *q;
+- int oldSize;
++ size_t oldSize;
+
+ if (size == 0) {
+ if (p)
+@@ -137,7 +137,7 @@
+
+ void gfree(void *p) {
+ #ifdef DEBUG_MEM
+- int size;
++ size_t size;
+ GMemHdr *hdr;
+ GMemHdr *prevHdr, *q;
+ int lst;
diff --git a/xpdf-3.00-gcc4.patch b/xpdf-3.00-gcc4.patch
new file mode 100644
index 0000000..494b127
--- /dev/null
+++ b/xpdf-3.00-gcc4.patch
@@ -0,0 +1,29 @@
+--- xpdf-3.00/xpdf/TextOutputDev.h.orig 2005-06-13 10:11:17.000000000 +0200
++++ xpdf-3.00/xpdf/TextOutputDev.h 2005-06-13 10:27:18.000000000 +0200
+@@ -169,7 +169,7 @@
+ class TextLine {
+ public:
+
+- TextLine(TextBlock *blkA, int rotA, double baseA);
++ TextLine(class TextBlock *blkA, int rotA, double baseA);
+ ~TextLine();
+
+ void addWord(TextWord *word);
+@@ -226,7 +226,7 @@
+ class TextBlock {
+ public:
+
+- TextBlock(TextPage *pageA, int rotA);
++ TextBlock(class TextPage *pageA, int rotA);
+ ~TextBlock();
+
+ void addWord(TextWord *word);
+@@ -416,7 +416,7 @@
+ private:
+
+ void clear();
+- void assignColumns(TextLineFrag *frags, int nFrags, int rot);
++ void assignColumns(class TextLineFrag *frags, int nFrags, int rot);
+ int dumpFragment(Unicode *text, int len, UnicodeMap *uMap, GString *s);
+
+ GBool rawOrder; // keep text in content stream order
diff --git a/xpdf-3.01-can_2005_2097.patch b/xpdf-3.01-can_2005_2097.patch
new file mode 100644
index 0000000..f61c7f4
--- /dev/null
+++ b/xpdf-3.01-can_2005_2097.patch
@@ -0,0 +1,30 @@
+--- xpdf-3.01/fofi/FoFiTrueType.cc 2005-08-17 07:34:30.000000000 +0200
++++ xpdf-3.01-fix/fofi/FoFiTrueType.cc 2005-08-22 12:13:04.000000000 +0200
+@@ -1652,6 +1652,27 @@
+ return;
+ }
+
++ // make sure the loca table is sane (correct length and entries are
++ // in bounds)
++ i = seekTable("loca");
++ if (tables[i].len < (nGlyphs + 1) * (locaFmt ? 4 : 2)) {
++ parsedOk = gFalse;
++ return;
++ }
++ for (j = 0; j <= nGlyphs; ++j) {
++ if (locaFmt) {
++ pos = (int)getU32BE(tables[i].offset + j*4, &parsedOk);
++ } else {
++ pos = getU16BE(tables[i].offset + j*2, &parsedOk);
++ }
++ if (pos < 0 || pos > len) {
++ parsedOk = gFalse;
++ }
++ }
++ if (!parsedOk) {
++ return;
++ }
++
+ // read the post table
+ readPostTable();
+ }
diff --git a/xpdf-3.01-can_2005_3191_2_3.patch b/xpdf-3.01-can_2005_3191_2_3.patch
new file mode 100644
index 0000000..84a777c
--- /dev/null
+++ b/xpdf-3.01-can_2005_3191_2_3.patch
@@ -0,0 +1,154 @@
+--- xpdf-3.01/xpdf/Stream.h.cve-2005-3191_2_3 2005-08-16 23:34:31.000000000 -0600
++++ xpdf-3.01/xpdf/Stream.h 2006-01-03 16:06:22.323135129 -0700
+@@ -232,6 +232,8 @@
+
+ ~StreamPredictor();
+
++ GBool isOk() { return ok; }
++
+ int lookChar();
+ int getChar();
+
+@@ -249,6 +251,7 @@
+ int rowBytes; // bytes per line
+ Guchar *predLine; // line buffer
+ int predIdx; // current index in predLine
++ GBool ok;
+ };
+
+ //------------------------------------------------------------------------
+--- xpdf-3.01/xpdf/Stream.cc.cve-2005-3191_2_3 2005-08-16 23:34:31.000000000 -0600
++++ xpdf-3.01/xpdf/Stream.cc 2006-01-03 16:06:22.324134948 -0700
+@@ -15,6 +15,7 @@
+ #include
+ #include
+ #include
++#include
+ #ifndef WIN32
+ #include
+ #endif
+@@ -406,13 +407,28 @@
+ width = widthA;
+ nComps = nCompsA;
+ nBits = nBitsA;
++ predLine = NULL;
++ ok = gFalse;
+
++ if (width <= 0 || nComps <= 0 || nBits <= 0 ||
++ nComps >= INT_MAX/nBits ||
++ width >= INT_MAX/nComps/nBits) {
++ return;
++ }
+ nVals = width * nComps;
++ if (nVals * nBits + 7 <= 0) {
++ return;
++ }
+ pixBytes = (nComps * nBits + 7) >> 3;
+ rowBytes = ((nVals * nBits + 7) >> 3) + pixBytes;
++ if (rowBytes < 0) {
++ return;
++ }
+ predLine = (Guchar *)gmalloc(rowBytes);
+ memset(predLine, 0, rowBytes);
+ predIdx = rowBytes;
++
++ ok = gTrue;
+ }
+
+ StreamPredictor::~StreamPredictor() {
+@@ -1004,6 +1020,10 @@
+ FilterStream(strA) {
+ if (predictor != 1) {
+ pred = new StreamPredictor(this, predictor, columns, colors, bits);
++ if (!pred->isOk()) {
++ delete pred;
++ pred = NULL;
++ }
+ } else {
+ pred = NULL;
+ }
+@@ -2899,6 +2919,10 @@
+ height = read16();
+ width = read16();
+ numComps = str->getChar();
++ if (numComps <= 0 || numComps > 4) {
++ error(getPos(), "Bad number of components in DCT stream", prec);
++ return gFalse;
++ }
+ if (prec != 8) {
+ error(getPos(), "Bad DCT precision %d", prec);
+ return gFalse;
+@@ -2925,6 +2949,10 @@
+ height = read16();
+ width = read16();
+ numComps = str->getChar();
++ if (numComps <= 0 || numComps > 4) {
++ error(getPos(), "Bad number of components in DCT stream", prec);
++ return gFalse;
++ }
+ if (prec != 8) {
+ error(getPos(), "Bad DCT precision %d", prec);
+ return gFalse;
+@@ -2947,6 +2975,10 @@
+
+ length = read16() - 2;
+ scanInfo.numComps = str->getChar();
++ if (scanInfo.numComps <= 0 || scanInfo.numComps > 4) {
++ error(getPos(), "Bad number of components in DCT stream");
++ return gFalse;
++ }
+ --length;
+ if (length != 2 * scanInfo.numComps + 3) {
+ error(getPos(), "Bad DCT scan info block");
+@@ -3827,6 +3859,10 @@
+ FilterStream(strA) {
+ if (predictor != 1) {
+ pred = new StreamPredictor(this, predictor, columns, colors, bits);
++ if (!pred->isOk()) {
++ delete pred;
++ pred = NULL;
++ }
+ } else {
+ pred = NULL;
+ }
+--- xpdf-3.01/xpdf/JPXStream.cc.cve-2005-3191_2_3 2005-08-16 23:34:31.000000000 -0600
++++ xpdf-3.01/xpdf/JPXStream.cc 2006-01-03 16:10:55.857459404 -0700
+@@ -7,6 +7,7 @@
+ //========================================================================
+
+ #include
++#include
+
+ #ifdef USE_GCC_PRAGMAS
+ #pragma implementation
+@@ -783,7 +784,7 @@
+ int segType;
+ GBool haveSIZ, haveCOD, haveQCD, haveSOT;
+ Guint precinctSize, style;
+- Guint segLen, capabilities, comp, i, j, r;
++ Guint segLen, capabilities, nTiles, comp, i, j, r;
+
+ //----- main header
+ haveSIZ = haveCOD = haveQCD = haveSOT = gFalse;
+@@ -818,8 +819,19 @@
+ / img.xTileSize;
+ img.nYTiles = (img.ySize - img.yTileOffset + img.yTileSize - 1)
+ / img.yTileSize;
+- img.tiles = (JPXTile *)gmallocn(img.nXTiles * img.nYTiles,
+- sizeof(JPXTile));
++ // check for overflow before allocating memory
++ if (img.nXTiles <= 0 || img.nYTiles <= 0 ||
++ img.nXTiles >= INT_MAX/img.nYTiles) {
++ error(getPos(), "Bad tile count in JPX SIZ marker segment");
++ return gFalse;
++ }
++ nTiles = img.nXTiles * img.nYTiles;
++ if (nTiles >= INT_MAX/sizeof(JPXTile)) {
++ error(getPos(), "Bad tile count in JPX SIZ marker segment");
++ return gFalse;
++ }
++ img.tiles = (JPXTile *)gmalloc(nTiles * sizeof(JPXTile));
++
+ for (i = 0; i < img.nXTiles * img.nYTiles; ++i) {
+ img.tiles[i].tileComps = (JPXTileComp *)gmallocn(img.nComps,
+ sizeof(JPXTileComp));
diff --git a/xpdf-3.01-can_2005_3624_5_6_7.patch b/xpdf-3.01-can_2005_3624_5_6_7.patch
new file mode 100644
index 0000000..782bb67
--- /dev/null
+++ b/xpdf-3.01-can_2005_3624_5_6_7.patch
@@ -0,0 +1,139 @@
+--- xpdf-3.01/xpdf/JBIG2Stream.cc.chris-overflows 2005-08-16 23:34:31.000000000 -0600
++++ xpdf-3.01/xpdf/JBIG2Stream.cc 2006-01-03 16:31:21.707918696 -0700
+@@ -7,6 +7,7 @@
+ //========================================================================
+
+ #include
++#include
+
+ #ifdef USE_GCC_PRAGMAS
+ #pragma implementation
+@@ -681,6 +682,13 @@
+ w = wA;
+ h = hA;
+ line = (wA + 7) >> 3;
++
++ if (h < 0 || line <= 0 || h >= (INT_MAX - 1) / line) {
++ error(-1, "invalid width/height");
++ data = NULL;
++ return;
++ }
++
+ // need to allocate one extra guard byte for use in combine()
+ data = (Guchar *)gmalloc(h * line + 1);
+ data[h * line] = 0;
+@@ -692,6 +700,13 @@
+ w = bitmap->w;
+ h = bitmap->h;
+ line = bitmap->line;
++
++ if (h < 0 || line <= 0 || h >= (INT_MAX - 1) / line) {
++ error(-1, "invalid width/height");
++ data = NULL;
++ return;
++ }
++
+ // need to allocate one extra guard byte for use in combine()
+ data = (Guchar *)gmalloc(h * line + 1);
+ memcpy(data, bitmap->data, h * line);
+@@ -720,7 +735,10 @@
+ }
+
+ void JBIG2Bitmap::expand(int newH, Guint pixel) {
+- if (newH <= h) {
++ if (newH <= h || line <= 0 || newH >= (INT_MAX - 1) / line) {
++ error(-1, "invalid width/height");
++ gfree(data);
++ data = NULL;
+ return;
+ }
+ // need to allocate one extra guard byte for use in combine()
+@@ -2305,6 +2323,15 @@
+ error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment");
+ return;
+ }
++ if (gridH == 0 || gridW >= INT_MAX / gridH) {
++ error(getPos(), "Bad size in JBIG2 halftone segment");
++ return;
++ }
++ if (w == 0 || h >= INT_MAX / w) {
++ error(getPos(), "Bad size in JBIG2 bitmap segment");
++ return;
++ }
++
+ patternDict = (JBIG2PatternDict *)seg;
+ bpp = 0;
+ i = 1;
+@@ -2936,6 +2963,11 @@
+ JBIG2BitmapPtr tpgrCXPtr0, tpgrCXPtr1, tpgrCXPtr2;
+ int x, y, pix;
+
++ if (w < 0 || h <= 0 || w >= INT_MAX / h) {
++ error(-1, "invalid width/height");
++ return NULL;
++ }
++
+ bitmap = new JBIG2Bitmap(0, w, h);
+ bitmap->clearToZero();
+
+--- xpdf-3.01/xpdf/Stream.cc.chris-overflows 2006-01-03 16:16:25.239630341 -0700
++++ xpdf-3.01/xpdf/Stream.cc 2006-01-03 16:44:17.794143711 -0700
+@@ -1276,8 +1276,9 @@
+ endOfLine = endOfLineA;
+ byteAlign = byteAlignA;
+ columns = columnsA;
+- if (columns < 1) {
+- columns = 1;
++ if (columns < 1 || columns >= INT_MAX / sizeof(short)) {
++ error(getPos(), "Bad number of columns: %d in CCITTFaxStream", columns);
++ exit(1);
+ }
+ rows = rowsA;
+ endOfBlock = endOfBlockA;
+@@ -2920,6 +2921,7 @@
+ width = read16();
+ numComps = str->getChar();
+ if (numComps <= 0 || numComps > 4) {
++ numComps = 0;
+ error(getPos(), "Bad number of components in DCT stream", prec);
+ return gFalse;
+ }
+@@ -2950,6 +2952,7 @@
+ width = read16();
+ numComps = str->getChar();
+ if (numComps <= 0 || numComps > 4) {
++ numComps = 0;
+ error(getPos(), "Bad number of components in DCT stream", prec);
+ return gFalse;
+ }
+@@ -2976,6 +2979,7 @@
+ length = read16() - 2;
+ scanInfo.numComps = str->getChar();
+ if (scanInfo.numComps <= 0 || scanInfo.numComps > 4) {
++ scanInfo.numComps = 0;
+ error(getPos(), "Bad number of components in DCT stream");
+ return gFalse;
+ }
+@@ -3063,12 +3067,12 @@
+ while (length > 0) {
+ index = str->getChar();
+ --length;
+- if ((index & 0x0f) >= 4) {
++ if ((index & ~0x10) >= 4 || (index & ~0x10) < 0) {
+ error(getPos(), "Bad DCT Huffman table");
+ return gFalse;
+ }
+ if (index & 0x10) {
+- index &= 0x0f;
++ index &= 0x03;
+ if (index >= numACHuffTables)
+ numACHuffTables = index+1;
+ tbl = &acHuffTables[index];
+@@ -3189,6 +3193,7 @@
+ } while (c != 0xff && c != EOF);
+ do {
+ c = str->getChar();
++ if(c == EOF) return EOF;
+ } while (c == 0xff);
+ } while (c == 0x00);
+ return c;
diff --git a/xpdf-3.01-crash.patch b/xpdf-3.01-crash.patch
new file mode 100644
index 0000000..21e60b3
--- /dev/null
+++ b/xpdf-3.01-crash.patch
@@ -0,0 +1,34 @@
+--- xpdf-3.00/splash/Splash.cc.tn 2005-07-25 09:59:45.000000000 +0200
++++ xpdf-3.00/splash/Splash.cc 2005-07-25 10:00:58.000000000 +0200
+@@ -636,6 +641,11 @@
+
+ xPath = new SplashXPath(path, state->flatness, gTrue);
+ xPath->sort();
++ if (!&xPath->segs[0])
++ {
++ delete xPath;
++ return splashErrEmptyPath;
++ }
+ scanner = new SplashXPathScanner(xPath, eo);
+
+ // get the min and max x and y values
+--- xpdf-3.00/fofi/FoFiType1.cc.tn 2005-07-25 10:34:04.000000000 +0200
++++ xpdf-3.00/fofi/FoFiType1.cc 2005-07-25 10:41:37.000000000 +0200
+@@ -187,9 +187,14 @@
+ }
+ }
+ } else {
+- if (strtok(buf, " \t") &&
+- (p = strtok(NULL, " \t\n\r")) && !strcmp(p, "def")) {
+- break;
++ p = strtok(buf, " \t\n\r");
++ if (p)
++ {
++ if (!strcmp(p, "def")) break;
++ if (!strcmp(p, "readonly")) break;
++ // the spec does not says this but i'm mantaining old xpdf behaviour that accepts "foo def" as end of the encoding array
++ p = strtok(buf, " \t\n\r");
++ if (p && !strcmp(p, "def")) break;
+ }
+ }
+ line = line1;
diff --git a/xpdf-3.01-cve_2006_0301.patch b/xpdf-3.01-cve_2006_0301.patch
new file mode 100644
index 0000000..9cc47d9
--- /dev/null
+++ b/xpdf-3.01-cve_2006_0301.patch
@@ -0,0 +1,39 @@
+Index: xpdf/splash/Splash.cc
+===================================================================
+--- xpdf/splash/Splash.cc (revision 498958)
++++ xpdf/splash/Splash.cc (working copy)
+@@ -928,6 +928,10 @@ void Splash::drawPixel(int x, int y, Spl
+ int alpha2, ialpha2;
+ Guchar t;
+
++ if ( (unsigned) x >= (unsigned) bitmap->getWidth() ||
++ (unsigned) y >= (unsigned) bitmap->getHeight())
++ return;
++
+ if (noClip || state->clip->test(x, y)) {
+ if (alpha != 1 || softMask || state->blendFunc) {
+ blendFunc = state->blendFunc ? state->blendFunc : &blendNormal;
+@@ -1195,6 +1199,11 @@ void Splash::drawSpan(int x0, int x1, in
+ updateModY(y);
+ }
+
++ if ((unsigned) x0 >= (unsigned) bitmap->getWidth() ||
++ (unsigned) x1 >= (unsigned) bitmap->getWidth() ||
++ (unsigned) y >= (unsigned) bitmap->getHeight())
++ return;
++
+ if (alpha != 1 || softMask || state->blendFunc) {
+ blendFunc = state->blendFunc ? state->blendFunc : &blendNormal;
+ if (softMask) {
+@@ -1825,6 +1834,11 @@ void Splash::xorSpan(int x0, int x1, int
+ updateModY(y);
+ }
+
++ if ((unsigned) x0 >= (unsigned) bitmap->getWidth() ||
++ (unsigned) x1 >= (unsigned) bitmap->getWidth() ||
++ (unsigned) y >= (unsigned) bitmap->getHeight())
++ return;
++
+ switch (bitmap->mode) {
+ case splashModeMono1:
+ p = &bitmap->data[y * bitmap->rowSize + (x0 >> 3)];
diff --git a/xpdf-3.03-libXpm-3.5.10.patch b/xpdf-3.03-libXpm-3.5.10.patch
new file mode 100644
index 0000000..621d107
--- /dev/null
+++ b/xpdf-3.03-libXpm-3.5.10.patch
@@ -0,0 +1,11 @@
+--- xpdf-3.03.orig/xpdf/XPDFViewer.cc 2012-04-11 14:04:36.669903728 +0200
++++ xpdf-3.03/xpdf/XPDFViewer.cc 2012-04-12 13:40:52.001063309 +0200
+@@ -134,7 +134,7 @@
+ //------------------------------------------------------------------------
+
+ struct ZoomMenuInfo {
+- const char *label;
++ char *label;
+ double zoom;
+ };
+
diff --git a/xpdf-3.03-xpdfrc.patch b/xpdf-3.03-xpdfrc.patch
new file mode 100644
index 0000000..6c75e2c
--- /dev/null
+++ b/xpdf-3.03-xpdfrc.patch
@@ -0,0 +1,75 @@
+diff -Nru xpdf-3.03.orig/doc/sample-xpdfrc xpdf-3.03/doc/sample-xpdfrc
+--- xpdf-3.03.orig/doc/sample-xpdfrc 2011-08-15 23:08:53.000000000 +0200
++++ xpdf-3.03/doc/sample-xpdfrc 2012-04-11 14:09:20.520224883 +0200
+@@ -29,20 +29,20 @@
+ # installed in a "standard" location, xpdf will find them
+ # automatically.)
+
+-#fontFile Times-Roman /usr/local/share/ghostscript/fonts/n021003l.pfb
+-#fontFile Times-Italic /usr/local/share/ghostscript/fonts/n021023l.pfb
+-#fontFile Times-Bold /usr/local/share/ghostscript/fonts/n021004l.pfb
+-#fontFile Times-BoldItalic /usr/local/share/ghostscript/fonts/n021024l.pfb
+-#fontFile Helvetica /usr/local/share/ghostscript/fonts/n019003l.pfb
+-#fontFile Helvetica-Oblique /usr/local/share/ghostscript/fonts/n019023l.pfb
+-#fontFile Helvetica-Bold /usr/local/share/ghostscript/fonts/n019004l.pfb
+-#fontFile Helvetica-BoldOblique /usr/local/share/ghostscript/fonts/n019024l.pfb
+-#fontFile Courier /usr/local/share/ghostscript/fonts/n022003l.pfb
+-#fontFile Courier-Oblique /usr/local/share/ghostscript/fonts/n022023l.pfb
+-#fontFile Courier-Bold /usr/local/share/ghostscript/fonts/n022004l.pfb
+-#fontFile Courier-BoldOblique /usr/local/share/ghostscript/fonts/n022024l.pfb
+-#fontFile Symbol /usr/local/share/ghostscript/fonts/s050000l.pfb
+-#fontFile ZapfDingbats /usr/local/share/ghostscript/fonts/d050000l.pfb
++fontFile Times-Roman /usr/share/ghostscript/fonts/n021003l.pfb
++fontFile Times-Italic /usr/share/ghostscript/fonts/n021023l.pfb
++fontFile Times-Bold /usr/share/ghostscript/fonts/n021004l.pfb
++fontFile Times-BoldItalic /usr/share/ghostscript/fonts/n021024l.pfb
++fontFile Helvetica /usr/share/ghostscript/fonts/n019003l.pfb
++fontFile Helvetica-Oblique /usr/share/ghostscript/fonts/n019023l.pfb
++fontFile Helvetica-Bold /usr/share/ghostscript/fonts/n019004l.pfb
++fontFile Helvetica-BoldOblique /usr/share/ghostscript/fonts/n019024l.pfb
++fontFile Courier /usr/share/ghostscript/fonts/n022003l.pfb
++fontFile Courier-Oblique /usr/share/ghostscript/fonts/n022023l.pfb
++fontFile Courier-Bold /usr/share/ghostscript/fonts/n022004l.pfb
++fontFile Courier-BoldOblique /usr/share/ghostscript/fonts/n022024l.pfb
++fontFile Symbol /usr/share/ghostscript/fonts/s050000l.pfb
++fontFile ZapfDingbats /usr/share/ghostscript/fonts/d050000l.pfb
+
+ # If you need to display PDF files that refer to non-embedded fonts,
+ # you should add one or more fontDir options to point to the
+@@ -50,7 +50,9 @@
+ # .pfb, .ttf, and .ttc files in those directories (other files will
+ # simply be ignored).
+
+-#fontDir /usr/local/fonts/bakoma
++fontDir /usr/share/ghostscript/fonts
++fontDir /usr/share/fonts/X11/TTF
++fontDir /usr/share/fonts/X11/Type1
+
+ #----- PostScript output control
+
+@@ -62,7 +64,7 @@
+ # A4, or A3. You can also specify a paper size as width and height
+ # (in points).
+
+-#psPaperSize letter
++psPaperSize A4
+
+ #----- text output control
+
+@@ -81,12 +83,12 @@
+
+ # Enable t1lib, FreeType, and anti-aliased text.
+
+-#enableT1lib yes
+-#enableFreeType yes
+-#antialias yes
++enableT1lib yes
++enableFreeType yes
++antialias yes
+
+ # Set the command used to run a web browser when a URL hyperlink is
+ # clicked.
+
+ #launchCommand viewer-script
+-#urlCommand "netscape -remote 'openURL(%s)'"
++urlCommand "xdg-open 'openURL(%s)'"
diff --git a/xpdf-xpdf_desktop b/xpdf-xpdf_desktop
new file mode 100644
index 0000000..eecedd2
--- /dev/null
+++ b/xpdf-xpdf_desktop
@@ -0,0 +1,85 @@
+[Desktop Entry]
+Encoding=UTF-8
+BinaryPattern=
+Name=X PDF
+Name[af]=X Pdf
+Name[de]=X-PDF
+Name[eo]=XPDF
+Name[es]=PDF para X
+Name[fr]=XPDF
+Name[hi]=एक्स पीडीएफ
+Name[ko]=X용 PDF
+Name[mn]=X-PDF
+Name[xx]=xxX PDFxx
+MimeType=application/pdf
+GenericName=PDF Viewer
+GenericName[af]=Pdf Aansig
+GenericName[ar]=عارض ملفات PDF
+GenericName[az]=PDF Nümayişçisi
+GenericName[bg]=Преглед на документи PDF
+GenericName[br]=Gweler PDF
+GenericName[ca]=Visor PDF
+GenericName[cs]=Prohlížeč PDF souborů
+GenericName[cy]=Gwelydd PDF
+GenericName[da]=PDF-fremviser
+GenericName[de]=PDF-Betrachter
+GenericName[el]=Προβολέας PDF
+GenericName[eo]=PDF-rigardilo
+GenericName[es]=Visor de documentos PDF
+GenericName[et]=PDF failide vaatamine
+GenericName[eu]=PDF Ikustailua
+GenericName[fa]=نمایشگر PDF
+GenericName[fi]=PDF-Näyttäjä
+GenericName[fo]=PDF-vísari
+GenericName[fr]=Afficheur PDF
+GenericName[gl]=Visualizador de PDF
+GenericName[he]=מציג קבצי PDF
+GenericName[hi]=पीडीएफ प्रदर्शक
+GenericName[hr]=Preglednik PDF dokumenata
+GenericName[hu]=PDF-nézegető
+GenericName[id]=Viewer PDF
+GenericName[is]=PDF-sjá
+GenericName[it]=Visualizzatore PDF
+GenericName[ja]=PDFビューア
+GenericName[ko]=PDF 보기
+GenericName[lo]=ສະແດງຜົນPDF
+GenericName[lt]=PDF Žiūriklis
+GenericName[lv]=PDF Skatītājs
+GenericName[mn]=PDF-Харагч
+GenericName[mt]=Werrej PDF
+GenericName[nb]=PDF-fremviser
+GenericName[nl]=PDF-weergaveprogramma
+GenericName[nn]=PDF-lesar
+GenericName[nso]=Molebeledi wa PDF
+GenericName[oc]=Visualisor PDF
+GenericName[pl]=Przeglądarka plików PDF
+GenericName[pt]=Visualizador de PDFs
+GenericName[pt_BR]=Visualizador de arquivos PDF
+GenericName[ro]=Vizualizor de documente PDF
+GenericName[ru]=Программа просмотра документов PDF
+GenericName[se]=PDF-logan
+GenericName[sk]=Prehliadač PDF súborov
+GenericName[sl]=Pregledovalnik datotek PDF
+GenericName[sr]=PDF приказивач
+GenericName[ss]=Sibuki se PDF
+GenericName[sv]=PDF-visare
+GenericName[ta]=PDF காட்சி
+GenericName[th]=ตัวแสดงผล PDF
+GenericName[tr]=PDF Görüntüleyici
+GenericName[uk]=Переглядач PDF
+GenericName[uz]=PDF кўрувчи
+GenericName[ven]=Tshivhoni tsha PDF
+GenericName[vi]=Trình xem PDF
+GenericName[wa]=Håyneu di documints PDF
+GenericName[xx]=xxPDF Viewerxx
+GenericName[zh_CN]=PDF 查看器
+GenericName[zh_TW]=PDF 檢視程式
+GenericName[zu]=Umbukisi we-PDF
+Exec=xpdf
+Icon=kpdf
+Categories=Application;Office;Viewer;
+TerminalOptions=
+Path=
+Type=Application
+Terminal=false
+X-KDE-StartupNotify=false
diff --git a/xpdf.spec b/xpdf.spec
new file mode 100644
index 0000000..1379c06
--- /dev/null
+++ b/xpdf.spec
@@ -0,0 +1,234 @@
+#%define majver %(echo %version | cut -d. -f1)
+#%define minver %(echo %version | cut -d. -f2)
+%define majver %(echo %version | cut -dp -f1)
+%define minver %(echo %{version}p | cut -dp -f2)
+Name: xpdf
+Version: 3.03
+Release: 1mamba
+Summary: An open source viewer for Portable Document Format (PDF) files
+Group: Graphical Desktop/Applications/Publishing
+Vendor: openmamba
+Distribution: openmamba
+Packager: Silvan Calarco
+URL: http://www.foolabs.com/xpdf/index.html
+Source0: ftp://ftp.foolabs.com/pub/xpdf/%{name}-%{majver}.tar.gz
+Source1: ftp://ftp.foolabs.com/pub/xpdf/%{name}-arabic.tar.gz
+Source2: ftp://ftp.foolabs.com/pub/xpdf/%{name}-chinese-simplified.tar.gz
+Source3: ftp://ftp.foolabs.com/pub/xpdf/%{name}-chinese-traditional.tar.gz
+Source4: ftp://ftp.foolabs.com/pub/xpdf/%{name}-cyrillic.tar.gz
+Source5: ftp://ftp.foolabs.com/pub/xpdf/%{name}-greek.tar.gz
+Source6: ftp://ftp.foolabs.com/pub/xpdf/%{name}-hebrew.tar.gz
+Source7: ftp://ftp.foolabs.com/pub/xpdf/%{name}-japanese.tar.gz
+Source8: ftp://ftp.foolabs.com/pub/xpdf/%{name}-korean.tar.gz
+Source9: ftp://ftp.foolabs.com/pub/xpdf/%{name}-latin2.tar.gz
+Source10: ftp://ftp.foolabs.com/pub/xpdf/%{name}-thai.tar.gz
+Source11: ftp://ftp.foolabs.com/pub/xpdf/%{name}-turkish.tar.gz
+Source12: xpdf-xpdf_desktop
+#%if "%{minver}" != ""
+#Source13: ftp://ftp.foolabs.com/pub/xpdf/%{name}-%{majver}pl1.patch
+#Source14: ftp://ftp.foolabs.com/pub/xpdf/%{name}-%{majver}p%{minver}.patch
+#%endif
+Patch0: %{name}-2.03-fonts.patch
+Patch1: %{name}-3.00-gcc4.patch
+Patch2: %{name}-3.03-xpdfrc.patch
+Patch4: %{name}-3.01-crash.patch
+Patch5: %{name}-3.00-can_2005_0206.patch
+Patch6: %{name}-3.01-can_2005_2097.patch
+Patch7: %{name}-3.01-can_2005_3191_2_3.patch
+Patch8: %{name}-3.01-can_2005_3624_5_6_7.patch
+Patch9: %{name}-3.01-cve_2006_0301.patch
+Patch10: %{name}-3.03-libXpm-3.5.10.patch
+License: GPL
+## AUTOBUILDREQ-BEGIN
+BuildRequires: ghostscript-fonts
+BuildRequires: glibc-devel
+BuildRequires: libfreetype-devel
+BuildRequires: libgcc
+BuildRequires: libICE-devel
+BuildRequires: liblesstif-devel
+BuildRequires: libpaper-devel
+BuildRequires: libSM-devel
+BuildRequires: libstdc++6-devel
+BuildRequires: libt1-devel
+BuildRequires: libX11-devel
+BuildRequires: libXext-devel
+BuildRequires: libXp-devel
+BuildRequires: libXpm-devel
+BuildRequires: libXt-devel
+## AUTOBUILDREQ-END
+Requires: ghostscript-fonts >= 6.0
+Requires: libpoppler-tools
+BuildRoot: %{_tmppath}/%{name}-%{version}-root
+
+%description
+Xpdf is an open source viewer for Portable Document Format (PDF) files.
+(These are also sometimes also called 'Acrobat' files, from the name of Adobe's PDF software.)
+The Xpdf project also includes a PDF text extractor, PDF-to-PostScript converter, and various other utilities.
+
+%prep
+%setup -q -a1 -a2 -a3 -a4 -a5 -a6 -a7 -a8 -a9 -a10 -a11 -n %{name}-%{majver}
+%patch0 -p1 -b .fonts
+%patch1 -p1 -b .gcc4
+%patch2 -p1 -b .xpdfrc
+%if "%{minver}" != ""
+patch -p1 < %{SOURCE13}
+patch -p1 < %{SOURCE14}
+%endif
+#%patch4 -p1 -b .crash
+#%patch5 -p1 -b .can_2005_2006
+%patch6 -p1 -b .can_2005_2097
+#%patch7 -p1 -b .can_2005_3191_2_3
+#%patch8 -p1 -b .can_2005_3624_5_6_7
+#%patch9 -p1 -b .cve_2006_0301
+%patch10 -p1
+
+languages='
+ arabic
+ chinese-simplified
+ chinese-traditional
+ cyrillic
+ greek
+ hebrew
+ japanese
+ korean
+ latin2
+ thai
+ turkish'
+> languages.lst
+for lang in $languages; do echo "$lang" >> languages.lst; done
+
+%build
+# FIXME: -D__STRICT_ANSI__ needed as long as gcc provides a fixed header
+# for paper.h
+%configure \
+ --sysconfdir=%{_sysconfdir}/X11/xpdf \
+ --enable-freetype2 \
+ --with-freetype2-includes=%{_includedir}/freetype2 \
+ --with-appdef-dir=%{_datadir}/X11/app-defaults \
+ --enable-a4-paper \
+ --enable-opi \
+ CXXFLAGS="-g -O2 -D__STRICT_ANSI__"
+# --enable-wordlist
+
+%make
+
+for lang in `cat languages.lst`; do
+ sed -i '
+ s,/usr/local/share/xpdf,%{_datadir}/xpdf,g
+ s,/usr/local/etc/xpdfrc,%{_sysconfdir}/X11/xpdf/xpdfrc,g' \
+ xpdf-$lang/{add-to-xpdfrc,README}
+ echo >> doc/sample-xpdfrc
+ cat xpdf-$lang/add-to-xpdfrc >> doc/sample-xpdfrc
+ rm xpdf-$lang/add-to-xpdfrc
+done
+
+%install
+[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
+%makeinstall
+
+for lang in `cat languages.lst`; do
+ install -d %{buildroot}%{_datadir}/%{name}/$lang
+ cp -a xpdf-$lang/* %{buildroot}%{_datadir}/%{name}/$lang/
+done
+
+# fix wrong paths
+find %{buildroot}/%{_mandir}/man? -type f -name "*.[15]" \
+ -exec sed -i 's,/usr/local/etc/xpdfrc,/etc/X11/xpdf/xpdfrc,g' {} \;
+sed -i 's,/usr/local/share/,/usr/share/,g' \
+ %{buildroot}/%{_mandir}/man5/xpdfrc.5
+
+install -D -m644 %{SOURCE12} \
+ %{buildroot}%{_datadir}/applications/xpdf.desktop
+
+rm -f %{buildroot}%{_bindir}/pdf*
+rm -f %{buildroot}%{_mandir}/man1/pdf*.1*
+
+%clean
+[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
+
+%files
+%defattr(-,root,root)
+%dir %{_sysconfdir}/X11/xpdf
+%config %{_sysconfdir}/X11/xpdf/xpdfrc
+%{_bindir}/xpdf
+%dir %{_datadir}/xpdf
+%{_datadir}/xpdf/*
+%{_datadir}/applications/xpdf.desktop
+%{_mandir}/man1/xpdf.1.gz
+%{_mandir}/man5/xpdfrc.5.gz
+%doc COPYING
+#%doc ANNOUNCE CHANGES COPYING README
+
+%changelog
+* Mon Oct 24 2011 Automatic Build System 3.03-1mamba
+- update to 3.03
+
+* Wed Jun 09 2010 Silvan Calarco 3.02pl4-3mamba
+- don't install pdf* man pages provided by libpoppler-tools 0.13
+
+* Thu Dec 03 2009 Silvan Calarco 3.02pl4-2mamba
+- don't provide pdf conversion tools but use libpoppler-tools (added as requirement)
+
+* Sat Oct 24 2009 Automatic Build System 3.02pl4-1mamba
+- automatic update by autodist
+
+* Fri Jul 10 2009 Automatic Build System 3.02pl3-1mamba
+- automatic update by autodist
+
+* Tue Dec 30 2008 Silvan Calarco 3.02pl2-1mamba
+- update to 3.02pl2
+
+* Tue Jul 15 2008 Silvan Calarco 3.02-1mamba
+- update to 3.02
+
+* Thu Apr 27 2006 Davide Madrisan 3.01-7qilnx
+- fixed desktop file
+
+* Fri Feb 03 2006 Davide Madrisan 3.01-6qilnx
+- security update for CVE-2006-0301 (qibug#122)
+
+* Fri Jan 20 2006 Davide Madrisan 3.01-5qilnx
+- security update for CVE-2005-2006, and CVE-2005-362[4,5,6,7] (qibug#105)
+
+* Tue Dec 13 2005 Davide Madrisan 3.01-4qilnx
+- fixed desktop file
+
+* Wed Dec 07 2005 Davide Madrisan 3.01-3qilnx
+- security fix CAN-2005-3193 (qibug#90)
+
+* Wed Nov 09 2005 Davide Madrisan 3.01-2qilnx
+- added desktop file
+
+* Mon Aug 22 2005 Davide Madrisan 3.01-1qilnx
+- update to version 3.01 by autospec
+- fixed security issue QSA-2005-090 (CAN-2005-2097)
+
+* Mon Feb 14 2005 Davide Madrisan 3.00-2qilnx
+- rebuilt with new libt1 libraries
+
+* Thu Jan 20 2005 Davide Madrisan 3.00-1qilnx
+- update to version 3.00 by autospec
+- fixed security issue QSA-2005-003 (CAN-2004-1125)
+- added support for arabic, chinese-simplified, chinese-traditional,
+ cyrillic, greek, hebrew, japanese, korean, latin2, thai, turkish
+
+* Sat Nov 27 2004 Davide Madrisan 2.03-4qilnx
+- fixed size of `times-medium-r-normal' in XPDFViewer.cc
+
+* Sat Oct 30 2004 Davide Madrisan 2.03-3qilnx
+- added a patch to customize the xpdf configuration file:
+ - ghostscript and TTF fonts path fixed/added
+ - font anti-aliasing enabled
+ - paper size default set to A4
+ - default printer set to kprinter (KDE printer)
+ - browser for URL hyperlink set to konqueror
+- added the requirement `ghostscript-fonts'
+
+* Thu Oct 28 2004 Davide Madrisan 2.03-2qilnx
+- security fix (QSA-2004-047): CAN-2004-0888
+
+* Mon Jan 12 2004 Davide Madrisan 2.03-1qilnx
+- package updated
+
+* Thu Sep 25 2003 Silvan Calarco 2.02pl1-1qilnx
+- first build