[poppler] goo/gfile.cc goo/gfile.h utils/pdftohtml.1 utils/pdftohtml.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Thu May 10 13:25:02 PDT 2012


 goo/gfile.cc       |    8 --
 goo/gfile.h        |    3 -
 utils/pdftohtml.1  |    8 --
 utils/pdftohtml.cc |  149 ++++++++++++-----------------------------------------
 4 files changed, 36 insertions(+), 132 deletions(-)

New commits:
commit ad36d22d1f11339be90403534b921cce120fdbad
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu May 10 22:24:40 2012 +0200

    pdftohtml: Remove the option to invoke gs

diff --git a/goo/gfile.cc b/goo/gfile.cc
index 7522424..7833502 100644
--- a/goo/gfile.cc
+++ b/goo/gfile.cc
@@ -545,14 +545,6 @@ GBool openTempFile(GooString **name, FILE **f, const char *mode) {
 #endif
 }
 
-GBool executeCommand(char *cmd) {
-#ifdef VMS
-  return system(cmd) ? gTrue : gFalse;
-#else
-  return system(cmd) ? gFalse : gTrue;
-#endif
-}
-
 #ifdef WIN32
 GooString *fileNameToUTF8(char *path) {
   GooString *s;
diff --git a/goo/gfile.h b/goo/gfile.h
index d4b9082..34b85f0 100644
--- a/goo/gfile.h
+++ b/goo/gfile.h
@@ -104,9 +104,6 @@ extern time_t getModTime(char *fileName);
 // should be "w" or "wb".  Returns true on success.
 extern GBool openTempFile(GooString **name, FILE **f, const char *mode);
 
-// Execute <command>.  Returns true on success.
-extern GBool executeCommand(char *cmd);
-
 #ifdef WIN32
 // Convert a file name from Latin-1 to UTF-8.
 extern GooString *fileNameToUTF8(char *path);
diff --git a/utils/pdftohtml.1 b/utils/pdftohtml.1
index 44137e4..d565ae6 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 neither \-fmt or are specified,
 \-fmt png will be assumed
 .TP
 .B \-nomerge
diff --git a/utils/pdftohtml.cc b/utils/pdftohtml.cc
index d6475b0..5f7e0d4 100644
--- a/utils/pdftohtml.cc
+++ b/utils/pdftohtml.cc
@@ -75,7 +75,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;
@@ -89,7 +88,6 @@ GBool showHidden = gFalse;
 GBool noMerge = 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 +130,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,
@@ -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;


More information about the poppler mailing list