PDFTOTEXT_API int WINAPI fnPDFToText(char* szPDFFilePath,char* szTextFilePath)
{
int argc=5;
char* argv[5];
argv[0]=NULL;
argv[1]=szPDFFilePath;
char pLayout[]="-layout";
argv[2]=pLayout;
char pEnc[]="-enc";
argv[3]=pEnc;
char pGBK[]="GBK";
argv[4]=pGBK;
PDFDoc *doc;
GString *fileName;
GString *textFileName;
GString *ownerPW, *userPW;
TextOutputDev *textOut;
FILE *f;
UnicodeMap *uMap;
Object info;
GBool ok;
char *p;
int exitCode;
exitCode = 99;
// parse args
ok = parseArgs(argDesc, &argc, argv);
if (!ok || argc < 2 || argc > 3 || printVersion || printHelp) {
fprintf(stderr, "pdftotext version %s\n", xpdfVersion);
fprintf(stderr, "%s\n", xpdfCopyright);
if (!printVersion) {
printUsage("pdftotext", "<PDF-file> [<text-file>]", argDesc);
}
exitCode=4;
goto err0;
}
fileName = new GString(argv[1]);
if (fixedPitch) {
physLayout = gTrue;
}
// read config file
globalParams = new GlobalParams(cfgFileName);
if (textEncName[0]) {
globalParams->setTextEncoding(textEncName);
}
if (textEOL[0]) {
if (!globalParams->setTextEOL(textEOL)) {
fprintf(stderr, "Bad '-eol' value on command line\n");
}
}
if (noPageBreaks) {
globalParams->setTextPageBreaks(gFalse);
}
if (quiet) {
globalParams->setErrQuiet(quiet);
}
// get mapping to output encoding
if (!(uMap = globalParams->getTextEncoding())) {
error(errConfig, -1, "Couldn't get text encoding");
delete fileName; www.jingjixx.com/guoji/20210130-1352.html exitCode=5;
goto err1;
}
// open PDF file
if (ownerPassword[0] != '\001') {
ownerPW = new GString(ownerPassword);
} else {
ownerPW = NULL;
}