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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  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. * @throws FOPException if creating the InputHandler fails
  403. */
  404. public InputHandler getInputHandler() throws FOPException {
  405. switch (inputmode) {
  406. case FO_INPUT:
  407. return new FOInputHandler(fofile);
  408. case XSLT_INPUT:
  409. return new XSLTInputHandler(xmlfile, xsltfile);
  410. default:
  411. return new FOInputHandler(fofile);
  412. }
  413. }
  414. /**
  415. * Get the renderer specific options.
  416. * @return hash map with option/value pairs.
  417. */
  418. public java.util.HashMap getRendererOptions() {
  419. return rendererOptions;
  420. }
  421. /**
  422. * Get the starter for the process.
  423. * @return the starter.
  424. * @throws FOPException In case of failure while getting the starter
  425. */
  426. public Starter getStarter() throws FOPException {
  427. Starter starter = null;
  428. switch (outputmode) {
  429. case AWT_OUTPUT:
  430. try {
  431. starter = new AWTStarter(this);
  432. } catch (FOPException e) {
  433. throw e;
  434. } catch (Exception e) {
  435. throw new FOPException("AWTStarter could not be loaded.", e);
  436. }
  437. break;
  438. case PRINT_OUTPUT:
  439. try {
  440. starter = new PrintStarter(this);
  441. } catch (FOPException e) {
  442. throw e;
  443. } catch (Exception e) {
  444. throw new FOPException("PrintStarter could not be loaded.", e);
  445. }
  446. break;
  447. default:
  448. starter = new CommandLineStarter(this);
  449. }
  450. starter.enableLogging(log);
  451. return starter;
  452. }
  453. /**
  454. * Returns the input mode (type of input data, ex. NOT_SET or FO_INPUT)
  455. * @return the input mode
  456. */
  457. public int getInputMode() {
  458. return inputmode;
  459. }
  460. /**
  461. * Returns the output mode (output format, ex. NOT_SET or PDF_OUTPUT)
  462. * @return the output mode
  463. */
  464. public int getOutputMode() {
  465. return outputmode;
  466. }
  467. /**
  468. * Returns the XSL-FO file if set.
  469. * @return the XSL-FO file, null if not set
  470. */
  471. public File getFOFile() {
  472. return fofile;
  473. }
  474. /**
  475. * Returns the input XML file if set.
  476. * @return the input XML file, null if not set
  477. */
  478. public File getXMLFile() {
  479. return xmlfile;
  480. }
  481. /**
  482. * Returns the stylesheet to be used for transformation to XSL-FO.
  483. * @return stylesheet
  484. */
  485. public File getXSLFile() {
  486. return xsltfile;
  487. }
  488. /**
  489. * Returns the output file
  490. * @return the output file
  491. */
  492. public File getOutputFile() {
  493. return outfile;
  494. }
  495. /**
  496. * Returns the user configuration file to be used.
  497. * @return the userconfig.xml file
  498. */
  499. public File getUserConfigFile() {
  500. return userConfigFile;
  501. }
  502. /**
  503. * Returns the default language
  504. * @return the default language
  505. */
  506. public String getLanguage() {
  507. return language;
  508. }
  509. /**
  510. * Indicates if FOP should be silent.
  511. * @return true if should be silent
  512. */
  513. public Boolean isQuiet() {
  514. return quiet;
  515. }
  516. /**
  517. * Indicates if FOP should dump its configuration during runtime.
  518. * @return true if config dump is enabled
  519. */
  520. public Boolean dumpConfiguration() {
  521. return dumpConfiguration;
  522. }
  523. /**
  524. * Indicates whether the XML renderer should generate course area XML
  525. * @return true if coarse area XML is desired
  526. */
  527. public Boolean isCoarseAreaXml() {
  528. return suppressLowLevelAreas;
  529. }
  530. /**
  531. * Returns the input file.
  532. * @return either the fofile or the xmlfile
  533. */
  534. public File getInputFile() {
  535. switch (inputmode) {
  536. case FO_INPUT:
  537. return fofile;
  538. case XSLT_INPUT:
  539. return xmlfile;
  540. default:
  541. return fofile;
  542. }
  543. }
  544. /**
  545. * shows the commandline syntax including a summary of all available options and some examples
  546. */
  547. public static void printUsage() {
  548. System.err.println(
  549. "\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] "
  550. + "[-awt|-pdf|-mif|-rtf|-pcl|-ps|-txt|-at|-print] <outfile>\n"
  551. + " [OPTIONS] \n"
  552. + " -d debug mode \n"
  553. + " -x dump configuration settings \n"
  554. + " -q quiet mode \n"
  555. + " -c cfg.xml use additional configuration file cfg.xml\n"
  556. + " -l lang the language to use for user information \n"
  557. + " -s for area tree XML, down to block areas only\n\n"
  558. + " [INPUT] \n"
  559. + " infile xsl:fo input file (the same as the next) \n"
  560. + " -fo infile xsl:fo input file \n"
  561. + " -xml infile xml input file, must be used together with -xsl \n"
  562. + " -xsl stylesheet xslt stylesheet \n \n"
  563. + " [OUTPUT] \n"
  564. + " outfile input will be rendered as pdf file into outfile \n"
  565. + " -pdf outfile input will be rendered as pdf file (outfile req'd) \n"
  566. + " -awt input will be displayed on screen \n"
  567. + " -mif outfile input will be rendered as mif file (outfile req'd)\n"
  568. + " -rtf outfile input will be rendered as rtf file (outfile req'd)\n"
  569. + " -pcl outfile input will be rendered as pcl file (outfile req'd) \n"
  570. + " -ps outfile input will be rendered as PostScript file (outfile req'd) \n"
  571. + " -txt outfile input will be rendered as text file (outfile req'd) \n"
  572. + " -svg outfile input will be rendered as an svg slides file (outfile req'd) \n"
  573. + " -at outfile representation of area tree as XML (outfile req'd) \n"
  574. + " -print input file will be rendered and sent to the printer \n"
  575. + " see options with \"-print help\" \n\n"
  576. + " [Examples]\n" + " Fop foo.fo foo.pdf \n"
  577. + " Fop -fo foo.fo -pdf foo.pdf (does the same as the previous line)\n"
  578. + " Fop -xsl foo.xsl -xml foo.xml -pdf foo.pdf\n"
  579. + " Fop foo.fo -mif foo.mif\n"
  580. + " Fop foo.fo -rtf foo.rtf\n"
  581. + " Fop foo.fo -print or Fop -print foo.fo \n"
  582. + " Fop foo.fo -awt \n");
  583. }
  584. /**
  585. * shows the options for print output
  586. */
  587. public void printUsagePrintOutput() {
  588. System.err.println("USAGE: -print [-Dstart=i] [-Dend=i] [-Dcopies=i] [-Deven=true|false] "
  589. + " org.apache.fop.apps.Fop (..) -print \n"
  590. + "Example:\n"
  591. + "java -Dstart=1 -Dend=2 org.apache.Fop.apps.Fop infile.fo -print ");
  592. }
  593. /**
  594. * debug mode. outputs all commandline settings
  595. */
  596. private void debug() {
  597. log.debug("Input mode: ");
  598. switch (inputmode) {
  599. case NOT_SET:
  600. log.debug("not set");
  601. break;
  602. case FO_INPUT:
  603. log.debug("FO ");
  604. log.debug("fo input file: " + fofile.toString());
  605. break;
  606. case XSLT_INPUT:
  607. log.debug("xslt transformation");
  608. log.debug("xml input file: " + xmlfile.toString());
  609. log.debug("xslt stylesheet: " + xsltfile.toString());
  610. break;
  611. default:
  612. log.debug("unknown input type");
  613. }
  614. log.debug("Output mode: ");
  615. switch (outputmode) {
  616. case NOT_SET:
  617. log.debug("not set");
  618. break;
  619. case PDF_OUTPUT:
  620. log.debug("pdf");
  621. log.debug("output file: " + outfile.toString());
  622. break;
  623. case AWT_OUTPUT:
  624. log.debug("awt on screen");
  625. if (outfile != null) {
  626. log.error("awt mode, but outfile is set:");
  627. log.debug("out file: " + outfile.toString());
  628. }
  629. break;
  630. case MIF_OUTPUT:
  631. log.debug("mif");
  632. log.debug("output file: " + outfile.toString());
  633. break;
  634. case RTF_OUTPUT:
  635. log.debug("rtf");
  636. log.debug("output file: " + outfile.toString());
  637. break;
  638. case PRINT_OUTPUT:
  639. log.debug("print directly");
  640. if (outfile != null) {
  641. log.error("print mode, but outfile is set:");
  642. log.error("out file: " + outfile.toString());
  643. }
  644. break;
  645. case PCL_OUTPUT:
  646. log.debug("pcl");
  647. log.debug("output file: " + outfile.toString());
  648. break;
  649. case PS_OUTPUT:
  650. log.debug("PostScript");
  651. log.debug("output file: " + outfile.toString());
  652. break;
  653. case TXT_OUTPUT:
  654. log.debug("txt");
  655. log.debug("output file: " + outfile.toString());
  656. break;
  657. case SVG_OUTPUT:
  658. log.debug("svg");
  659. log.debug("output file: " + outfile.toString());
  660. break;
  661. default:
  662. log.debug("unknown input type");
  663. }
  664. log.debug("OPTIONS");
  665. if (userConfigFile != null) {
  666. log.debug("user configuration file: "
  667. + userConfigFile.toString());
  668. } else {
  669. log.debug("no user configuration file is used [default]");
  670. }
  671. if (dumpConfiguration != null) {
  672. log.debug("dump configuration");
  673. } else {
  674. log.debug("don't dump configuration [default]");
  675. }
  676. if (quiet != null) {
  677. log.debug("quiet mode on");
  678. } else {
  679. log.debug("quiet mode off [default]");
  680. }
  681. }
  682. }