diff options
author | Anas Nashif <anas.nashif@intel.com> | 2013-02-26 07:25:08 -0800 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2013-02-26 07:25:08 -0800 |
commit | 5942f0e1c3612174a62de62227bc4c5d3c947797 (patch) | |
tree | 6366f95e09113b971f6adec814a4a78bb2e7b2b6 /utils | |
parent | 65619a8a518ba0f513e57429e461d199264a9929 (diff) | |
download | poppler-5942f0e1c3612174a62de62227bc4c5d3c947797.tar.gz poppler-5942f0e1c3612174a62de62227bc4c5d3c947797.tar.bz2 poppler-5942f0e1c3612174a62de62227bc4c5d3c947797.zip |
Imported Upstream version 0.22.1upstream/0.22.1
Diffstat (limited to 'utils')
-rw-r--r-- | utils/CMakeLists.txt | 3 | ||||
-rw-r--r-- | utils/HtmlFonts.cc | 10 | ||||
-rw-r--r-- | utils/HtmlFonts.h | 4 | ||||
-rw-r--r-- | utils/HtmlOutputDev.cc | 126 | ||||
-rw-r--r-- | utils/Makefile.am | 4 | ||||
-rw-r--r-- | utils/Makefile.in | 45 | ||||
-rw-r--r-- | utils/pdfinfo.cc | 84 | ||||
-rw-r--r-- | utils/pdfseparate.cc | 4 | ||||
-rw-r--r-- | utils/pdftocairo.1 | 23 | ||||
-rw-r--r-- | utils/pdftocairo.cc | 92 | ||||
-rw-r--r-- | utils/pdftohtml.1 | 11 | ||||
-rw-r--r-- | utils/pdftohtml.cc | 157 | ||||
-rw-r--r-- | utils/pdftoppm.cc | 10 | ||||
-rw-r--r-- | utils/pdfunite.cc | 10 |
14 files changed, 263 insertions, 320 deletions
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 4a29841b..06378bd9 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -5,9 +5,6 @@ set(common_srcs set(common_libs poppler ) -if (FONTCONFIG_FOUND) - set(common_libs ${common_libs} ${FONTCONFIG_LIBRARIES}) -endif (FONTCONFIG_FOUND) if (ENABLE_SPLASH) # pdftoppm diff --git a/utils/HtmlFonts.cc b/utils/HtmlFonts.cc index be02c5f3..d8334bce 100644 --- a/utils/HtmlFonts.cc +++ b/utils/HtmlFonts.cc @@ -17,13 +17,14 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2007, 2010 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2007, 2010, 2012 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2008 Boris Toloknov <tlknv@yandex.ru> // Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com> // Copyright (C) 2010 OSSD CDAC Mumbai by Leena Chourey (leenac@cdacmumbai.in) and Onkar Potdar (onkar@cdacmumbai.in) // Copyright (C) 2011 Joshua Richardson <jric@chegg.com> // Copyright (C) 2011 Stephen Reichling <sreichling@chegg.com> // Copyright (C) 2012 Igor Slepchin <igor.slepchin@gmail.com> +// Copyright (C) 2012 Luis Parravicini <lparravi@gmail.com> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -63,6 +64,7 @@ static Fonts fonts[font_num+1]={ #define xoutRound(x) ((int)(x + 0.5)) extern GBool xml; +extern GBool fontFullName; GooString* HtmlFont::DefaultFont=new GooString("Times"); // Arial,Helvetica,sans-serif @@ -81,10 +83,10 @@ GooString *HtmlFontColor::convtoX(unsigned int xcol) const{ char tmp; unsigned int k; k = (xcol/16); - if ((k>=0)&&(k<10)) tmp=(char) ('0'+k); else tmp=(char)('a'+k-10); + if (k<10) tmp=(char) ('0'+k); else tmp=(char)('a'+k-10); xret->append(tmp); k = (xcol%16); - if ((k>=0)&&(k<10)) tmp=(char) ('0'+k); else tmp=(char)('a'+k-10); + if (k<10) tmp=(char) ('0'+k); else tmp=(char)('a'+k-10); xret->append(tmp); return xret; } @@ -318,7 +320,7 @@ GooString* HtmlFontAccu::CSStyle(int i, int j){ HtmlFont font=*g; GooString *Size=GooString::fromInt(font.getSize()); GooString *colorStr=font.getColor().toString(); - GooString *fontName=font.getFontName(); + GooString *fontName=(fontFullName ? font.getFullName() : font.getFontName()); GooString *lSize; if(!xml){ diff --git a/utils/HtmlFonts.h b/utils/HtmlFonts.h index 22368b28..7993c78e 100644 --- a/utils/HtmlFonts.h +++ b/utils/HtmlFonts.h @@ -18,7 +18,7 @@ // under GPL version 2 or later // // Copyright (C) 2010 OSSD CDAC Mumbai by Leena Chourey (leenac@cdacmumbai.in) and Onkar Potdar (onkar@cdacmumbai.in) -// Copyright (C) 2010 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2010, 2012 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2011 Steven Murdoch <Steven.Murdoch@cl.cam.ac.uk> // Copyright (C) 2011 Joshua Richardson <jric@chegg.com> // Copyright (C) 2012 Igor Slepchin <igor.slepchin@gmail.com> @@ -40,7 +40,7 @@ class HtmlFontColor{ unsigned int r; unsigned int g; unsigned int b; - GBool Ok(unsigned int xcol){ return ((xcol<=255)&&(xcol>=0));} + GBool Ok(unsigned int xcol){ return xcol<=255;} GooString *convtoX(unsigned int xcol) const; public: HtmlFontColor():r(0),g(0),b(0){} diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc index 1d1b6285..a718380f 100644 --- a/utils/HtmlOutputDev.cc +++ b/utils/HtmlOutputDev.cc @@ -25,13 +25,15 @@ // Copyright (C) 2009 Warren Toomey <wkt@tuhs.org> // Copyright (C) 2009, 2011 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2009 Reece Dunn <msclrhd@gmail.com> -// Copyright (C) 2010 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2010, 2012 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2010 Hib Eris <hib@hiberis.nl> // Copyright (C) 2010 OSSD CDAC Mumbai by Leena Chourey (leenac@cdacmumbai.in) and Onkar Potdar (onkar@cdacmumbai.in) // Copyright (C) 2011 Joshua Richardson <jric@chegg.com> // Copyright (C) 2011 Stephen Reichling <sreichling@chegg.com> // Copyright (C) 2011, 2012 Igor Slepchin <igor.slepchin@gmail.com> // Copyright (C) 2012 Ihar Filipau <thephilips@gmail.com> +// Copyright (C) 2012 Gerald Schmidt <solahcin@gmail.com> +// Copyright (C) 2012 Pino Toscano <pino@kde.org> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -66,6 +68,10 @@ #include "Outline.h" #include "PDFDoc.h" +#ifdef ENABLE_LIBPNG +#include <png.h> +#endif + #define DEBUG __FILE__ << ": " << __LINE__ << ": DEBUG: " class HtmlImage @@ -399,19 +405,7 @@ void HtmlPage::addChar(GfxState *state, double x, double y, h1 /= uLen; } for (i = 0; i < uLen; ++i) { - Unicode u1 = u[i]; - if (u1 >= 0xd800 && u1 <= 0xdbff && i < uLen) { - // surrogate pair - const Unicode u2 = u[i + 1]; - if (u2 >= 0xdc00 && u2 <= 0xdfff) { - u1 = 0x10000 + ((u1 - 0xd800) << 10) + (u2 - 0xdc00); - - curStr->addChar(state, x1 + i*w1, y1 + i*h1, w1, h1, u1); - } - ++i; - } else { - curStr->addChar(state, x1 + i*w1, y1 + i*h1, w1, h1, u1); - } + curStr->addChar(state, x1 + i*w1, y1 + i*h1, w1, h1, u[i]); } } @@ -782,7 +776,7 @@ static void printCSS(FILE *f) // http://stackoverflow.com/questions/1309055/cross-browser-way-to-flip-html-image-via-javascript-css // tested in Chrome, Fx (Linux) and IE9 (W7) static const char css[] = - "<STYLE type=\"text/css\">" "\n" + "<style type=\"text/css\">" "\n" "<!--" "\n" ".xflip {" "\n" " -moz-transform: scaleX(-1);" "\n" @@ -806,7 +800,7 @@ static void printCSS(FILE *f) " filter: fliph + flipv;" "\n" "}" "\n" "-->" "\n" - "</STYLE>" "\n"; + "</style>" "\n"; fwrite( css, sizeof(css)-1, 1, f ); } @@ -833,17 +827,17 @@ int HtmlPage::dumpComplexHeaders(FILE * const file, FILE *& pageFile, int page) } if (!singleHtml) - fprintf(pageFile,"%s\n<HTML xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"\" xml:lang=\"\">\n<HEAD>\n<TITLE>Page %d</TITLE>\n\n", DOCTYPE, page); + fprintf(pageFile,"%s\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"\" xml:lang=\"\">\n<head>\n<title>Page %d</title>\n\n", DOCTYPE, page); else - fprintf(pageFile,"%s\n<HTML xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"\" xml:lang=\"\">\n<HEAD>\n<TITLE>%s</TITLE>\n\n", DOCTYPE, tmp->getCString()); + fprintf(pageFile,"%s\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"\" xml:lang=\"\">\n<head>\n<title>%s</title>\n\n", DOCTYPE, tmp->getCString()); delete tmp; GooString *htmlEncoding = HtmlOutputDev::mapEncodingToHtml(globalParams->getTextEncodingName()); if (!singleHtml) - fprintf(pageFile, "<META http-equiv=\"Content-Type\" content=\"text/html; charset=%s\"/>\n", htmlEncoding->getCString()); + fprintf(pageFile, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\"/>\n", htmlEncoding->getCString()); else - fprintf(pageFile, "<META http-equiv=\"Content-Type\" content=\"text/html; charset=%s\"/>\n <br/>\n", htmlEncoding->getCString()); + fprintf(pageFile, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\"/>\n <br/>\n", htmlEncoding->getCString()); delete htmlEncoding; } else @@ -866,7 +860,7 @@ void HtmlPage::dumpComplex(FILE *file, int page){ tmp=basename(DocName); - fputs("<STYLE type=\"text/css\">\n<!--\n",pageFile); + fputs("<style type=\"text/css\">\n<!--\n",pageFile); fputs("\tp {margin: 0; padding: 0;}",pageFile); for(int i=fontsPageMarker;i!=fonts->size();i++) { GooString *fontCSStyle; @@ -878,20 +872,20 @@ void HtmlPage::dumpComplex(FILE *file, int page){ delete fontCSStyle; } - fputs("-->\n</STYLE>\n",pageFile); + fputs("-->\n</style>\n",pageFile); if( !noframes ) { - fputs("</HEAD>\n<BODY bgcolor=\"#A0A0A0\" vlink=\"blue\" link=\"blue\">\n",pageFile); + fputs("</head>\n<body bgcolor=\"#A0A0A0\" vlink=\"blue\" link=\"blue\">\n",pageFile); } - fprintf(pageFile,"<DIV id=\"page%d-div\" style=\"position:relative;width:%dpx;height:%dpx;\">\n", + fprintf(pageFile,"<div id=\"page%d-div\" style=\"position:relative;width:%dpx;height:%dpx;\">\n", page, pageWidth, pageHeight); if( !ignore ) { fprintf(pageFile, - "<IMG width=\"%d\" height=\"%d\" src=\"%s%03d.%s\" alt=\"background image\"/>\n", + "<img width=\"%d\" height=\"%d\" src=\"%s%03d.%s\" alt=\"background image\"/>\n", pageWidth, pageHeight, tmp->getCString(), (page-firstPage+1), imgExt->getCString()); } @@ -901,7 +895,7 @@ void HtmlPage::dumpComplex(FILE *file, int page){ for(HtmlString *tmp1=yxStrings;tmp1;tmp1=tmp1->yxNext){ if (tmp1->htext){ fprintf(pageFile, - "<P style=\"position:absolute;top:%dpx;left:%dpx;white-space:nowrap\" class=\"ft", + "<p style=\"position:absolute;top:%dpx;left:%dpx;white-space:nowrap\" class=\"ft", xoutRound(tmp1->yMin), xoutRound(tmp1->xMin)); if (!singleHtml) { @@ -911,15 +905,15 @@ void HtmlPage::dumpComplex(FILE *file, int page){ } fprintf(pageFile,"%d\">", tmp1->fontpos); fputs(tmp1->htext->getCString(), pageFile); - fputs("</P>\n", pageFile); + fputs("</p>\n", pageFile); } } - fputs("</DIV>\n", pageFile); + fputs("</div>\n", pageFile); if( !noframes ) { - fputs("</BODY>\n</HTML>\n",pageFile); + fputs("</body>\n</html>\n",pageFile); fclose(pageFile); } } @@ -934,7 +928,7 @@ void HtmlPage::dump(FILE *f, int pageNum) } else { - fprintf(f,"<A name=%d></a>",pageNum); + fprintf(f,"<a name=%d></a>",pageNum); // Loop over the list of image names on this page int listlen=imgList->getLength(); for (int i = 0; i < listlen; i++) { @@ -946,7 +940,7 @@ void HtmlPage::dump(FILE *f, int pageNum) if (img->xMin > img->xMax) style_index += 1; // xFlip if (img->yMin > img->yMax) style_index += 2; // yFlip - fprintf(f,"<IMG%s src=\"%s\"/><br/>\n",styles[style_index],img->fName->getCString()); + fprintf(f,"<img%s src=\"%s\"/><br/>\n",styles[style_index],img->fName->getCString()); delete img; } @@ -959,7 +953,7 @@ void HtmlPage::dump(FILE *f, int pageNum) fputs("<br/>\n",f); } } - fputs("<hr>\n",f); + fputs("<hr/>\n",f); } } @@ -1024,7 +1018,7 @@ HtmlMetaVar::~HtmlMetaVar() GooString* HtmlMetaVar::toString() { - GooString *result = new GooString("<META name=\""); + GooString *result = new GooString("<meta name=\""); result->append(name); result->append("\" content=\""); result->append(content); @@ -1070,22 +1064,22 @@ void HtmlOutputDev::doFrame(int firstPage){ fName=basename(Docname); fputs(DOCTYPE, fContentsFrame); - fputs("\n<HTML>",fContentsFrame); - fputs("\n<HEAD>",fContentsFrame); - fprintf(fContentsFrame,"\n<TITLE>%s</TITLE>",docTitle->getCString()); + fputs("\n<html>",fContentsFrame); + fputs("\n<head>",fContentsFrame); + fprintf(fContentsFrame,"\n<title>%s</title>",docTitle->getCString()); htmlEncoding = mapEncodingToHtml(globalParams->getTextEncodingName()); - fprintf(fContentsFrame, "\n<META http-equiv=\"Content-Type\" content=\"text/html; charset=%s\"/>\n", htmlEncoding->getCString()); + fprintf(fContentsFrame, "\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\"/>\n", htmlEncoding->getCString()); dumpMetaVars(fContentsFrame); - fprintf(fContentsFrame, "</HEAD>\n"); - fputs("<FRAMESET cols=\"100,*\">\n",fContentsFrame); - fprintf(fContentsFrame,"<FRAME name=\"links\" src=\"%s_ind.html\">\n",fName->getCString()); - fputs("<FRAME name=\"contents\" src=",fContentsFrame); + fprintf(fContentsFrame, "</head>\n"); + fputs("<frameset cols=\"100,*\">\n",fContentsFrame); + fprintf(fContentsFrame,"<frame name=\"links\" src=\"%s_ind.html\"/>\n",fName->getCString()); + fputs("<frame name=\"contents\" src=",fContentsFrame); if (complexMode) fprintf(fContentsFrame,"\"%s-%d.html\"",fName->getCString(), firstPage); else fprintf(fContentsFrame,"\"%ss.html\"",fName->getCString()); - fputs(">\n</FRAMESET>\n</HTML>\n",fContentsFrame); + fputs("/>\n</frameset>\n</html>\n",fContentsFrame); delete fName; delete htmlEncoding; @@ -1143,12 +1137,12 @@ HtmlOutputDev::HtmlOutputDev(Catalog *catalogA, char *fileName, char *title, } delete left; fputs(DOCTYPE, fContentsFrame); - fputs("<HTML xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"\" xml:lang=\"\">\n<HEAD>\n<TITLE></TITLE>\n</HEAD>\n<BODY>\n", fContentsFrame); + fputs("<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"\" xml:lang=\"\">\n<head>\n<title></title>\n</head>\n<body>\n", fContentsFrame); if (doOutline) { GooString *str = basename(Docname); - fprintf(fContentsFrame, "<A href=\"%s%s\" target=\"contents\">Outline</a><br/>", str->getCString(), complexMode ? "-outline.html" : "s.html#outline"); + fprintf(fContentsFrame, "<a href=\"%s%s\" target=\"contents\">Outline</a><br/>", str->getCString(), complexMode ? "-outline.html" : "s.html#outline"); delete str; } } @@ -1165,9 +1159,9 @@ HtmlOutputDev::HtmlOutputDev(Catalog *catalogA, char *fileName, char *title, } delete right; fputs(DOCTYPE, page); - fputs("<HTML>\n<HEAD>\n<TITLE></TITLE>\n",page); + fputs("<html>\n<head>\n<title></title>\n",page); printCSS(page); - fputs("</HEAD>\n<BODY>\n",page); + fputs("</head>\n<body>\n",page); } } @@ -1194,14 +1188,14 @@ HtmlOutputDev::HtmlOutputDev(Catalog *catalogA, char *fileName, char *title, } else { - fprintf(page,"%s\n<HTML xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"\" xml:lang=\"\">\n<HEAD>\n<TITLE>%s</TITLE>\n", DOCTYPE, docTitle->getCString()); + fprintf(page,"%s\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"\" xml:lang=\"\">\n<head>\n<title>%s</title>\n", DOCTYPE, docTitle->getCString()); - fprintf(page, "<META http-equiv=\"Content-Type\" content=\"text/html; charset=%s\"/>\n", htmlEncoding->getCString()); + fprintf(page, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\"/>\n", htmlEncoding->getCString()); dumpMetaVars(page); printCSS(page); - fprintf(page,"</HEAD>\n"); - fprintf(page,"<BODY bgcolor=\"#A0A0A0\" vlink=\"blue\" link=\"blue\">\n"); + fprintf(page,"</head>\n"); + fprintf(page,"<body bgcolor=\"#A0A0A0\" vlink=\"blue\" link=\"blue\">\n"); } delete htmlEncoding; } @@ -1217,7 +1211,7 @@ HtmlOutputDev::~HtmlOutputDev() { deleteGooList(glMetaVars, HtmlMetaVar); if (fContentsFrame){ - fputs("</BODY>\n</HTML>\n",fContentsFrame); + fputs("</body>\n</html>\n",fContentsFrame); fclose(fContentsFrame); } if (page != NULL) { @@ -1227,7 +1221,7 @@ HtmlOutputDev::~HtmlOutputDev() { } else if ( !complexMode || xml || noframes ) { - fputs("</BODY>\n</HTML>\n",page); + fputs("</body>\n</html>\n",page); fclose(page); } } @@ -1263,9 +1257,9 @@ void HtmlOutputDev::startPage(int pageNum, GfxState *state) { if (fContentsFrame) { if (complexMode) - fprintf(fContentsFrame,"<A href=\"%s-%d.html\"",str->getCString(),pageNum); + fprintf(fContentsFrame,"<a href=\"%s-%d.html\"",str->getCString(),pageNum); else - fprintf(fContentsFrame,"<A href=\"%ss.html#%d\"",str->getCString(),pageNum); + fprintf(fContentsFrame,"<a href=\"%ss.html#%d\"",str->getCString(),pageNum); fprintf(fContentsFrame," target=\"contents\" >Page %d</a><br/>\n",pageNum); } } @@ -1295,7 +1289,7 @@ void HtmlOutputDev::endPage() { maxPageWidth = pages->pageWidth; maxPageHeight = pages->pageHeight; - //if(!noframes&&!xml) fputs("<br>\n", fContentsFrame); + //if(!noframes&&!xml) fputs("<br/>\n", fContentsFrame); if(!stout && !globalParams->getErrQuiet()) printf("Page-%d\n",(pageNum)); } @@ -1698,7 +1692,7 @@ GBool HtmlOutputDev::dumpDocOutline(PDFDoc* doc) if (noframes) { output = page; - fputs("<hr>\n", output); + fputs("<hr/>\n", output); } else { @@ -1713,13 +1707,13 @@ GBool HtmlOutputDev::dumpDocOutline(PDFDoc* doc) GooString *htmlEncoding = HtmlOutputDev::mapEncodingToHtml(globalParams->getTextEncodingName()); - fprintf(output, "<HTML xmlns=\"http://www.w3.org/1999/xhtml\" " \ + fprintf(output, "<html xmlns=\"http://www.w3.org/1999/xhtml\" " \ "lang=\"\" xml:lang=\"\">\n" \ - "<HEAD>\n" \ - "<TITLE>Document Outline</TITLE>\n" \ - "<META http-equiv=\"Content-Type\" content=\"text/html; " \ + "<head>\n" \ + "<title>Document Outline</title>\n" \ + "<meta http-equiv=\"Content-Type\" content=\"text/html; " \ "charset=%s\"/>\n" \ - "</HEAD>\n<BODY>\n", htmlEncoding->getCString()); + "</head>\n<body>\n", htmlEncoding->getCString()); delete htmlEncoding; } } @@ -1728,11 +1722,11 @@ GBool HtmlOutputDev::dumpDocOutline(PDFDoc* doc) { GBool done = newHtmlOutlineLevel(output, outlines, catalog); if (done && !complexMode) - fputs("<hr>\n", output); + fputs("<hr/>\n", output); if (bClose) { - fputs("</BODY>\n</HTML>\n", output); + fputs("</body>\n</html>\n", output); fclose(output); } } @@ -1752,7 +1746,7 @@ GBool HtmlOutputDev::newHtmlOutlineLevel(FILE *output, GooList *outlines, Catalo if (level == 1) { - fputs("<A name=\"outline\"></a>", output); + fputs("<a name=\"outline\"></a>", output); fputs("<h1>Document Outline</h1>\n", output); } fputs("<ul>\n",output); @@ -1791,10 +1785,10 @@ GBool HtmlOutputDev::newHtmlOutlineLevel(FILE *output, GooList *outlines, Catalo fputs("<li>",output); if (linkName) - fprintf(output,"<A href=\"%s\">", linkName->getCString()); + fprintf(output,"<a href=\"%s\">", linkName->getCString()); fputs(titleStr->getCString(),output); if (linkName) { - fputs("</A>",output); + fputs("</a>",output); delete linkName; } delete titleStr; diff --git a/utils/Makefile.am b/utils/Makefile.am index ad845c19..d56cc9c6 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -16,13 +16,11 @@ INCLUDES = \ -I$(top_srcdir)/utils \ -I$(top_srcdir)/poppler \ $(UTILS_CFLAGS) \ - $(FONTCONFIG_CFLAGS) \ $(PDFTOCAIRO_CFLAGS) LDADD = \ $(top_builddir)/poppler/libpoppler.la \ - $(UTILS_LIBS) \ - $(FONTCONFIG_LIBS) + $(UTILS_LIBS) if BUILD_CAIRO_OUTPUT diff --git a/utils/Makefile.in b/utils/Makefile.in index cfda1da2..aa531030 100644 --- a/utils/Makefile.in +++ b/utils/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.5 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -84,45 +84,39 @@ am__objects_1 = parseargs.$(OBJEXT) am_pdfdetach_OBJECTS = pdfdetach.$(OBJEXT) $(am__objects_1) pdfdetach_OBJECTS = $(am_pdfdetach_OBJECTS) pdfdetach_LDADD = $(LDADD) -am__DEPENDENCIES_1 = -pdfdetach_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la \ - $(am__DEPENDENCIES_1) +pdfdetach_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am_pdffonts_OBJECTS = pdffonts.$(OBJEXT) $(am__objects_1) pdffonts_OBJECTS = $(am_pdffonts_OBJECTS) pdffonts_LDADD = $(LDADD) -pdffonts_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la \ - $(am__DEPENDENCIES_1) +pdffonts_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la am_pdfimages_OBJECTS = pdfimages.$(OBJEXT) ImageOutputDev.$(OBJEXT) \ $(am__objects_1) pdfimages_OBJECTS = $(am_pdfimages_OBJECTS) pdfimages_LDADD = $(LDADD) -pdfimages_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la \ - $(am__DEPENDENCIES_1) +pdfimages_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la am_pdfinfo_OBJECTS = pdfinfo.$(OBJEXT) printencodings.$(OBJEXT) \ $(am__objects_1) pdfinfo_OBJECTS = $(am_pdfinfo_OBJECTS) pdfinfo_LDADD = $(LDADD) -pdfinfo_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la \ - $(am__DEPENDENCIES_1) +pdfinfo_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la am_pdfseparate_OBJECTS = pdfseparate.$(OBJEXT) $(am__objects_1) pdfseparate_OBJECTS = $(am_pdfseparate_OBJECTS) pdfseparate_LDADD = $(LDADD) -pdfseparate_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la \ - $(am__DEPENDENCIES_1) +pdfseparate_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la am__pdftocairo_SOURCES_DIST = pdftocairo.cc parseargs.cc parseargs.h @BUILD_CAIRO_OUTPUT_TRUE@am_pdftocairo_OBJECTS = pdftocairo.$(OBJEXT) \ @BUILD_CAIRO_OUTPUT_TRUE@ $(am__objects_1) pdftocairo_OBJECTS = $(am_pdftocairo_OBJECTS) -am__DEPENDENCIES_2 = $(top_builddir)/poppler/libpoppler.la \ - $(am__DEPENDENCIES_1) +am__DEPENDENCIES_1 = $(top_builddir)/poppler/libpoppler.la +am__DEPENDENCIES_2 = @BUILD_CAIRO_OUTPUT_TRUE@@USE_CMS_TRUE@am__DEPENDENCIES_3 = \ -@BUILD_CAIRO_OUTPUT_TRUE@@USE_CMS_TRUE@ $(am__DEPENDENCIES_1) +@BUILD_CAIRO_OUTPUT_TRUE@@USE_CMS_TRUE@ $(am__DEPENDENCIES_2) am__DEPENDENCIES_4 = $(am__DEPENDENCIES_3) @BUILD_CAIRO_OUTPUT_TRUE@pdftocairo_DEPENDENCIES = $(top_builddir)/poppler/libpoppler-cairo.la \ -@BUILD_CAIRO_OUTPUT_TRUE@ $(am__DEPENDENCIES_2) \ +@BUILD_CAIRO_OUTPUT_TRUE@ $(am__DEPENDENCIES_1) \ @BUILD_CAIRO_OUTPUT_TRUE@ $(am__DEPENDENCIES_4) am__objects_2 = pdftohtml-parseargs.$(OBJEXT) am_pdftohtml_OBJECTS = pdftohtml-pdftohtml.$(OBJEXT) \ @@ -130,8 +124,7 @@ am_pdftohtml_OBJECTS = pdftohtml-pdftohtml.$(OBJEXT) \ pdftohtml-HtmlOutputDev.$(OBJEXT) $(am__objects_2) pdftohtml_OBJECTS = $(am_pdftohtml_OBJECTS) pdftohtml_LDADD = $(LDADD) -pdftohtml_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la \ - $(am__DEPENDENCIES_1) +pdftohtml_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la pdftohtml_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(pdftohtml_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ @@ -140,24 +133,20 @@ am__pdftoppm_SOURCES_DIST = pdftoppm.cc parseargs.cc parseargs.h @BUILD_SPLASH_OUTPUT_TRUE@ $(am__objects_1) pdftoppm_OBJECTS = $(am_pdftoppm_OBJECTS) pdftoppm_LDADD = $(LDADD) -pdftoppm_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la \ - $(am__DEPENDENCIES_1) +pdftoppm_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la am_pdftops_OBJECTS = pdftops.$(OBJEXT) $(am__objects_1) pdftops_OBJECTS = $(am_pdftops_OBJECTS) pdftops_LDADD = $(LDADD) -pdftops_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la \ - $(am__DEPENDENCIES_1) +pdftops_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la am_pdftotext_OBJECTS = pdftotext.$(OBJEXT) printencodings.$(OBJEXT) \ $(am__objects_1) pdftotext_OBJECTS = $(am_pdftotext_OBJECTS) pdftotext_LDADD = $(LDADD) -pdftotext_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la \ - $(am__DEPENDENCIES_1) +pdftotext_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la am_pdfunite_OBJECTS = pdfunite.$(OBJEXT) $(am__objects_1) pdfunite_OBJECTS = $(am_pdfunite_OBJECTS) pdfunite_LDADD = $(LDADD) -pdfunite_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la \ - $(am__DEPENDENCIES_1) +pdfunite_DEPENDENCIES = $(top_builddir)/poppler/libpoppler.la DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/poppler depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @@ -459,13 +448,11 @@ INCLUDES = \ -I$(top_srcdir)/utils \ -I$(top_srcdir)/poppler \ $(UTILS_CFLAGS) \ - $(FONTCONFIG_CFLAGS) \ $(PDFTOCAIRO_CFLAGS) LDADD = \ $(top_builddir)/poppler/libpoppler.la \ - $(UTILS_LIBS) \ - $(FONTCONFIG_LIBS) + $(UTILS_LIBS) @BUILD_CAIRO_OUTPUT_TRUE@pdftocairo_SOURCES = \ @BUILD_CAIRO_OUTPUT_TRUE@ pdftocairo.cc \ diff --git a/utils/pdfinfo.cc b/utils/pdfinfo.cc index cdc5375d..10a6c31e 100644 --- a/utils/pdfinfo.cc +++ b/utils/pdfinfo.cc @@ -18,6 +18,7 @@ // Copyright (C) 2010 Hib Eris <hib@hiberis.nl> // Copyright (C) 2011 Vittal Aithal <vittal.aithal@cognidox.com> // Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> +// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -48,7 +49,7 @@ #include "PDFDocFactory.h" #include "CharTypes.h" #include "UnicodeMap.h" -#include "PDFDocEncoding.h" +#include "UTF.h" #include "Error.h" #include "DateInfo.h" @@ -107,8 +108,7 @@ int main(int argc, char *argv[]) { GooString *ownerPW, *userPW; UnicodeMap *uMap; Page *page; - Object info, xfa; - Object *acroForm; + Object info; char buf[256]; double w, h, wISO, hISO; FILE *f; @@ -228,16 +228,17 @@ int main(int argc, char *argv[]) { doc->getStructTreeRoot()->isDict() ? "yes" : "no"); // print form info - if ((acroForm = doc->getCatalog()->getAcroForm())->isDict()) { - acroForm->dictLookup("XFA", &xfa); - if (xfa.isStream() || xfa.isArray()) { - printf("Form: XFA\n"); - } else { + switch (doc->getCatalog()->getFormType()) + { + case Catalog::NoForm: + printf("Form: none\n"); + break; + case Catalog::AcroForm: printf("Form: AcroForm\n"); - } - xfa.free(); - } else { - printf("Form: none\n"); + break; + case Catalog::XfaForm: + printf("Form: XFA\n"); + break; } // print page count @@ -246,11 +247,31 @@ int main(int argc, char *argv[]) { // print encryption info printf("Encrypted: "); if (doc->isEncrypted()) { - printf("yes (print:%s copy:%s change:%s addNotes:%s)\n", + Guchar *fileKey; + CryptAlgorithm encAlgorithm; + int keyLength; + doc->getXRef()->getEncryptionParameters(&fileKey, &encAlgorithm, &keyLength); + + const char *encAlgorithmName = "unknown"; + switch (encAlgorithm) + { + case cryptRC4: + encAlgorithmName = "RC4"; + break; + case cryptAES: + encAlgorithmName = "AES"; + break; + case cryptAES256: + encAlgorithmName = "AES-256"; + break; + } + + printf("yes (print:%s copy:%s change:%s addNotes:%s algorithm:%s)\n", doc->okToPrint(gTrue) ? "yes" : "no", doc->okToCopy(gTrue) ? "yes" : "no", doc->okToChange(gTrue) ? "yes" : "no", - doc->okToAddNotes(gTrue) ? "yes" : "no"); + doc->okToAddNotes(gTrue) ? "yes" : "no", + encAlgorithmName); } else { printf("no\n"); } @@ -379,41 +400,16 @@ static void printInfoString(Dict *infoDict, const char *key, const char *text, UnicodeMap *uMap) { Object obj; GooString *s1; - GBool isUnicode; - Unicode u, u2; + Unicode *u; char buf[8]; - int i, n; + int i, n, len; if (infoDict->lookup(key, &obj)->isString()) { fputs(text, stdout); s1 = obj.getString(); - if ((s1->getChar(0) & 0xff) == 0xfe && - (s1->getChar(1) & 0xff) == 0xff) { - isUnicode = gTrue; - i = 2; - } else { - isUnicode = gFalse; - i = 0; - } - while (i < obj.getString()->getLength()) { - if (isUnicode) { - u = ((s1->getChar(i) & 0xff) << 8) | - (s1->getChar(i+1) & 0xff); - i += 2; - if (u >= 0xd800 && u <= 0xdbff && i < obj.getString()->getLength()) { - // surrogate pair - u2 = ((s1->getChar(i) & 0xff) << 8) | - (s1->getChar(i+1) & 0xff); - i += 2; - if (u2 >= 0xdc00 && u2 <= 0xdfff) { - u = 0x10000 + ((u - 0xd800) << 10) + (u2 - 0xdc00); - } - } - } else { - u = pdfDocEncoding[s1->getChar(i) & 0xff]; - ++i; - } - n = uMap->mapUnicode(u, buf, sizeof(buf)); + len = TextStringToUCS4(s1, &u); + for (i = 0; i < len; i++) { + n = uMap->mapUnicode(u[i], buf, sizeof(buf)); fwrite(buf, 1, n, stdout); } fputc('\n', stdout); diff --git a/utils/pdfseparate.cc b/utils/pdfseparate.cc index 25fac5a9..35ae0209 100644 --- a/utils/pdfseparate.cc +++ b/utils/pdfseparate.cc @@ -52,10 +52,6 @@ bool extractPages (const char *srcFileName, const char *destFileName) { error(errSyntaxError, -1, "Could not extract page(s) from damaged file ('{0:s}')", srcFileName); return false; } - if (doc->isEncrypted()) { - error(errSyntaxError, -1, "Could not extract page(s) from encrypted file ('{0:s}')", srcFileName); - return false; - } if (firstPage == 0 && lastPage == 0) { firstPage = 1; diff --git a/utils/pdftocairo.1 b/utils/pdftocairo.1 index 19b62efb..7d17eef4 100644 --- a/utils/pdftocairo.1 +++ b/utils/pdftocairo.1 @@ -1,6 +1,6 @@ .TH pdftoppm 1 .SH NAME -pdftocairo \- Portable Document Format (PDF) to PNG/JPEG/PDF/PS/EPS/SVG using cairo +pdftocairo \- Portable Document Format (PDF) to PNG/JPEG/TIFF/PDF/PS/EPS/SVG using cairo .SH SYNOPSIS .B pdftocairo [options] @@ -14,6 +14,8 @@ Portable Network Graphics (PNG) .IP \(bu JPEG Interchange Format (JPEG) .IP \(bu +Tagged Image File Format (TIFF) +.IP \(bu Portable Document Format (PDF) .IP \(bu PostScript (PS) @@ -27,7 +29,7 @@ reads the PDF file, .IR PDF-file , and writes to .IR output-file . -The image formats (PNG and JPEG) generate one file per page with the page number and file type appended to +The image formats (PNG, JPEG, and TIFF) generate one file per page with the page number and file type appended to .IR output-file (except when \-singlefile is used). When the output format is a vector format (PDF, PS, EPS, and SVG) or when \-singlefile is used, @@ -46,7 +48,7 @@ is not used, the output filename will be derived from the .IR PDF-file filename. .PP -Not all options are valid with all output formats. One (and only one) of the output format options (\-png, \-jpeg, \-pdf, \-ps, \-eps, or \-svg) must be used. +Not all options are valid with all output formats. One (and only one) of the output format options (\-png, \-jpeg, \-tiff, \-pdf, \-ps, \-eps, or \-svg) must be used. .PP The resolution options (\-r, \-rx, \-ry) set the resolution of the image output formats. The image dimensions will depend on the PDF page @@ -72,6 +74,9 @@ Generates a PNG file(s) .BI \-jpeg Generates a JPEG file(s) .TP +.BI \-tiff +Generates a TIFF file(s) +.TP .BI \-pdf Generates a PDF file .TP @@ -114,17 +119,17 @@ Specifies the Y resolution, in pixels per inch of image files (or rasterized reg .BI \-scale-to " number" Scales the long side of each page (width for landscape pages, height for portrait pages) to fit in scale-to pixels. The size of the short -side will be determined by the aspect ratio of the page (PNG/JPEG only). +side will be determined by the aspect ratio of the page (PNG/JPEG/TIFF only). .TP .BI \-scale-to-x " number" Scales each page horizontally to fit in scale-to-x pixels. If scale-to-y is set to -1, the vertical size will determined by the -aspect ratio of the page (PNG/JPEG only). +aspect ratio of the page (PNG/JPEG/TIFF only). .TP .BI \-scale-to-y " number" Scales each page vertically to fit in scale-to-y pixels. If scale-to-x is set to -1, the horizontal size will determined by the aspect ratio -of the page (PNG/JPEG only). +of the page (PNG/JPEG/TIFF only). .TP .BI \-x " number" Specifies the x-coordinate of the crop area top left corner in pixels (image output) or points (vector output) @@ -145,13 +150,13 @@ Specifies the size of crop square in pixels (image output) or points (vector out Uses the crop box rather than media box when generating the files .TP .B \-mono -Generate a monochrome file (PNG only). +Generate a monochrome file (PNG and TIFF only). .TP .B \-gray -Generate a grayscale file (PNG and JPEG only). +Generate a grayscale file (PNG, JPEG, and TIFF only). .TP .B \-transp -Use a transparent page color instead of white (PNG only). +Use a transparent page color instead of white (PNG and TIFF only). .TP .BI \-icc " icc-file" Use the specified ICC file as the output profile (PNG only). The profile will be embedded in the PNG file. diff --git a/utils/pdftocairo.cc b/utils/pdftocairo.cc index 8d13e316..192d2957 100644 --- a/utils/pdftocairo.cc +++ b/utils/pdftocairo.cc @@ -45,6 +45,7 @@ #include "goo/ImgWriter.h" #include "goo/JpegWriter.h" #include "goo/PNGWriter.h" +#include "goo/TiffWriter.h" #include "GlobalParams.h" #include "Object.h" #include "PDFDoc.h" @@ -75,6 +76,7 @@ static GBool ps = gFalse; static GBool eps = gFalse; static GBool pdf = gFalse; static GBool svg = gFalse; +static GBool tiff = gFalse; static int firstPage = 1; static int lastPage = 0; @@ -109,6 +111,7 @@ static GBool expand = gFalse; static GBool noShrink = gFalse; static GBool noCenter = gFalse; static GBool duplex = gFalse; +static char tiffCompressionStr[16] = ""; static char ownerPassword[33] = ""; static char userPassword[33] = ""; @@ -125,6 +128,12 @@ static const ArgDesc argDesc[] = { {"-jpeg", argFlag, &jpeg, 0, "generate a JPEG file"}, #endif +#if ENABLE_LIBTIFF + {"-tiff", argFlag, &tiff, 0, + "generate a TIFF file"}, + {"-tiffcompression", argString, tiffCompressionStr, sizeof(tiffCompressionStr), + "set TIFF compression: none, packbits, jpeg, lzw, deflate"}, +#endif #if CAIRO_HAS_PS_SURFACE {"-ps", argFlag, &ps, 0, "generate PostScript file"}, @@ -284,9 +293,21 @@ void writePageImage(GooString *filename) } else if (jpeg) { #if ENABLE_LIBJPEG if (gray) - writer = new JpegWriter(JCS_GRAYSCALE); + writer = new JpegWriter(JpegWriter::GRAY); else - writer = new JpegWriter(JCS_RGB); + writer = new JpegWriter(JpegWriter::RGB); +#endif + } else if (tiff) { +#if ENABLE_LIBTIFF + if (transp) + writer = new TiffWriter(TiffWriter::RGBA_PREMULTIPLIED); + else if (gray) + writer = new TiffWriter(TiffWriter::GRAY); + else if (mono) + writer = new TiffWriter(TiffWriter::MONOCHROME); + else + writer = new TiffWriter(TiffWriter::RGB); + static_cast<TiffWriter*>(writer)->setCompressionString(tiffCompressionStr); #endif } if (!writer) @@ -316,21 +337,30 @@ void writePageImage(GooString *filename) for (int y = 0; y < height; y++ ) { uint32_t *pixel = (uint32_t *) (data + y*stride); unsigned char *rowp = row; + int bit = 7; for (int x = 0; x < width; x++, pixel++) { if (transp) { + if (tiff) { + // RGBA premultipled format + *rowp++ = (*pixel & 0xff0000) >> 16; + *rowp++ = (*pixel & 0x00ff00) >> 8; + *rowp++ = (*pixel & 0x0000ff) >> 0; + *rowp++ = (*pixel & 0xff000000) >> 24; + } else { // unpremultiply into RGBA format - uint8_t a; - a = (*pixel & 0xff000000) >> 24; - if (a == 0) { - *rowp++ = 0; - *rowp++ = 0; - *rowp++ = 0; - } else { - *rowp++ = (((*pixel & 0xff0000) >> 16) * 255 + a / 2) / a; - *rowp++ = (((*pixel & 0x00ff00) >> 8) * 255 + a / 2) / a; - *rowp++ = (((*pixel & 0x0000ff) >> 0) * 255 + a / 2) / a; - } - *rowp++ = a; + uint8_t a; + a = (*pixel & 0xff000000) >> 24; + if (a == 0) { + *rowp++ = 0; + *rowp++ = 0; + *rowp++ = 0; + } else { + *rowp++ = (((*pixel & 0xff0000) >> 16) * 255 + a / 2) / a; + *rowp++ = (((*pixel & 0x00ff00) >> 8) * 255 + a / 2) / a; + *rowp++ = (((*pixel & 0x0000ff) >> 0) * 255 + a / 2) / a; + } + *rowp++ = a; + } } else if (gray || mono) { // convert to gray // The PDF Reference specifies the DeviceRGB to DeviceGray conversion as @@ -340,7 +370,19 @@ void writePageImage(GooString *filename) int b = (*pixel & 0x000000ff) >> 0; // an arbitrary integer approximation of .3*r + .59*g + .11*b int y = (r*19661+g*38666+b*7209 + 32829)>>16; - *rowp++ = y; + if (tiff && mono) { + if (bit == 7) + *rowp = 0; + if (y > 127) + *rowp |= (1 << bit); + bit--; + if (bit < 0) { + bit = 7; + rowp++; + } + } else { + *rowp++ = y; + } } else { // copy into RGB format *rowp++ = (*pixel & 0x00ff0000) >> 16; @@ -630,6 +672,8 @@ static GooString *getImageFileName(GooString *outputFileName, int numDigits, int imageName->append(".png"); else if (jpeg) imageName->append(".jpg"); + else if (tiff) + imageName->append(".tif"); return imageName; } @@ -702,7 +746,7 @@ static GooString *getOutputFileName(GooString *fileName, GooString *outputName) static void checkInvalidPrintOption(GBool option, const char *option_name) { if (option) { - fprintf(stderr, "Error: %s may only be used with the -png or -jpeg output options.\n", option_name); + fprintf(stderr, "Error: %s may only be used with the -png, -jpeg, or -tiff output options.\n", option_name); exit(99); } } @@ -752,6 +796,7 @@ int main(int argc, char *argv[]) { num_outputs = (png ? 1 : 0) + (jpeg ? 1 : 0) + + (tiff ? 1 : 0) + (ps ? 1 : 0) + (eps ? 1 : 0) + (pdf ? 1 : 0) + @@ -764,7 +809,7 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Error: use only one of the output format options (-png, -jpeg, -ps, -eps, -pdf, -svg).\n"); exit(99); } - if (png || jpeg) + if (png || jpeg || tiff) printing = gFalse; else printing = gTrue; @@ -794,8 +839,8 @@ int main(int argc, char *argv[]) { exit(99); } - if (transp && !png) { - fprintf(stderr, "Error: -transp may only be used with png output.\n"); + if (transp && !(png || tiff)) { + fprintf(stderr, "Error: -transp may only be used with png or tiff output.\n"); exit(99); } @@ -804,8 +849,13 @@ int main(int argc, char *argv[]) { exit(99); } - if (mono && !png) { - fprintf(stderr, "Error: -mono may only be used with png output.\n"); + if (mono && !(png || tiff)) { + fprintf(stderr, "Error: -mono may only be used with png or tiff output.\n"); + exit(99); + } + + if (strlen(tiffCompressionStr) > 0 && !tiff) { + fprintf(stderr, "Error: -tiffcompression may only be used with tiff output.\n"); exit(99); } diff --git a/utils/pdftohtml.1 b/utils/pdftohtml.1 index 44137e4d..f08fccb8 100644 --- a/utils/pdftohtml.1 +++ b/utils/pdftohtml.1 @@ -70,13 +70,9 @@ user password (for encrypted files) .B \-hidden force hidden text extraction .TP -.B \-dev -output device name for Ghostscript (png16m, jpeg etc). -Unless this option is specified, Splash will be used -.TP -.B \-fmt +3.B \-fmt image file format for Splash output (png or jpg). -If complex is selected, but neither \-fmt or \-dev are specified, +If complex is selected, but \-fmt is not specified, \-fmt png will be assumed .TP .B \-nomerge @@ -89,6 +85,9 @@ override document DRM settings adjust the word break threshold percent. Default is 10. Word break occurs when distance between two adjacent characters is greater than this percent of character height. +.TP +.B \-fontfullname +outputs the font name without any substitutions. .SH AUTHOR diff --git a/utils/pdftohtml.cc b/utils/pdftohtml.cc index d6475b01..97372be1 100644 --- a/utils/pdftohtml.cc +++ b/utils/pdftohtml.cc @@ -21,6 +21,7 @@ // Copyright (C) 2011 Steven Murdoch <Steven.Murdoch@cl.cam.ac.uk> // Copyright (C) 2012 Igor Slepchin <igor.redhat@gmail.com> // Copyright (C) 2012 Ihar Filipau <thephilips@gmail.com> +// Copyright (C) 2012 Luis Parravicini <lparravi@gmail.com> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -62,10 +63,6 @@ #include "DateInfo.h" #include "goo/gfile.h" -#ifndef GHOSTSCRIPT -# define GHOSTSCRIPT "gs" -#endif - static int firstPage = 1; static int lastPage = 0; static GBool rawOrder = gTrue; @@ -75,7 +72,6 @@ GBool printHtml = gFalse; GBool complexMode=gFalse; GBool singleHtml=gFalse; // singleHtml GBool ignore=gFalse; -static GBool useSplash=gTrue; static char extension[5]="png"; static double scale=1.5; GBool noframes=gFalse; @@ -87,9 +83,9 @@ double wordBreakThreshold=10; // 10%, below converted into a coefficient - 0.1 GBool showHidden = gFalse; GBool noMerge = gFalse; +GBool fontFullName = gFalse; static char ownerPassword[33] = ""; static char userPassword[33] = ""; -static char gsDevice[33] = "none"; static GBool printVersion = gFalse; static GooString* getInfoString(Dict *infoDict, const char *key); @@ -132,8 +128,6 @@ static const ArgDesc argDesc[] = { "do not merge paragraphs"}, {"-enc", argString, textEncName, sizeof(textEncName), "output text encoding name"}, - {"-dev", argString, gsDevice, sizeof(gsDevice), - "output device name for Ghostscript (png16m, jpeg etc)"}, {"-fmt", argString, extension, sizeof(extension), "image file format for Splash output (png or jpg)"}, {"-v", argFlag, &printVersion, 0, @@ -146,6 +140,8 @@ static const ArgDesc argDesc[] = { "override document DRM settings"}, {"-wbt", argFP, &wordBreakThreshold, 0, "word break threshold (default 10 percent)"}, + {"-fontfullname", argFlag, &fontFullName, 0, + "outputs font full name"}, {NULL} }; @@ -181,18 +177,15 @@ int main(int argc, char *argv[]) { GooString *docTitle = NULL; GooString *author = NULL, *keywords = NULL, *subject = NULL, *date = NULL; GooString *htmlFileName = NULL; - GooString *psFileName = NULL; HtmlOutputDev *htmlOut = NULL; #ifdef HAVE_SPLASH SplashOutputDev *splashOut = NULL; #endif - PSOutputDev *psOut = NULL; GBool doOutline; GBool ok; char *p; GooString *ownerPW, *userPW; Object info; - const char * extsList[] = {"png", "jpeg", "bmp", "pcx", "tiff", "pbm", NULL}; // parse args ok = parseArgs(argDesc, &argc, argv); @@ -344,36 +337,6 @@ int main(int argc, char *argv[]) { info.free(); if( !docTitle ) docTitle = new GooString(htmlFileName); - if( strcmp("none", gsDevice) ) { - useSplash = gFalse; - /* determine extensions of output background images */ - int i; - for(i = 0; extsList[i]; i++) - { - if( strstr(gsDevice, extsList[i]) != (char *) NULL ) - { - strncpy(extension, extsList[i], sizeof(extension)); - break; - } - } - } - -#ifndef HAVE_SPLASH - if( useSplash ) { - fprintf(stderr, "You are trying to use the -fmt option but your pdftohtml was built without support for it. Please use the -dev option\n"); - delete docTitle; - delete author; - delete keywords; - delete subject; - delete date; - delete htmlFileName; - delete globalParams; - delete fileName; - delete doc; - return -1; - } -#endif - if (!singleHtml) rawOrder = complexMode; // todo: figure out what exactly rawOrder do :) else @@ -421,87 +384,43 @@ int main(int argc, char *argv[]) { } if ((complexMode || singleHtml) && !xml && !ignore) { - if(useSplash) { #ifdef HAVE_SPLASH - GooString *imgFileName = NULL; - // White paper color - SplashColor color; - color[0] = color[1] = color[2] = 255; - // If the user specified "jpg" use JPEG, otherwise PNG - SplashImageFileFormat format = strcmp(extension, "jpg") ? - splashFormatPng : splashFormatJpeg; - - splashOut = new SplashOutputDevNoText(splashModeRGB8, 4, gFalse, color); - splashOut->startDoc(doc); - - for (int pg = firstPage; pg <= lastPage; ++pg) { - doc->displayPage(splashOut, pg, - 72 * scale, 72 * scale, - 0, gTrue, gFalse, gFalse); - SplashBitmap *bitmap = splashOut->getBitmap(); - - imgFileName = GooString::format("{0:s}{1:03d}.{2:s}", - htmlFileName->getCString(), pg, extension); - - bitmap->writeImgFile(format, imgFileName->getCString(), - 72 * scale, 72 * scale); - - delete imgFileName; - } + GooString *imgFileName = NULL; + // White paper color + SplashColor color; + color[0] = color[1] = color[2] = 255; + // If the user specified "jpg" use JPEG, otherwise PNG + SplashImageFileFormat format = strcmp(extension, "jpg") ? + splashFormatPng : splashFormatJpeg; + + splashOut = new SplashOutputDevNoText(splashModeRGB8, 4, gFalse, color); + splashOut->startDoc(doc); + + for (int pg = firstPage; pg <= lastPage; ++pg) { + doc->displayPage(splashOut, pg, + 72 * scale, 72 * scale, + 0, gTrue, gFalse, gFalse); + SplashBitmap *bitmap = splashOut->getBitmap(); + + imgFileName = GooString::format("{0:s}{1:03d}.{2:s}", + htmlFileName->getCString(), pg, extension); + + bitmap->writeImgFile(format, imgFileName->getCString(), + 72 * scale, 72 * scale); + + delete imgFileName; + } - delete splashOut; + delete splashOut; +#else + fprintf(stderr, "Your pdftohtml was built without splash backend support. It is needed for the option you want to use.\n"); + delete htmlOut; + delete htmlFileName; + delete globalParams; + delete fileName; + delete doc; + return -1; #endif - } else { - int h=xoutRound(htmlOut->getPageHeight()/scale); - int w=xoutRound(htmlOut->getPageWidth()/scale); - //int h=xoutRound(doc->getPageHeight(1)/scale); - //int w=xoutRound(doc->getPageWidth(1)/scale); - - psFileName = new GooString(htmlFileName->getCString()); - psFileName->append(".ps"); - - psOut = new PSOutputDev(psFileName->getCString(), doc, - NULL, firstPage, lastPage, psModePS, w, h); - psOut->setDisplayText(gFalse); - doc->displayPages(psOut, firstPage, lastPage, 72, 72, 0, - gTrue, gFalse, gFalse); - delete psOut; - - /*sprintf(buf, "%s -sDEVICE=png16m -dBATCH -dNOPROMPT -dNOPAUSE -r%d -sOutputFile=%s%%03d.png -g%dx%d -q %s", GHOSTSCRIPT, resolution, htmlFileName->getCString(), w, h, - psFileName->getCString());*/ - - GooString *gsCmd = new GooString(GHOSTSCRIPT); - GooString *tw, *th, *sc; - gsCmd->append(" -sDEVICE="); - gsCmd->append(gsDevice); - gsCmd->append(" -dBATCH -dNOPROMPT -dNOPAUSE -r"); - sc = GooString::fromInt(static_cast<int>(72*scale)); - gsCmd->append(sc); - gsCmd->append(" -sOutputFile="); - gsCmd->append("\""); - gsCmd->append(htmlFileName); - gsCmd->append("%03d."); - gsCmd->append(extension); - gsCmd->append("\" -g"); - tw = GooString::fromInt(static_cast<int>(scale*w)); - gsCmd->append(tw); - gsCmd->append("x"); - th = GooString::fromInt(static_cast<int>(scale*h)); - gsCmd->append(th); - gsCmd->append(" -q \""); - gsCmd->append(psFileName); - gsCmd->append("\""); - // printf("running: %s\n", gsCmd->getCString()); - if( !executeCommand(gsCmd->getCString()) && !errQuiet) { - error(errIO, -1, "Failed to launch Ghostscript!\n"); - } - unlink(psFileName->getCString()); - delete tw; - delete th; - delete sc; - delete gsCmd; - delete psFileName; - } } delete htmlOut; diff --git a/utils/pdftoppm.cc b/utils/pdftoppm.cc index 04a0dfba..cebb12a4 100644 --- a/utils/pdftoppm.cc +++ b/utils/pdftoppm.cc @@ -23,7 +23,7 @@ // Copyright (C) 2010 Hib Eris <hib@hiberis.nl> // Copyright (C) 2010 Jonathan Liu <net147@gmail.com> // Copyright (C) 2010 William Bader <williambader@hotmail.com> -// Copyright (C) 2011 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2011, 2012 Thomas Freitag <Thomas.Freitag@alfa.de> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -353,10 +353,8 @@ int main(int argc, char *argv[]) { #if SPLASH_CMYK if (jpegcmyk || overprint) { globalParams->setOverprintPreview(gTrue); - paperColor[0] = 0; - paperColor[1] = 0; - paperColor[2] = 0; - paperColor[3] = 0; + for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) + paperColor[cp] = 0; } else #endif { @@ -367,7 +365,7 @@ int main(int argc, char *argv[]) { splashOut = new SplashOutputDev(mono ? splashModeMono1 : gray ? splashModeMono8 : #if SPLASH_CMYK - (jpegcmyk || overprint) ? splashModeCMYK8 : + (jpegcmyk || overprint) ? splashModeDeviceN8 : #endif splashModeRGB8, 4, gFalse, paperColor); diff --git a/utils/pdfunite.cc b/utils/pdfunite.cc index 212f89be..79d05f04 100644 --- a/utils/pdfunite.cc +++ b/utils/pdfunite.cc @@ -4,9 +4,10 @@ // // This file is licensed under the GPLv2 or later // -// Copyright (C) 2011 Thomas Freitag <Thomas.Freitag@alfa.de> +// Copyright (C) 2011, 2012 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2012 Arseny Solokha <asolokha@gmx.com> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> +// Copyright (C) 2012 Albert Astals Cid <aacid@kde.org> // //======================================================================== #include <PDFDoc.h> @@ -56,7 +57,8 @@ int main (int argc, char *argv[]) int exitCode; exitCode = 99; - if (argc <= 3 || printVersion || printHelp) { + const GBool ok = parseArgs (argDesc, &argc, argv); + if (!ok || argc <= 3 || printVersion || printHelp) { fprintf(stderr, "pdfunite version %s\n", PACKAGE_VERSION); fprintf(stderr, "%s\n", popplerCopyright); fprintf(stderr, "%s\n", xpdfCopyright); @@ -120,7 +122,7 @@ int main (int argc, char *argv[]) Dict *pageDict = page.getDict(); docs[i]->markPageObjects(pageDict, yRef, countRef, numOffset); } - objectsCount += docs[i]->writePageObjects(outStr, yRef, numOffset); + objectsCount += docs[i]->writePageObjects(outStr, yRef, numOffset, gTrue); numOffset = yRef->getNumObjects() + 1; } @@ -154,7 +156,7 @@ int main (int argc, char *argv[]) outStr->printf("/Parent %d 0 R", rootNum + 1); } else { outStr->printf("/%s ", key); - PDFDoc::writeObject(&value, NULL, outStr, yRef, offsets[i]); + PDFDoc::writeObject(&value, outStr, yRef, offsets[i], NULL, cryptRC4, 0, 0, 0); } value.free(); } |