summaryrefslogtreecommitdiff
path: root/Build/source/libs/xpdf/xpdf-src/xpdf/pdftohtml.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/xpdf/xpdf-src/xpdf/pdftohtml.cc')
-rw-r--r--Build/source/libs/xpdf/xpdf-src/xpdf/pdftohtml.cc88
1 files changed, 64 insertions, 24 deletions
diff --git a/Build/source/libs/xpdf/xpdf-src/xpdf/pdftohtml.cc b/Build/source/libs/xpdf/xpdf-src/xpdf/pdftohtml.cc
index af8fe93fbd5..4c98afed50c 100644
--- a/Build/source/libs/xpdf/xpdf-src/xpdf/pdftohtml.cc
+++ b/Build/source/libs/xpdf/xpdf-src/xpdf/pdftohtml.cc
@@ -31,48 +31,66 @@ static int firstPage = 1;
static int lastPage = 0;
static double zoom = 1;
static int resolution = 150;
+static double vStretch = 1;
+static GBool embedBackground = gFalse;
static GBool noFonts = gFalse;
+static GBool embedFonts = gFalse;
static GBool skipInvisible = gFalse;
static GBool allInvisible = gFalse;
+static GBool formFields = gFalse;
+static GBool tableMode = gFalse;
static char ownerPassword[33] = "\001";
static char userPassword[33] = "\001";
+static GBool verbose = gFalse;
static GBool quiet = gFalse;
static char cfgFileName[256] = "";
static GBool printVersion = gFalse;
static GBool printHelp = gFalse;
static ArgDesc argDesc[] = {
- {"-f", argInt, &firstPage, 0,
+ {"-f", argInt, &firstPage, 0,
"first page to convert"},
- {"-l", argInt, &lastPage, 0,
+ {"-l", argInt, &lastPage, 0,
"last page to convert"},
- {"-z", argFP, &zoom, 0,
+ {"-z", argFP, &zoom, 0,
"initial zoom level (1.0 means 72dpi)"},
- {"-r", argInt, &resolution, 0,
+ {"-r", argInt, &resolution, 0,
"resolution, in DPI (default is 150)"},
- {"-nofonts", argFlag, &noFonts, 0,
+ {"-vstretch", argFP, &vStretch, 0,
+ "vertical stretch factor (1.0 means no stretching)"},
+ {"-embedbackground", argFlag, &embedBackground, 0,
+ "embed the background image as base64-encoded data" },
+ {"-nofonts", argFlag, &noFonts, 0,
"do not extract embedded fonts"},
- {"-skipinvisible", argFlag, &skipInvisible, 0,
+ {"-embedfonts", argFlag, &embedFonts, 0,
+ "embed the fonts as base64-encoded data" },
+ {"-skipinvisible", argFlag, &skipInvisible, 0,
"do not draw invisible text"},
- {"-allinvisible", argFlag, &allInvisible, 0,
+ {"-allinvisible", argFlag, &allInvisible, 0,
"treat all text as invisible"},
- {"-opw", argString, ownerPassword, sizeof(ownerPassword),
+ {"-formfields", argFlag, &formFields, 0,
+ "convert form fields to HTML"},
+ {"-table", argFlag, &tableMode, 0,
+ "use table mode for text extraction"},
+ {"-opw", argString, ownerPassword, sizeof(ownerPassword),
"owner password (for encrypted files)"},
- {"-upw", argString, userPassword, sizeof(userPassword),
+ {"-upw", argString, userPassword, sizeof(userPassword),
"user password (for encrypted files)"},
- {"-q", argFlag, &quiet, 0,
+ {"-verbose", argFlag, &verbose, 0,
+ "print per-page status information"},
+ {"-q", argFlag, &quiet, 0,
"don't print any messages or errors"},
- {"-cfg", argString, cfgFileName, sizeof(cfgFileName),
+ {"-cfg", argString, cfgFileName, sizeof(cfgFileName),
"configuration file to use in place of .xpdfrc"},
- {"-v", argFlag, &printVersion, 0,
+ {"-v", argFlag, &printVersion, 0,
"print copyright and version info"},
- {"-h", argFlag, &printHelp, 0,
+ {"-h", argFlag, &printHelp, 0,
"print usage information"},
- {"-help", argFlag, &printHelp, 0,
+ {"-help", argFlag, &printHelp, 0,
"print usage information"},
- {"--help", argFlag, &printHelp, 0,
+ {"--help", argFlag, &printHelp, 0,
"print usage information"},
- {"-?", argFlag, &printHelp, 0,
+ {"-?", argFlag, &printHelp, 0,
"print usage information"},
{NULL}
};
@@ -111,7 +129,14 @@ int main(int argc, char *argv[]) {
htmlDir = argv[2];
// read config file
+ if (cfgFileName[0] && !pathIsFile(cfgFileName)) {
+ error(errConfig, -1, "Config file '{0:s}' doesn't exist or isn't a file",
+ cfgFileName);
+ }
globalParams = new GlobalParams(cfgFileName);
+ if (verbose) {
+ globalParams->setPrintStatusInfo(verbose);
+ }
if (quiet) {
globalParams->setErrQuiet(quiet);
}
@@ -166,19 +191,28 @@ int main(int argc, char *argv[]) {
}
// set up the HTMLGen object
- htmlGen = new HTMLGen(resolution);
+ htmlGen = new HTMLGen(resolution, tableMode);
if (!htmlGen->isOk()) {
exitCode = 99;
goto err1;
}
htmlGen->setZoom(zoom);
+ htmlGen->setVStretch(vStretch);
htmlGen->setDrawInvisibleText(!skipInvisible);
htmlGen->setAllTextInvisible(allInvisible);
+ htmlGen->setEmbedBackgroundImage(embedBackground);
htmlGen->setExtractFontFiles(!noFonts);
+ htmlGen->setEmbedFonts(embedFonts);
+ htmlGen->setConvertFormFields(formFields);
htmlGen->startDoc(doc);
// convert the pages
for (pg = firstPage; pg <= lastPage; ++pg) {
+ if (globalParams->getPrintStatusInfo()) {
+ fflush(stderr);
+ printf("[processing page %d]\n", pg);
+ fflush(stdout);
+ }
htmlFileName = GString::format("{0:s}/page{1:d}.html", htmlDir, pg);
pngFileName = GString::format("{0:s}/page{1:d}.png", htmlDir, pg);
if (!(htmlFile = openFile(htmlFileName->getCString(), "wb"))) {
@@ -187,12 +221,16 @@ int main(int argc, char *argv[]) {
delete pngFileName;
goto err2;
}
- if (!(pngFile = openFile(pngFileName->getCString(), "wb"))) {
- error(errIO, -1, "Couldn't open PNG file '{0:t}'", pngFileName);
- fclose(htmlFile);
- delete htmlFileName;
- delete pngFileName;
- goto err2;
+ if (embedBackground) {
+ pngFile = NULL;
+ } else {
+ if (!(pngFile = openFile(pngFileName->getCString(), "wb"))) {
+ error(errIO, -1, "Couldn't open PNG file '{0:t}'", pngFileName);
+ fclose(htmlFile);
+ delete htmlFileName;
+ delete pngFileName;
+ goto err2;
+ }
}
pngURL = GString::format("page{0:d}.png", pg);
err = htmlGen->convertPage(pg, pngURL->getCString(), htmlDir,
@@ -200,7 +238,9 @@ int main(int argc, char *argv[]) {
&writeToFile, pngFile);
delete pngURL;
fclose(htmlFile);
- fclose(pngFile);
+ if (!embedBackground) {
+ fclose(pngFile);
+ }
delete htmlFileName;
delete pngFileName;
if (err != errNone) {