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

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