28#include <config_folders.h>
38int main(
int argc,
char **argv)
43 if (!strcmp(argv[k],
"-f"))
47 for (
int j = k; j < argc; ++j)
50 else if (!strcmp(argv[k],
"-o"))
54 for (
int j = k; j < argc; ++j)
58 else if (!strcmp(argv[k],
"-opw"))
62 for (
int j = k; j < argc; ++j)
65 else if (!strcmp(argv[k],
"-upw"))
69 for (
int j = k; j < argc; ++j)
77 const char* datadir =
nullptr;
82 const std::string execPath = argv[0];
83 const std::size_t filenameStartPos = execPath.find_last_of(
"/\\")+1;
84 const std::string programPath = execPath.substr(0,filenameStartPos);
85 const std::string popplerDataPath = programPath +
"../" LIBO_SHARE_FOLDER
"/xpdfimport/poppler_data";
86 const char* datadir = popplerDataPath.c_str();
90#if POPPLER_CHECK_VERSION(0, 83, 0)
91 globalParams = std::make_unique<GlobalParams>(datadir);
93 globalParams =
new GlobalParams(datadir);
95 globalParams->setErrQuiet(
true);
97 globalParams->setupBaseFonts(
nullptr);
103 if( ! fgets( aPwBuf,
sizeof(aPwBuf)-1, stdin ) )
107 for(
size_t i = 0;
i <
sizeof(aPwBuf);
i++ )
109 if( aPwBuf[
i] ==
'\n' )
118 GooString* pFileName =
new GooString(argv[1]);
119 GooString* pErrFileName =
new GooString(argv[2]);
122 GooString* pOwnerPasswordStr( aPwBuf[0] != 0
123 ?
new GooString( aPwBuf )
127 GooString* pUserPasswordStr( aPwBuf[0] != 0
128 ?
new GooString( aPwBuf )
141#if POPPLER_CHECK_VERSION(22, 6, 0)
142 PDFDoc aDoc( std::make_unique<GooString>(pFileName),
143 std::optional<GooString>(pOwnerPasswordStr),
144 std::optional<GooString>(pUserPasswordStr) );
146 PDFDoc aErrDoc( std::make_unique<GooString>(pErrFileName),
147 std::optional<GooString>(pOwnerPasswordStr),
148 std::optional<GooString>(pUserPasswordStr) );
150 PDFDoc aDoc( pFileName,
154 PDFDoc aErrDoc( pErrFileName,
160 PDFDoc &rDoc = aDoc.isOk()? aDoc: aErrDoc;
163 if (!strcmp(
options,
"SkipImages")) {
168 const int nPages = rDoc.isOk()? rDoc.getNumPages(): 0;
175 for (
int i = 1;
i <= nPages; ++
i)
177 rDoc.displayPage(&aOutDev,
181 0,
true,
true,
true);
182 rDoc.processLinks(&aOutDev,
i);
void setSkipImages(bool bSkipImages)
static void setPageNum(int nNumPages)
#define PDFI_OUTDEV_RESOLUTION
static const char * options
int main(int argc, char **argv)
static const char * outputFile
static const char * userPassword
static const char * ownerPassword