You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CommandLineOptions.java 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. /*
  2. * $Id: CommandLineOptions.java,v 1.22 2003/02/27 10:13:06 jeremias Exp $
  3. * ============================================================================
  4. * The Apache Software License, Version 1.1
  5. * ============================================================================
  6. *
  7. * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without modifica-
  10. * tion, are permitted provided that the following conditions are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. *
  19. * 3. The end-user documentation included with the redistribution, if any, must
  20. * include the following acknowledgment: "This product includes software
  21. * developed by the Apache Software Foundation (http://www.apache.org/)."
  22. * Alternately, this acknowledgment may appear in the software itself, if
  23. * and wherever such third-party acknowledgments normally appear.
  24. *
  25. * 4. The names "FOP" and "Apache Software Foundation" must not be used to
  26. * endorse or promote products derived from this software without prior
  27. * written permission. For written permission, please contact
  28. * apache@apache.org.
  29. *
  30. * 5. Products derived from this software may not be called "Apache", nor may
  31. * "Apache" appear in their name, without prior written permission of the
  32. * Apache Software Foundation.
  33. *
  34. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  35. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  36. * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  37. * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  38. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
  39. * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  40. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  41. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  42. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  43. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44. * ============================================================================
  45. *
  46. * This software consists of voluntary contributions made by many individuals
  47. * on behalf of the Apache Software Foundation and was originally created by
  48. * James Tauber <jtauber@jtauber.com>. For more information on the Apache
  49. * Software Foundation, please see <http://www.apache.org/>.
  50. */
  51. package org.apache.fop.apps;
  52. // java
  53. import java.io.File;
  54. import java.io.FileNotFoundException;
  55. // Avalon
  56. import org.apache.avalon.framework.logger.ConsoleLogger;
  57. import org.apache.avalon.framework.logger.Logger;
  58. /**
  59. * Options parses the commandline arguments
  60. */
  61. public class CommandLineOptions {
  62. /* input / output not set */
  63. private static final int NOT_SET = 0;
  64. /* input: fo file */
  65. private static final int FO_INPUT = 1;
  66. /* input: xml+xsl file */
  67. private static final int XSLT_INPUT = 2;
  68. /* output: pdf file */
  69. private static final int PDF_OUTPUT = 1;
  70. /* output: screen using swing */
  71. private static final int AWT_OUTPUT = 2;
  72. /* output: mif file */
  73. private static final int MIF_OUTPUT = 3;
  74. /* output: sent swing rendered file to printer */
  75. private static final int PRINT_OUTPUT = 4;
  76. /* output: pcl file */
  77. private static final int PCL_OUTPUT = 5;
  78. /* output: postscript file */
  79. private static final int PS_OUTPUT = 6;
  80. /* output: text file */
  81. private static final int TXT_OUTPUT = 7;
  82. /* output: svg file */
  83. private static final int SVG_OUTPUT = 8;
  84. /* output: XML area tree */
  85. private static final int AREA_OUTPUT = 9;
  86. /* output: RTF file */
  87. private static final int RTF_OUTPUT = 10;
  88. /* show configuration information */
  89. private Boolean dumpConfiguration = Boolean.FALSE;
  90. /* suppress any progress information */
  91. private Boolean quiet = Boolean.FALSE;
  92. /* for area tree XML output, only down to block area level */
  93. private Boolean suppressLowLevelAreas = Boolean.FALSE;
  94. /* user configuration file */
  95. private File userConfigFile = null;
  96. /* input fo file */
  97. private File fofile = null;
  98. /* xsltfile (xslt transformation as input) */
  99. private File xsltfile = null;
  100. /* xml file (xslt transformation as input) */
  101. private File xmlfile = null;
  102. /* output file */
  103. private File outfile = null;
  104. /* input mode */
  105. private int inputmode = NOT_SET;
  106. /* output mode */
  107. private int outputmode = NOT_SET;
  108. /* language for user information */
  109. private String language = null;
  110. private java.util.HashMap rendererOptions;
  111. private Logger log;
  112. /**
  113. * Construct a command line option object from command line arguments
  114. * @param args command line parameters
  115. * @throws FOPException for general errors
  116. * @throws FileNotFoundException if an input file wasn't found.
  117. */
  118. public CommandLineOptions(String[] args)
  119. throws FOPException, FileNotFoundException {
  120. log = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
  121. boolean optionsParsed = true;
  122. rendererOptions = new java.util.HashMap();
  123. try {
  124. optionsParsed = parseOptions(args);
  125. if (optionsParsed) {
  126. checkSettings();
  127. }
  128. } catch (FOPException e) {
  129. printUsage();
  130. throw e;
  131. } catch (java.io.FileNotFoundException e) {
  132. printUsage();
  133. throw e;
  134. }
  135. }
  136. /**
  137. * Get the logger.
  138. * @return the logger
  139. */
  140. public Logger getLogger() {
  141. return log;
  142. }
  143. /**
  144. * parses the commandline arguments
  145. * @return true if parse was successful and processing can continue, false
  146. * if processing should stop
  147. * @exception FOPException if there was an error in the format of the options
  148. */
  149. private boolean parseOptions(String args[]) throws FOPException {
  150. for (int i = 0; i < args.length; i++) {
  151. if (args[i].equals("-d") || args[i].equals("--full-error-dump")) {
  152. log = new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG);
  153. } else if (args[i].equals("-x")
  154. || args[i].equals("--dump-config")) {
  155. dumpConfiguration = Boolean.TRUE;
  156. } else if (args[i].equals("-q") || args[i].equals("--quiet")) {
  157. quiet = Boolean.TRUE;
  158. log = new ConsoleLogger(ConsoleLogger.LEVEL_ERROR);
  159. } else if (args[i].equals("-c")) {
  160. if ((i + 1 == args.length)
  161. || (args[i + 1].charAt(0) == '-')) {
  162. throw new FOPException("if you use '-c', you must specify "
  163. + "the name of the configuration file");
  164. } else {
  165. userConfigFile = new File(args[i + 1]);
  166. i++;
  167. }
  168. } else if (args[i].equals("-l")) {
  169. if ((i + 1 == args.length)
  170. || (args[i + 1].charAt(0) == '-')) {
  171. throw new FOPException("if you use '-l', you must specify a language");
  172. } else {
  173. language = args[i + 1];
  174. i++;
  175. }
  176. } else if (args[i].equals("-s")) {
  177. suppressLowLevelAreas = Boolean.TRUE;
  178. } else if (args[i].equals("-fo")) {
  179. inputmode = FO_INPUT;
  180. if ((i + 1 == args.length)
  181. || (args[i + 1].charAt(0) == '-')) {
  182. throw new FOPException("you must specify the fo file for the '-fo' option");
  183. } else {
  184. fofile = new File(args[i + 1]);
  185. i++;
  186. }
  187. } else if (args[i].equals("-xsl")) {
  188. inputmode = XSLT_INPUT;
  189. if ((i + 1 == args.length)
  190. || (args[i + 1].charAt(0) == '-')) {
  191. throw new FOPException("you must specify the stylesheet "
  192. + "file for the '-xsl' option");
  193. } else {
  194. xsltfile = new File(args[i + 1]);
  195. i++;
  196. }
  197. } else if (args[i].equals("-xml")) {
  198. inputmode = XSLT_INPUT;
  199. if ((i + 1 == args.length)
  200. || (args[i + 1].charAt(0) == '-')) {
  201. throw new FOPException("you must specify the input file "
  202. + "for the '-xml' option");
  203. } else {
  204. xmlfile = new File(args[i + 1]);
  205. i++;
  206. }
  207. } else if (args[i].equals("-awt")) {
  208. setOutputMode(AWT_OUTPUT);
  209. } else if (args[i].equals("-pdf")) {
  210. setOutputMode(PDF_OUTPUT);
  211. if ((i + 1 == args.length)
  212. || (args[i + 1].charAt(0) == '-')) {
  213. throw new FOPException("you must specify the pdf output file");
  214. } else {
  215. outfile = new File(args[i + 1]);
  216. i++;
  217. }
  218. } else if (args[i].equals("-mif")) {
  219. setOutputMode(MIF_OUTPUT);
  220. if ((i + 1 == args.length)
  221. || (args[i + 1].charAt(0) == '-')) {
  222. throw new FOPException("you must specify the mif output file");
  223. } else {
  224. outfile = new File(args[i + 1]);
  225. i++;
  226. }
  227. } else if (args[i].equals("-rtf")) {
  228. setOutputMode(RTF_OUTPUT);
  229. if ((i + 1 == args.length)
  230. || (args[i + 1].charAt(0) == '-')) {
  231. throw new FOPException("you must specify the rtf output file");
  232. } else {
  233. outfile = new File(args[i + 1]);
  234. i++;
  235. }
  236. } else if (args[i].equals("-print")) {
  237. setOutputMode(PRINT_OUTPUT);
  238. // show print help
  239. if (i + 1 < args.length) {
  240. if (args[i + 1].equals("help")) {
  241. printUsagePrintOutput();
  242. return false;
  243. }
  244. }
  245. } else if (args[i].equals("-pcl")) {
  246. setOutputMode(PCL_OUTPUT);
  247. if ((i + 1 == args.length)
  248. || (args[i + 1].charAt(0) == '-')) {
  249. throw new FOPException("you must specify the pdf output file");
  250. } else {
  251. outfile = new File(args[i + 1]);
  252. i++;
  253. }
  254. } else if (args[i].equals("-ps")) {
  255. setOutputMode(PS_OUTPUT);
  256. if ((i + 1 == args.length)
  257. || (args[i + 1].charAt(0) == '-')) {
  258. throw new FOPException("you must specify the PostScript output file");
  259. } else {
  260. outfile = new File(args[i + 1]);
  261. i++;
  262. }
  263. } else if (args[i].equals("-txt")) {
  264. setOutputMode(TXT_OUTPUT);
  265. if ((i + 1 == args.length)
  266. || (args[i + 1].charAt(0) == '-')) {
  267. throw new FOPException("you must specify the text output file");
  268. } else {
  269. outfile = new File(args[i + 1]);
  270. i++;
  271. }
  272. } else if (args[i].equals("-svg")) {
  273. setOutputMode(SVG_OUTPUT);
  274. if ((i + 1 == args.length)
  275. || (args[i + 1].charAt(0) == '-')) {
  276. throw new FOPException("you must specify the svg output file");
  277. } else {
  278. outfile = new File(args[i + 1]);
  279. i++;
  280. }
  281. } else if (args[i].charAt(0) != '-') {
  282. if (inputmode == NOT_SET) {
  283. inputmode = FO_INPUT;
  284. fofile = new File(args[i]);
  285. } else if (outputmode == NOT_SET) {
  286. outputmode = PDF_OUTPUT;
  287. outfile = new File(args[i]);
  288. } else {
  289. throw new FOPException("Don't know what to do with "
  290. + args[i]);
  291. }
  292. } else if (args[i].equals("-at")) {
  293. setOutputMode(AREA_OUTPUT);
  294. if ((i + 1 == args.length)
  295. || (args[i + 1].charAt(0) == '-')) {
  296. throw new FOPException("you must specify the area-tree output file");
  297. } else {
  298. outfile = new File(args[i + 1]);
  299. i++;
  300. }
  301. } else {
  302. printUsage();
  303. return false;
  304. }
  305. }
  306. return true;
  307. } // end parseOptions
  308. private void setOutputMode(int mode) throws FOPException {
  309. if (outputmode == NOT_SET) {
  310. outputmode = mode;
  311. } else {
  312. throw new FOPException("you can only set one output method");
  313. }
  314. }
  315. /**
  316. * checks whether all necessary information has been given in a consistent way
  317. */
  318. private void checkSettings() throws FOPException, FileNotFoundException {
  319. if (inputmode == NOT_SET) {
  320. throw new FOPException("No input file specified");
  321. }
  322. if (outputmode == NOT_SET) {
  323. throw new FOPException("No output file specified");
  324. }
  325. if (inputmode == XSLT_INPUT) {
  326. // check whether xml *and* xslt file have been set
  327. if (xmlfile == null) {
  328. throw new FOPException("XML file must be specified for the tranform mode");
  329. }
  330. if (xsltfile == null) {
  331. throw new FOPException("XSLT file must be specified for the tranform mode");
  332. }
  333. // warning if fofile has been set in xslt mode
  334. if (fofile != null) {
  335. log.warn("Can't use fo file with transform mode! Ignoring.\n"
  336. + "Your input is " + "\n xmlfile: "
  337. + xmlfile.getAbsolutePath()
  338. + "\nxsltfile: "
  339. + xsltfile.getAbsolutePath()
  340. + "\n fofile: "
  341. + fofile.getAbsolutePath());
  342. }
  343. if (!xmlfile.exists()) {
  344. throw new FileNotFoundException("xml file "
  345. + xmlfile.getAbsolutePath()
  346. + " not found ");
  347. }
  348. if (!xsltfile.exists()) {
  349. throw new FileNotFoundException("xsl file "
  350. + xsltfile.getAbsolutePath()
  351. + " not found ");
  352. }
  353. } else if (inputmode == FO_INPUT) {
  354. if (xmlfile != null || xsltfile != null) {
  355. log.warn("fo input mode, but xmlfile or xslt file are set:");
  356. log.error("xml file: " + xmlfile.toString());
  357. log.error("xslt file: " + xsltfile.toString());
  358. }
  359. if (!fofile.exists()) {
  360. throw new FileNotFoundException("fo file "
  361. + fofile.getAbsolutePath()
  362. + " not found ");
  363. }
  364. }
  365. } // end checkSettings
  366. /**
  367. * @return the type chosen renderer
  368. * @throws FOPException for invalid output modes
  369. */
  370. public int getRenderer() throws FOPException {
  371. switch (outputmode) {
  372. case NOT_SET:
  373. throw new FOPException("Renderer has not been set!");
  374. case PDF_OUTPUT:
  375. return Driver.RENDER_PDF;
  376. case AWT_OUTPUT:
  377. return Driver.RENDER_AWT;
  378. case MIF_OUTPUT:
  379. return Driver.RENDER_MIF;
  380. case PRINT_OUTPUT:
  381. return Driver.RENDER_PRINT;
  382. case PCL_OUTPUT:
  383. return Driver.RENDER_PCL;
  384. case PS_OUTPUT:
  385. return Driver.RENDER_PS;
  386. case TXT_OUTPUT:
  387. return Driver.RENDER_TXT;
  388. case SVG_OUTPUT:
  389. return Driver.RENDER_SVG;
  390. case AREA_OUTPUT:
  391. rendererOptions.put("fineDetail", isCoarseAreaXml());
  392. return Driver.RENDER_XML;
  393. case RTF_OUTPUT:
  394. return Driver.RENDER_RTF;
  395. default:
  396. throw new FOPException("Invalid Renderer setting!");
  397. }
  398. }
  399. /**
  400. * Get the input handler.
  401. * @return the input handler
  402. */
  403. public InputHandler getInputHandler() {
  404. switch (inputmode) {
  405. case FO_INPUT:
  406. return new FOInputHandler(fofile);
  407. case XSLT_INPUT:
  408. return new XSLTInputHandler(xmlfile, xsltfile);
  409. default:
  410. return new FOInputHandler(fofile);
  411. }
  412. }
  413. /**
  414. * Get the renderer specific options.
  415. * @return hash map with option/value pairs.
  416. */
  417. public java.util.HashMap getRendererOptions() {
  418. return rendererOptions;
  419. }
  420. /**
  421. * Get the starter for the process.
  422. * @return the starter.
  423. * @throws FOPException In case of failure while getting the starter
  424. */
  425. public Starter getStarter() throws FOPException {
  426. Starter starter = null;
  427. switch (outputmode) {
  428. case AWT_OUTPUT:
  429. try {
  430. starter = new AWTStarter(this);
  431. } catch (FOPException e) {
  432. throw e;
  433. } catch (Exception e) {
  434. throw new FOPException("AWTStarter could not be loaded.", e);
  435. }
  436. break;
  437. case PRINT_OUTPUT:
  438. try {
  439. starter = new PrintStarter(this);
  440. } catch (FOPException e) {
  441. throw e;
  442. } catch (Exception e) {
  443. throw new FOPException("PrintStarter could not be loaded.", e);
  444. }
  445. break;
  446. default:
  447. starter = new CommandLineStarter(this);
  448. }
  449. starter.enableLogging(log);
  450. return starter;
  451. }
  452. /**
  453. * Returns the input mode (type of input data, ex. NOT_SET or FO_INPUT)
  454. * @return the input mode
  455. */
  456. public int getInputMode() {
  457. return inputmode;
  458. }
  459. /**
  460. * Returns the output mode (output format, ex. NOT_SET or PDF_OUTPUT)
  461. * @return the output mode
  462. */
  463. public int getOutputMode() {
  464. return outputmode;
  465. }
  466. /**
  467. * Returns the XSL-FO file if set.
  468. * @return the XSL-FO file, null if not set
  469. */
  470. public File getFOFile() {
  471. return fofile;
  472. }
  473. /**
  474. * Returns the input XML file if set.
  475. * @return the input XML file, null if not set
  476. */
  477. public File getXMLFile() {
  478. return xmlfile;
  479. }
  480. /**
  481. * Returns the stylesheet to be used for transformation to XSL-FO.
  482. * @return stylesheet
  483. */
  484. public File getXSLFile() {
  485. return xsltfile;
  486. }
  487. /**
  488. * Returns the output file
  489. * @return the output file
  490. */
  491. public File getOutputFile() {
  492. return outfile;
  493. }
  494. /**
  495. * Returns the user configuration file to be used.
  496. * @return the userconfig.xml file
  497. */
  498. public File getUserConfigFile() {
  499. return userConfigFile;
  500. }
  501. /**
  502. * Returns the default language
  503. * @return the default language
  504. */
  505. public String getLanguage() {
  506. return language;
  507. }
  508. /**
  509. * Indicates if FOP should be silent.
  510. * @return true if should be silent
  511. */
  512. public Boolean isQuiet() {
  513. return quiet;
  514. }
  515. /**
  516. * Indicates if FOP should dump its configuration during runtime.
  517. * @return true if config dump is enabled
  518. */
  519. public Boolean dumpConfiguration() {
  520. return dumpConfiguration;
  521. }
  522. /**
  523. * Indicates whether the XML renderer should generate course area XML
  524. * @return true if coarse area XML is desired
  525. */
  526. public Boolean isCoarseAreaXml() {
  527. return suppressLowLevelAreas;
  528. }
  529. /**
  530. * Returns the input file.
  531. * @return either the fofile or the xmlfile
  532. */
  533. public File getInputFile() {
  534. switch (inputmode) {
  535. case FO_INPUT:
  536. return fofile;
  537. case XSLT_INPUT:
  538. return xmlfile;
  539. default:
  540. return fofile;
  541. }
  542. }
  543. /**
  544. * shows the commandline syntax including a summary of all available options and some examples
  545. */
  546. public static void printUsage() {
  547. System.err.println(
  548. "\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] "
  549. + "[-awt|-pdf|-mif|-rtf|-pcl|-ps|-txt|-at|-print] <outfile>\n"
  550. + " [OPTIONS] \n"
  551. + " -d debug mode \n"
  552. + " -x dump configuration settings \n"
  553. + " -q quiet mode \n"
  554. + " -c cfg.xml use additional configuration file cfg.xml\n"
  555. + " -l lang the language to use for user information \n"
  556. + " -s for area tree XML, down to block areas only\n\n"
  557. + " [INPUT] \n"
  558. + " infile xsl:fo input file (the same as the next) \n"
  559. + " -fo infile xsl:fo input file \n"
  560. + " -xml infile xml input file, must be used together with -xsl \n"
  561. + " -xsl stylesheet xslt stylesheet \n \n"
  562. + " [OUTPUT] \n"
  563. + " outfile input will be rendered as pdf file into outfile \n"
  564. + " -pdf outfile input will be rendered as pdf file (outfile req'd) \n"
  565. + " -awt input will be displayed on screen \n"
  566. + " -mif outfile input will be rendered as mif file (outfile req'd)\n"
  567. + " -rtf outfile input will be rendered as rtf file (outfile req'd)\n"
  568. + " -pcl outfile input will be rendered as pcl file (outfile req'd) \n"
  569. + " -ps outfile input will be rendered as PostScript file (outfile req'd) \n"
  570. + " -txt outfile input will be rendered as text file (outfile req'd) \n"
  571. + " -svg outfile input will be rendered as an svg slides file (outfile req'd) \n"
  572. + " -at outfile representation of area tree as XML (outfile req'd) \n"
  573. + " -print input file will be rendered and sent to the printer \n"
  574. + " see options with \"-print help\" \n\n"
  575. + " [Examples]\n" + " Fop foo.fo foo.pdf \n"
  576. + " Fop -fo foo.fo -pdf foo.pdf (does the same as the previous line)\n"
  577. + " Fop -xsl foo.xsl -xml foo.xml -pdf foo.pdf\n"
  578. + " Fop foo.fo -mif foo.mif\n"
  579. + " Fop foo.fo -rtf foo.rtf\n"
  580. + " Fop foo.fo -print or Fop -print foo.fo \n"
  581. + " Fop foo.fo -awt \n");
  582. }
  583. /**
  584. * shows the options for print output
  585. */
  586. public void printUsagePrintOutput() {
  587. System.err.println("USAGE: -print [-Dstart=i] [-Dend=i] [-Dcopies=i] [-Deven=true|false] "
  588. + " org.apache.fop.apps.Fop (..) -print \n"
  589. + "Example:\n"
  590. + "java -Dstart=1 -Dend=2 org.apache.Fop.apps.Fop infile.fo -print ");
  591. }
  592. /**
  593. * debug mode. outputs all commandline settings
  594. */
  595. private void debug() {
  596. log.debug("Input mode: ");
  597. switch (inputmode) {
  598. case NOT_SET:
  599. log.debug("not set");
  600. break;
  601. case FO_INPUT:
  602. log.debug("FO ");
  603. log.debug("fo input file: " + fofile.toString());
  604. break;
  605. case XSLT_INPUT:
  606. log.debug("xslt transformation");
  607. log.debug("xml input file: " + xmlfile.toString());
  608. log.debug("xslt stylesheet: " + xsltfile.toString());
  609. break;
  610. default:
  611. log.debug("unknown input type");
  612. }
  613. log.debug("Output mode: ");
  614. switch (outputmode) {
  615. case NOT_SET:
  616. log.debug("not set");
  617. break;
  618. case PDF_OUTPUT:
  619. log.debug("pdf");
  620. log.debug("output file: " + outfile.toString());
  621. break;
  622. case AWT_OUTPUT:
  623. log.debug("awt on screen");
  624. if (outfile != null) {
  625. log.error("awt mode, but outfile is set:");
  626. log.debug("out file: " + outfile.toString());
  627. }
  628. break;
  629. case MIF_OUTPUT:
  630. log.debug("mif");
  631. log.debug("output file: " + outfile.toString());
  632. break;
  633. case RTF_OUTPUT:
  634. log.debug("rtf");
  635. log.debug("output file: " + outfile.toString());
  636. break;
  637. case PRINT_OUTPUT:
  638. log.debug("print directly");
  639. if (outfile != null) {
  640. log.error("print mode, but outfile is set:");
  641. log.error("out file: " + outfile.toString());
  642. }
  643. break;
  644. case PCL_OUTPUT:
  645. log.debug("pcl");
  646. log.debug("output file: " + outfile.toString());
  647. break;
  648. case PS_OUTPUT:
  649. log.debug("PostScript");
  650. log.debug("output file: " + outfile.toString());
  651. break;
  652. case TXT_OUTPUT:
  653. log.debug("txt");
  654. log.debug("output file: " + outfile.toString());
  655. break;
  656. case SVG_OUTPUT:
  657. log.debug("svg");
  658. log.debug("output file: " + outfile.toString());
  659. break;
  660. default:
  661. log.debug("unknown input type");
  662. }
  663. log.debug("OPTIONS");
  664. if (userConfigFile != null) {
  665. log.debug("user configuration file: "
  666. + userConfigFile.toString());
  667. } else {
  668. log.debug("no user configuration file is used [default]");
  669. }
  670. if (dumpConfiguration != null) {
  671. log.debug("dump configuration");
  672. } else {
  673. log.debug("don't dump configuration [default]");
  674. }
  675. if (quiet != null) {
  676. log.debug("quiet mode on");
  677. } else {
  678. log.debug("quiet mode off [default]");
  679. }
  680. }
  681. }