Commit ad36d22d authored by Albert Astals Cid's avatar Albert Astals Cid

pdftohtml: Remove the option to invoke gs

parent 4114c928
......@@ -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;
......
......@@ -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);
......
......@@ -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
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment