15#include "GlobalParams.h"
24static char t1libControlStr[16] = "";
25static char freetypeControlStr[16] = "";
26static char psFileArg[256];
27static char paperSize[15] = "";
28static int paperWidth = 0;
29static int paperHeight = 0;
30static GBool level1 = gFalse;
31static char textEncName[128] = "";
32static char textEOL[16] = "";
33static char ownerPassword[33] = "";
34static char userPassword[33] = "";
35static GBool fullScreen = gFalse;
36static char remoteName[100] = "xpdf_";
37static GBool doRemoteRaise = gFalse;
38static GBool doRemoteQuit = gFalse;
39static GBool printCommands = gFalse;
40static GBool quiet = gFalse;
41static char cfgFileName[256] = "";
42static GBool printVersion = gFalse;
43static GBool printHelp = gFalse;
45static ArgDesc argDesc[] = {
46 { "-g", argStringDummy, NULL, 0,
47 "initial window geometry"},
48 { "-geometry", argStringDummy, NULL, 0,
49 "initial window geometry"},
50 { "-title", argStringDummy, NULL, 0,
52 { "-cmap", argFlagDummy, NULL, 0,
53 "install a private colormap"},
54 { "-rgb", argIntDummy, NULL, 0,
55 "biggest RGB cube to allocate (default is 5)"},
56 { "-rv", argFlagDummy, NULL, 0,
58 { "-papercolor", argStringDummy, NULL, 0,
59 "color of paper background"},
60 { "-z", argStringDummy, NULL, 0,
61 "initial zoom level (-5..5, page, width)"},
63 { "-t1lib", argString, t1libControlStr, sizeof(t1libControlStr),
64 "t1lib font rasterizer control: none, plain, low, high"},
66#if HAVE_FREETYPE_FREETYPE_H | HAVE_FREETYPE_H
67 { "-freetype", argString, freetypeControlStr, sizeof(freetypeControlStr),
68 "FreeType font rasterizer control: none, plain, low, high"},
70 { "-ps", argString, psFileArg, sizeof(psFileArg),
71 "default PostScript file name or command"},
72 { "-paper", argString, paperSize, sizeof(paperSize),
73 "paper size (letter, legal, A4, A3)"},
74 { "-paperw", argInt, &paperWidth, 0,
75 "paper width, in points"},
76 { "-paperh", argInt, &paperHeight, 0,
77 "paper height, in points"},
78 { "-level1", argFlag, &level1, 0,
79 "generate Level 1 PostScript"},
80 { "-enc", argString, textEncName, sizeof(textEncName),
81 "output text encoding name"},
82 { "-eol", argString, textEOL, sizeof(textEOL),
83 "output end-of-line convention (unix, dos, or mac)"},
84 { "-opw", argString, ownerPassword, sizeof(ownerPassword),
85 "owner password (for encrypted files)"},
86 { "-upw", argString, userPassword, sizeof(userPassword),
87 "user password (for encrypted files)"},
88 { "-fullscreen", argFlag, &fullScreen, 0,
89 "run in full-screen (presentation) mode"},
90 { "-remote", argString, remoteName + 5, sizeof(remoteName) - 5,
91 "start/contact xpdf remote server with specified name"},
92 { "-raise", argFlag, &doRemoteRaise, 0,
93 "raise xpdf remote server window (with -remote only)"},
94 { "-quit", argFlag, &doRemoteQuit, 0,
95 "kill xpdf remote server (with -remote only)"},
96 { "-cmd", argFlag, &printCommands, 0,
97 "print commands as they're executed"},
98 { "-q", argFlag, &quiet, 0,
99 "don't print any messages or errors"},
100 { "-cfg", argString, cfgFileName, sizeof(cfgFileName),
101 "configuration file to use in place of .xpdfrc"},
102 { "-v", argFlag, &printVersion, 0,
103 "print copyright and version info"},
104 { "-h", argFlag, &printHelp, 0,
105 "print usage information"},
106 { "-help", argFlag, &printHelp, 0,
107 "print usage information"},
108 { "--help", argFlag, &printHelp, 0,
109 "print usage information"},
110 { "-?", argFlag, &printHelp, 0,
111 "print usage information"},
117int main( int argc, char *argv[]) {
122 GString *userPasswordStr, *ownerPasswordStr;
127 userPasswordStr = ownerPasswordStr = NULL;
130 ok = parseArgs(argDesc, &argc, argv);
133 globalParams = new GlobalParams(cfgFileName);
135 globalParams->setPSFile(psFileArg);
138 if (!globalParams->setPSPaperSize(paperSize)) {
139 fprintf(stderr, "Invalid paper size\n");
143 globalParams->setPSPaperWidth(paperWidth);
146 globalParams->setPSPaperHeight(paperHeight);
150 globalParams->setPSLevel(psLevel1);
152 if (textEncName[0]) {
153 globalParams->setTextEncoding(textEncName);
156 if (!globalParams->setTextEOL(textEOL)) {
157 fprintf(stderr, "Bad '-eol' value on command line\n");
160 if (t1libControlStr[0]) {
161 if (!globalParams->setT1libControl(t1libControlStr)) {
162 fprintf(stderr, "Bad '-t1lib' value on command line\n");
165 if (freetypeControlStr[0]) {
166 if (!globalParams->setFreeTypeControl(freetypeControlStr)) {
167 fprintf(stderr, "Bad '-freetype' value on command line\n");
171 globalParams->setPrintCommands(printCommands);
174 globalParams->setErrQuiet(quiet);
178 app = new XPDFApp(&argc, argv);
182 if (app->getInitialZoom()) {
183 globalParams->setInitialZoom(app->getInitialZoom()->getCString());
188 ok = ok && remoteName[5] && !doRemoteQuit && argc >= 1 && argc <= 3;
189 } else if (doRemoteQuit) {
190 ok = ok && remoteName[5] && argc == 1;
192 ok = ok && argc >= 1 && argc <= 3;
194 if (!ok || printVersion || printHelp) {
195 fprintf(stderr, "xpdf version %s\n", xpdfVersion);
196 fprintf(stderr, "%s\n", xpdfCopyright);
198 printUsage( "xpdf", "[<PDF-file> [<page> | +<dest>]]", argDesc);
204 fileName = new GString(argv[1]);
211 if (argv[2][0] == '+') {
212 destName = new GString(&argv[2][1]);
220 app->setRemoteName(remoteName);
221 if (app->remoteServerRunning()) {
224 app->remoteOpenAtDest(fileName, destName, doRemoteRaise);
226 app->remoteOpen(fileName, pg, doRemoteRaise);
228 } else if (doRemoteRaise) {
230 } else if (doRemoteQuit) {
241 app->setFullScreen(fullScreen);
244 ownerPasswordStr = ownerPassword[0] ? new GString(ownerPassword)
246 userPasswordStr = userPassword[0] ? new GString(userPassword)
251 if (!app->openAtDest(fileName, destName,
252 ownerPasswordStr, userPasswordStr)) {
257 if (!app->open(fileName, pg, ownerPasswordStr, userPasswordStr)) {
268 if (userPasswordStr) {
269 delete userPasswordStr;
271 if (ownerPasswordStr) {
272 delete ownerPasswordStr;
285 Object::memCheck(stderr);
|