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 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  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. import java.util.Locale;
  56. // Avalon
  57. import org.apache.avalon.framework.logger.ConsoleLogger;
  58. import org.apache.avalon.framework.logger.Logger;
  59. /**
  60. * Options parses the commandline arguments
  61. */
  62. public class CommandLineOptions {
  63. /* input / output not set */
  64. public static final int NOT_SET = 0;
  65. /* input: fo file */
  66. public static final int FO_INPUT = 1;
  67. /* input: xml+xsl file */
  68. public static final int XSLT_INPUT = 2;
  69. /* output: pdf file */
  70. public static final int PDF_OUTPUT = 1;
  71. /* output: screen using swing */
  72. public static final int AWT_OUTPUT = 2;
  73. /* output: mif file */
  74. public static final int MIF_OUTPUT = 3;
  75. /* output: sent swing rendered file to printer */
  76. public static final int PRINT_OUTPUT = 4;
  77. /* output: pcl file */
  78. public static final int PCL_OUTPUT = 5;
  79. /* output: postscript file */
  80. public static final int PS_OUTPUT = 6;
  81. /* output: text file */
  82. public static final int TXT_OUTPUT = 7;
  83. /* output: svg file */
  84. public static final int SVG_OUTPUT = 8;
  85. /* output: XML area tree */
  86. public static final int AREA_OUTPUT = 9;
  87. /* output: RTF file */
  88. public static final int RTF_OUTPUT = 10;
  89. /* show configuration information */
  90. private Boolean dumpConfiguration = Boolean.FALSE;
  91. /* suppress any progress information */
  92. private Boolean quiet = Boolean.FALSE;
  93. /* for area tree XML output, only down to block area level */
  94. private Boolean suppressLowLevelAreas = Boolean.FALSE;
  95. /* user configuration file */
  96. private File userConfigFile = null;
  97. /* input fo file */
  98. private File fofile = null;
  99. /* xsltfile (xslt transformation as input) */
  100. private File xsltfile = null;
  101. /* xml file (xslt transformation as input) */
  102. private File xmlfile = null;
  103. /* output file */
  104. private File outfile = null;
  105. /* input mode */
  106. private int inputmode = NOT_SET;
  107. /* output mode */
  108. private int outputmode = NOT_SET;
  109. private java.util.HashMap rendererOptions;
  110. private Logger log;
  111. /**
  112. * Construct a command line option object from command line arguments
  113. * @param args command line parameters
  114. * @throws FOPException for general errors
  115. * @throws FileNotFoundException if an input file wasn't found.
  116. */
  117. public CommandLineOptions(String[] args)
  118. throws FOPException, FileNotFoundException {
  119. log = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
  120. boolean optionsParsed = true;
  121. rendererOptions = new java.util.HashMap();
  122. try {
  123. optionsParsed = parseOptions(args);
  124. if (optionsParsed) {
  125. checkSettings();
  126. }
  127. } catch (FOPException e) {
  128. printUsage();
  129. throw e;
  130. } catch (java.io.FileNotFoundException e) {
  131. printUsage();
  132. throw e;
  133. }
  134. }
  135. /**
  136. * Get the logger.
  137. * @return the logger
  138. */
  139. public Logger getLogger() {
  140. return log;
  141. }
  142. /**
  143. * parses the commandline arguments
  144. * @return true if parse was successful and processing can continue, false
  145. * if processing should stop
  146. * @exception FOPException if there was an error in the format of the options
  147. */
  148. private boolean parseOptions(String[] args) throws FOPException {
  149. for (int i = 0; i < args.length; i++) {
  150. if (args[i].equals("-d") || args[i].equals("--full-error-dump")) {
  151. log = new ConsoleLogger(ConsoleLogger.LEVEL_DEBUG);
  152. } else if (args[i].equals("-x")
  153. || args[i].equals("--dump-config")) {
  154. dumpConfiguration = Boolean.TRUE;
  155. } else if (args[i].equals("-q") || args[i].equals("--quiet")) {
  156. quiet = Boolean.TRUE;
  157. log = new ConsoleLogger(ConsoleLogger.LEVEL_ERROR);
  158. } else if (args[i].equals("-c")) {
  159. i = i + parseConfigurationOption(args, i);
  160. } else if (args[i].equals("-l")) {
  161. i = i + parseLanguageOption(args, i);
  162. } else if (args[i].equals("-s")) {
  163. suppressLowLevelAreas = Boolean.TRUE;
  164. } else if (args[i].equals("-fo")) {
  165. i = i + parseFOInputOption(args, i);
  166. } else if (args[i].equals("-xsl")) {
  167. i = i + parseXSLInputOption(args, i);
  168. } else if (args[i].equals("-xml")) {
  169. i = i + parseXMLInputOption(args, i);
  170. } else if (args[i].equals("-awt")) {
  171. i = i + parseAWTOutputOption(args, i);
  172. } else if (args[i].equals("-pdf")) {
  173. i = i + parsePDFOutputOption(args, i);
  174. } else if (args[i].equals("-mif")) {
  175. i = i + parseMIFOutputOption(args, i);
  176. } else if (args[i].equals("-rtf")) {
  177. i = i + parseRTFOutputOption(args, i);
  178. } else if (args[i].equals("-print")) {
  179. i = i + parsePrintOutputOption(args, i);
  180. // show print help
  181. if (i + 1 < args.length) {
  182. if (args[i + 1].equals("help")) {
  183. printUsagePrintOutput();
  184. return false;
  185. }
  186. }
  187. } else if (args[i].equals("-pcl")) {
  188. i = i + parsePCLOutputOption(args, i);
  189. } else if (args[i].equals("-ps")) {
  190. i = i + parsePostscriptOutputOption(args, i);
  191. } else if (args[i].equals("-txt")) {
  192. i = i + parseTextOutputOption(args, i);
  193. } else if (args[i].equals("-svg")) {
  194. i = i + parseSVGOutputOption(args, i);
  195. } else if (args[i].charAt(0) != '-') {
  196. i = i + parseUnknownOption(args, i);
  197. } else if (args[i].equals("-at")) {
  198. i = i + parseAreaTreeOption(args, i);
  199. } else {
  200. printUsage();
  201. return false;
  202. }
  203. }
  204. return true;
  205. } // end parseOptions
  206. private int parseConfigurationOption(String[] args, int i) throws FOPException {
  207. if ((i + 1 == args.length)
  208. || (args[i + 1].charAt(0) == '-')) {
  209. throw new FOPException("if you use '-c', you must specify "
  210. + "the name of the configuration file");
  211. } else {
  212. userConfigFile = new File(args[i + 1]);
  213. return 1;
  214. }
  215. }
  216. private int parseLanguageOption(String[] args, int i) throws FOPException {
  217. if ((i + 1 == args.length)
  218. || (args[i + 1].charAt(0) == '-')) {
  219. throw new FOPException("if you use '-l', you must specify a language");
  220. } else {
  221. Locale.setDefault(new Locale(args[i + 1], ""));
  222. return 1;
  223. }
  224. }
  225. private int parseFOInputOption(String[] args, int i) throws FOPException {
  226. inputmode = FO_INPUT;
  227. if ((i + 1 == args.length)
  228. || (args[i + 1].charAt(0) == '-')) {
  229. throw new FOPException("you must specify the fo file for the '-fo' option");
  230. } else {
  231. fofile = new File(args[i + 1]);
  232. return 1;
  233. }
  234. }
  235. private int parseXSLInputOption(String[] args, int i) throws FOPException {
  236. inputmode = XSLT_INPUT;
  237. if ((i + 1 == args.length)
  238. || (args[i + 1].charAt(0) == '-')) {
  239. throw new FOPException("you must specify the stylesheet "
  240. + "file for the '-xsl' option");
  241. } else {
  242. xsltfile = new File(args[i + 1]);
  243. return 1;
  244. }
  245. }
  246. private int parseXMLInputOption(String[] args, int i) throws FOPException {
  247. inputmode = XSLT_INPUT;
  248. if ((i + 1 == args.length)
  249. || (args[i + 1].charAt(0) == '-')) {
  250. throw new FOPException("you must specify the input file "
  251. + "for the '-xml' option");
  252. } else {
  253. xmlfile = new File(args[i + 1]);
  254. return 1;
  255. }
  256. }
  257. private int parseAWTOutputOption(String[] args, int i) throws FOPException {
  258. setOutputMode(AWT_OUTPUT);
  259. return 0;
  260. }
  261. private int parsePDFOutputOption(String[] args, int i) throws FOPException {
  262. setOutputMode(PDF_OUTPUT);
  263. if ((i + 1 == args.length)
  264. || (args[i + 1].charAt(0) == '-')) {
  265. throw new FOPException("you must specify the pdf output file");
  266. } else {
  267. outfile = new File(args[i + 1]);
  268. return 1;
  269. }
  270. }
  271. private int parseMIFOutputOption(String[] args, int i) throws FOPException {
  272. setOutputMode(MIF_OUTPUT);
  273. if ((i + 1 == args.length)
  274. || (args[i + 1].charAt(0) == '-')) {
  275. throw new FOPException("you must specify the mif output file");
  276. } else {
  277. outfile = new File(args[i + 1]);
  278. return 1;
  279. }
  280. }
  281. private int parseRTFOutputOption(String[] args, int i) throws FOPException {
  282. setOutputMode(RTF_OUTPUT);
  283. if ((i + 1 == args.length)
  284. || (args[i + 1].charAt(0) == '-')) {
  285. throw new FOPException("you must specify the rtf output file");
  286. } else {
  287. outfile = new File(args[i + 1]);
  288. return 1;
  289. }
  290. }
  291. private int parsePrintOutputOption(String[] args, int i) throws FOPException {
  292. setOutputMode(PRINT_OUTPUT);
  293. return 0;
  294. }
  295. private int parsePCLOutputOption(String[] args, int i) throws FOPException {
  296. setOutputMode(PCL_OUTPUT);
  297. if ((i + 1 == args.length)
  298. || (args[i + 1].charAt(0) == '-')) {
  299. throw new FOPException("you must specify the pdf output file");
  300. } else {
  301. outfile = new File(args[i + 1]);
  302. return 1;
  303. }
  304. }
  305. private int parsePostscriptOutputOption(String[] args, int i) throws FOPException {
  306. setOutputMode(PS_OUTPUT);
  307. if ((i + 1 == args.length)
  308. || (args[i + 1].charAt(0) == '-')) {
  309. throw new FOPException("you must specify the PostScript output file");
  310. } else {
  311. outfile = new File(args[i + 1]);
  312. return 1;
  313. }
  314. }
  315. private int parseTextOutputOption(String[] args, int i) throws FOPException {
  316. setOutputMode(TXT_OUTPUT);
  317. if ((i + 1 == args.length)
  318. || (args[i + 1].charAt(0) == '-')) {
  319. throw new FOPException("you must specify the text output file");
  320. } else {
  321. outfile = new File(args[i + 1]);
  322. return 1;
  323. }
  324. }
  325. private int parseSVGOutputOption(String[] args, int i) throws FOPException {
  326. setOutputMode(SVG_OUTPUT);
  327. if ((i + 1 == args.length)
  328. || (args[i + 1].charAt(0) == '-')) {
  329. throw new FOPException("you must specify the svg output file");
  330. } else {
  331. outfile = new File(args[i + 1]);
  332. return 1;
  333. }
  334. }
  335. private int parseUnknownOption(String[] args, int i) throws FOPException {
  336. if (inputmode == NOT_SET) {
  337. inputmode = FO_INPUT;
  338. fofile = new File(args[i]);
  339. } else if (outputmode == NOT_SET) {
  340. outputmode = PDF_OUTPUT;
  341. outfile = new File(args[i]);
  342. } else {
  343. throw new FOPException("Don't know what to do with "
  344. + args[i]);
  345. }
  346. return 0;
  347. }
  348. private int parseAreaTreeOption(String[] args, int i) throws FOPException {
  349. setOutputMode(AREA_OUTPUT);
  350. if ((i + 1 == args.length)
  351. || (args[i + 1].charAt(0) == '-')) {
  352. throw new FOPException("you must specify the area-tree output file");
  353. } else {
  354. outfile = new File(args[i + 1]);
  355. return 1;
  356. }
  357. }
  358. private void setOutputMode(int mode) throws FOPException {
  359. if (outputmode == NOT_SET) {
  360. outputmode = mode;
  361. } else {
  362. throw new FOPException("you can only set one output method");
  363. }
  364. }
  365. /**
  366. * checks whether all necessary information has been given in a consistent way
  367. */
  368. private void checkSettings() throws FOPException, FileNotFoundException {
  369. if (inputmode == NOT_SET) {
  370. throw new FOPException("No input file specified");
  371. }
  372. if (outputmode == NOT_SET) {
  373. throw new FOPException("No output file specified");
  374. }
  375. if (inputmode == XSLT_INPUT) {
  376. // check whether xml *and* xslt file have been set
  377. if (xmlfile == null) {
  378. throw new FOPException("XML file must be specified for the tranform mode");
  379. }
  380. if (xsltfile == null) {
  381. throw new FOPException("XSLT file must be specified for the tranform mode");
  382. }
  383. // warning if fofile has been set in xslt mode
  384. if (fofile != null) {
  385. log.warn("Can't use fo file with transform mode! Ignoring.\n"
  386. + "Your input is " + "\n xmlfile: "
  387. + xmlfile.getAbsolutePath()
  388. + "\nxsltfile: "
  389. + xsltfile.getAbsolutePath()
  390. + "\n fofile: "
  391. + fofile.getAbsolutePath());
  392. }
  393. if (!xmlfile.exists()) {
  394. throw new FileNotFoundException("xml file "
  395. + xmlfile.getAbsolutePath()
  396. + " not found ");
  397. }
  398. if (!xsltfile.exists()) {
  399. throw new FileNotFoundException("xsl file "
  400. + xsltfile.getAbsolutePath()
  401. + " not found ");
  402. }
  403. } else if (inputmode == FO_INPUT) {
  404. if (xmlfile != null || xsltfile != null) {
  405. log.warn("fo input mode, but xmlfile or xslt file are set:");
  406. log.error("xml file: " + xmlfile.toString());
  407. log.error("xslt file: " + xsltfile.toString());
  408. }
  409. if (!fofile.exists()) {
  410. throw new FileNotFoundException("fo file "
  411. + fofile.getAbsolutePath()
  412. + " not found ");
  413. }
  414. }
  415. } // end checkSettings
  416. /**
  417. * @return the type chosen renderer
  418. * @throws FOPException for invalid output modes
  419. */
  420. public int getRenderer() throws FOPException {
  421. switch (outputmode) {
  422. case NOT_SET:
  423. throw new FOPException("Renderer has not been set!");
  424. case PDF_OUTPUT:
  425. return Driver.RENDER_PDF;
  426. case AWT_OUTPUT:
  427. return Driver.RENDER_AWT;
  428. case MIF_OUTPUT:
  429. return Driver.RENDER_MIF;
  430. case PRINT_OUTPUT:
  431. return Driver.RENDER_PRINT;
  432. case PCL_OUTPUT:
  433. return Driver.RENDER_PCL;
  434. case PS_OUTPUT:
  435. return Driver.RENDER_PS;
  436. case TXT_OUTPUT:
  437. return Driver.RENDER_TXT;
  438. case SVG_OUTPUT:
  439. return Driver.RENDER_SVG;
  440. case AREA_OUTPUT:
  441. rendererOptions.put("fineDetail", isCoarseAreaXml());
  442. return Driver.RENDER_XML;
  443. case RTF_OUTPUT:
  444. return Driver.RENDER_RTF;
  445. default:
  446. throw new FOPException("Invalid Renderer setting!");
  447. }
  448. }
  449. /**
  450. * Get the input handler.
  451. * @return the input handler
  452. * @throws FOPException if creating the InputHandler fails
  453. */
  454. public InputHandler getInputHandler() throws FOPException {
  455. switch (inputmode) {
  456. case FO_INPUT:
  457. return new FOFileHandler(fofile);
  458. case XSLT_INPUT:
  459. return new XSLTInputHandler(xmlfile, xsltfile);
  460. default:
  461. throw new FOPException("Invalid inputmode setting!");
  462. }
  463. }
  464. /**
  465. * Get the renderer specific options.
  466. * @return hash map with option/value pairs.
  467. */
  468. public java.util.HashMap getRendererOptions() {
  469. return rendererOptions;
  470. }
  471. /**
  472. * Returns the input mode (type of input data, ex. NOT_SET or FO_INPUT)
  473. * @return the input mode
  474. */
  475. public int getInputMode() {
  476. return inputmode;
  477. }
  478. /**
  479. * Returns the output mode (output format, ex. NOT_SET or PDF_OUTPUT)
  480. * @return the output mode
  481. */
  482. public int getOutputMode() {
  483. return outputmode;
  484. }
  485. /**
  486. * Returns the XSL-FO file if set.
  487. * @return the XSL-FO file, null if not set
  488. */
  489. public File getFOFile() {
  490. return fofile;
  491. }
  492. /**
  493. * Returns the input XML file if set.
  494. * @return the input XML file, null if not set
  495. */
  496. public File getXMLFile() {
  497. return xmlfile;
  498. }
  499. /**
  500. * Returns the stylesheet to be used for transformation to XSL-FO.
  501. * @return stylesheet
  502. */
  503. public File getXSLFile() {
  504. return xsltfile;
  505. }
  506. /**
  507. * Returns the output file
  508. * @return the output file
  509. */
  510. public File getOutputFile() {
  511. return outfile;
  512. }
  513. /**
  514. * Returns the user configuration file to be used.
  515. * @return the userconfig.xml file
  516. */
  517. public File getUserConfigFile() {
  518. return userConfigFile;
  519. }
  520. /**
  521. * Indicates if FOP should be silent.
  522. * @return true if should be silent
  523. */
  524. public Boolean isQuiet() {
  525. return quiet;
  526. }
  527. /**
  528. * Indicates if FOP should dump its configuration during runtime.
  529. * @return true if config dump is enabled
  530. */
  531. public Boolean dumpConfiguration() {
  532. return dumpConfiguration;
  533. }
  534. /**
  535. * Indicates whether the XML renderer should generate course area XML
  536. * @return true if coarse area XML is desired
  537. */
  538. public Boolean isCoarseAreaXml() {
  539. return suppressLowLevelAreas;
  540. }
  541. /**
  542. * Returns the input file.
  543. * @return either the fofile or the xmlfile
  544. */
  545. public File getInputFile() {
  546. switch (inputmode) {
  547. case FO_INPUT:
  548. return fofile;
  549. case XSLT_INPUT:
  550. return xmlfile;
  551. default:
  552. return fofile;
  553. }
  554. }
  555. /**
  556. * shows the commandline syntax including a summary of all available options and some examples
  557. */
  558. public static void printUsage() {
  559. System.err.println(
  560. "\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] "
  561. + "[-awt|-pdf|-mif|-rtf|-pcl|-ps|-txt|-at|-print] <outfile>\n"
  562. + " [OPTIONS] \n"
  563. + " -d debug mode \n"
  564. + " -x dump configuration settings \n"
  565. + " -q quiet mode \n"
  566. + " -c cfg.xml use additional configuration file cfg.xml\n"
  567. + " -l lang the language to use for user information \n"
  568. + " -s for area tree XML, down to block areas only\n\n"
  569. + " [INPUT] \n"
  570. + " infile xsl:fo input file (the same as the next) \n"
  571. + " -fo infile xsl:fo input file \n"
  572. + " -xml infile xml input file, must be used together with -xsl \n"
  573. + " -xsl stylesheet xslt stylesheet \n \n"
  574. + " [OUTPUT] \n"
  575. + " outfile input will be rendered as pdf file into outfile \n"
  576. + " -pdf outfile input will be rendered as pdf file (outfile req'd) \n"
  577. + " -awt input will be displayed on screen \n"
  578. + " -mif outfile input will be rendered as mif file (outfile req'd)\n"
  579. + " -rtf outfile input will be rendered as rtf file (outfile req'd)\n"
  580. + " -pcl outfile input will be rendered as pcl file (outfile req'd) \n"
  581. + " -ps outfile input will be rendered as PostScript file (outfile req'd) \n"
  582. + " -txt outfile input will be rendered as text file (outfile req'd) \n"
  583. + " -svg outfile input will be rendered as an svg slides file (outfile req'd) \n"
  584. + " -at outfile representation of area tree as XML (outfile req'd) \n"
  585. + " -print input file will be rendered and sent to the printer \n"
  586. + " see options with \"-print help\" \n\n"
  587. + " [Examples]\n" + " Fop foo.fo foo.pdf \n"
  588. + " Fop -fo foo.fo -pdf foo.pdf (does the same as the previous line)\n"
  589. + " Fop -xml foo.xml -xsl foo.xsl -pdf foo.pdf\n"
  590. + " Fop foo.fo -mif foo.mif\n"
  591. + " Fop foo.fo -rtf foo.rtf\n"
  592. + " Fop foo.fo -print or Fop -print foo.fo \n"
  593. + " Fop foo.fo -awt \n");
  594. }
  595. /**
  596. * shows the options for print output
  597. */
  598. public void printUsagePrintOutput() {
  599. System.err.println("USAGE: -print [-Dstart=i] [-Dend=i] [-Dcopies=i] [-Deven=true|false] "
  600. + " org.apache.fop.apps.Fop (..) -print \n"
  601. + "Example:\n"
  602. + "java -Dstart=1 -Dend=2 org.apache.Fop.apps.Fop infile.fo -print ");
  603. }
  604. /**
  605. * debug mode. outputs all commandline settings
  606. */
  607. private void debug() {
  608. log.debug("Input mode: ");
  609. switch (inputmode) {
  610. case NOT_SET:
  611. log.debug("not set");
  612. break;
  613. case FO_INPUT:
  614. log.debug("FO ");
  615. log.debug("fo input file: " + fofile.toString());
  616. break;
  617. case XSLT_INPUT:
  618. log.debug("xslt transformation");
  619. log.debug("xml input file: " + xmlfile.toString());
  620. log.debug("xslt stylesheet: " + xsltfile.toString());
  621. break;
  622. default:
  623. log.debug("unknown input type");
  624. }
  625. log.debug("Output mode: ");
  626. switch (outputmode) {
  627. case NOT_SET:
  628. log.debug("not set");
  629. break;
  630. case PDF_OUTPUT:
  631. log.debug("pdf");
  632. log.debug("output file: " + outfile.toString());
  633. break;
  634. case AWT_OUTPUT:
  635. log.debug("awt on screen");
  636. if (outfile != null) {
  637. log.error("awt mode, but outfile is set:");
  638. log.debug("out file: " + outfile.toString());
  639. }
  640. break;
  641. case MIF_OUTPUT:
  642. log.debug("mif");
  643. log.debug("output file: " + outfile.toString());
  644. break;
  645. case RTF_OUTPUT:
  646. log.debug("rtf");
  647. log.debug("output file: " + outfile.toString());
  648. break;
  649. case PRINT_OUTPUT:
  650. log.debug("print directly");
  651. if (outfile != null) {
  652. log.error("print mode, but outfile is set:");
  653. log.error("out file: " + outfile.toString());
  654. }
  655. break;
  656. case PCL_OUTPUT:
  657. log.debug("pcl");
  658. log.debug("output file: " + outfile.toString());
  659. break;
  660. case PS_OUTPUT:
  661. log.debug("PostScript");
  662. log.debug("output file: " + outfile.toString());
  663. break;
  664. case TXT_OUTPUT:
  665. log.debug("txt");
  666. log.debug("output file: " + outfile.toString());
  667. break;
  668. case SVG_OUTPUT:
  669. log.debug("svg");
  670. log.debug("output file: " + outfile.toString());
  671. break;
  672. default:
  673. log.debug("unknown input type");
  674. }
  675. log.debug("OPTIONS");
  676. if (userConfigFile != null) {
  677. log.debug("user configuration file: "
  678. + userConfigFile.toString());
  679. } else {
  680. log.debug("no user configuration file is used [default]");
  681. }
  682. if (dumpConfiguration != null) {
  683. log.debug("dump configuration");
  684. } else {
  685. log.debug("don't dump configuration [default]");
  686. }
  687. if (quiet != null) {
  688. log.debug("quiet mode on");
  689. } else {
  690. log.debug("quiet mode off [default]");
  691. }
  692. }
  693. }