/* System buffers */
private static final int BUFFER_FILE = 7;
+ /* System buffers */
+ private static final int AREA_OUTPUT = 8;
+
/* use debug mode*/
Boolean errorDump = new Boolean(false);
/* show configuration information */
Boolean dumpConfiguration = new Boolean(false);
/*suppress any progress information */
Boolean quiet = new Boolean(false);
+ /* for area tree XML output, only down to block area level */
+ Boolean suppressLowLevelAreas = new Boolean(false);
/* name of user configuration file*/
File userConfigFile = null;
/* name of input fo file */
/* language for user information */
String language = null;
-
+ private java.util.Hashtable rendererOptions;
+
public CommandLineOptions (String [] args)
throws FOPException, FileNotFoundException
{
boolean optionsParsed = true;
+ rendererOptions = new java.util.Hashtable();
try {
optionsParsed = parseOptions(args);
if (optionsParsed) {
language = args[i + 1];
i++;
}
- } else if (args[i].equals("-fo")) {
+ } else if (args[i].equals("-s")) {
+ suppressLowLevelAreas = new Boolean(true);
+ } else if (args[i].equals("-fo")) {
inputmode = FO_INPUT;
if ((i + 1 == args.length) ||
(args[i + 1].charAt(0) == '-')) {
bufferFile = new File (args[i + 1]);
i++;
}
+ } else if (args[i].equals("-at")) {
+ setOutputMode(AREA_OUTPUT);
+ if ((i + 1 == args.length) ||
+ (args[i + 1].charAt(0) == '-')) {
+ throw new FOPException("you must specify the area-tree output file");
+ } else {
+ outfile = new File (args[i + 1]);
+ i++;
+ }
} else {
printUsage();
return false;
return Driver.RENDER_PCL;
case TXT_OUTPUT:
return Driver.RENDER_TXT;
+ case AREA_OUTPUT:
+ rendererOptions.put("fineDetail", isCoarseAreaXml());
+ return Driver.RENDER_XML;
default:
throw new FOPException("Invalid Renderer setting!");
}
}
}
-
+ public java.util.Hashtable getRendererOptions() {
+ return rendererOptions;
+ }
+
public Starter getStarter()
throws FOPException
{
throw new FOPException("PrintStarter could not be loaded.",e);
}
+ case AREA_OUTPUT:
+ return new CommandLineStarter(this);
default:
return new CommandLineStarter(this);
}
return errorDump;
}
-
+ public Boolean isCoarseAreaXml() {
+ return suppressLowLevelAreas;
+ }
+
/**
* return either the fofile or the xmlfile
*/
*/
public static void printUsage() {
MessageHandler.errorln(
- "\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-pcl|-txt|-print] <outfile>\n" +
+ "\nUSAGE\nFop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-pcl|-txt|-at|-print] <outfile>\n" +
" [OPTIONS] \n" + " -d debug mode \n" +
" -x dump configuration settings \n" +
" -q quiet mode \n" +
" -c cfg.xml use additional configuration file cfg.xml\n" +
- " -l lang the language to use for user information \n\n" +
+ " -l lang the language to use for user information \n" +
+ " -s for area tree XML, down to block areas only\n\n" +
" [INPUT] \n" +
" infile xsl:fo input file (the same as the next) \n" +
" -fo infile xsl:fo input file \n" +
" -mif outfile input will be rendered as mif file (outfile req'd)\n" +
" -pcl outfile input will be rendered as pcl file (outfile req'd) \n" +
" -txt outfile input will be rendered as text file (outfile req'd) \n" +
+ " -at outfile representation of area tree as XML (outfile req'd) \n" +
" -print input file will be rendered and sent to the printer \n" +
" see options with \"-print help\" \n\n" +
" [Examples]\n" + " Fop foo.fo foo.pdf \n" +
try {
driver.setRenderer(commandLineOptions.getRenderer());
-
+ driver.getRenderer().setOptions(commandLineOptions.getRendererOptions());
driver.buildFOTree(parser, inputHandler.getInputSource());
driver.format();
driver.setOutputStream(new FileOutputStream(commandLineOptions.getOutputFile()));
_renderer = renderer;
}
+ public Renderer getRenderer() {
+ return _renderer;
+ }
+
/**
* @deprecated use renderer.setProducer(version) + setRenderer(renderer) or just setRenderer(renderer_type) which will use the default producer string.
* @see #setRenderer(int)
/** set up the given FontInfo */
public void setupFontInfo(FontInfo fontInfo);
+ /** set up renderer options */
+ public void setOptions(java.util.Hashtable options);
+
/** set the producer of the rendering */
public void setProducer(String producer);
*/
private int currentAreaContainerXPosition = 0;
-
+ /** options */
+ protected Hashtable options;
+
+ /** set up renderer options */
+ public void setOptions(Hashtable options) {
+ this.options = options;
+ }
+
public AWTRenderer(Translator aRes) {
res = aRes;
}
/* is a table currently open? */
private boolean inTable=false;
-
-
+ /** options */
+ protected Hashtable options;
+
/**
* create the MIF renderer
*/
public MIFRenderer() {
- this.mifDoc = new MIFDocument();
+ this.mifDoc = new MIFDocument();
}
-
+ /** set up renderer options */
+ public void setOptions(Hashtable options) {
+ this.options = options;
+ }
+
/**
* render the areas into MIF
*
private int xoffset = -180; // X Offset to allow for PCL implicit 1/4" left margin.
+ private java.util.Hashtable options;
+
/**
* Create the PCL renderer
*/
{
}
+ /** set up renderer options */
+ public void setOptions(java.util.Hashtable options) {
+ this.options = options;
+ }
+
/**
* set the PCL document's producer
*
/** reusable word area string buffer to reduce memory usage */
private StringBuffer _wordAreaPDF = new StringBuffer();
+ /** options */
+ protected Hashtable options;
+
/**
* create the PDF renderer
*/
this.pdfDoc = new PDFDocument();
}
+ /** set up renderer options */
+ public void setOptions(Hashtable options) {
+ this.options = options;
+ }
+
/**
* set the PDF document's producer
*
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.Vector;
+import java.util.Hashtable;
/**
* Renderer that renders areas to plain text
public String pageEnding = "\f"; // Every page except the last one will end with this string.
public boolean suppressGraphics = false; // If true then graphics/decorations will not be rendered - text only.
- /**
- * create the TXT renderer
- */
- public TXTRenderer()
- {
- }
+ /** options */
+ protected Hashtable options;
+
+ public TXTRenderer() {
+ }
+ /** set up renderer options */
+ public void setOptions(Hashtable options) {
+ this.options = options;
+ }
+
/**
* set the TXT document's producer
*
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Enumeration;
+import java.util.Hashtable;
/**
* Renderer that renders areas to XML for debugging purposes.
/** the writer used to output the XML */
protected PrintWriter writer;
+ /** options */
+ protected Hashtable options;
+
+ public XMLRenderer() {
+ }
+
+ /** set up renderer options */
+ public void setOptions(Hashtable options) {
+ this.options = options;
+ }
+
/**
* set the document's producer
*
* @param space the space to render
*/
public void renderDisplaySpace(DisplaySpace space) {
- writeEmptyElementTag("<DisplaySpace size=\""
+ if (!isCoarseXml())
+ writeEmptyElementTag("<DisplaySpace size=\""
+ space.getSize() +"\"/>");
}
else
sb = sb.append(ch);
}
- writeElement("<InlineArea font-weight=\""
+ if (!isCoarseXml()) {
+ writeElement("<WordArea font-weight=\""
+ fontWeight + "\" red=\""
+ area.getRed() + "\" green=\""
+ area.getGreen() + "\" blue = \""
+ area.getBlue() + "\" width = \""
+ area.getContentWidth() + "\">" + sb.toString()
- + "</InlineArea>");
+ + "</WordArea>");
+ } else {
+ this.writer.write(sb.toString());
+ }
}
/**
* @param space the space to render
*/
public void renderInlineSpace(InlineSpace space) {
- writeEmptyElementTag("<InlineSpace size=\""
+ if (!isCoarseXml())
+ writeEmptyElementTag("<InlineSpace size=\""
+ space.getSize() +"\"/>");
+ else
+ this.writer.write(" ");
}
/**
* @param area the area to render
*/
public void renderLineArea(LineArea area) {
- String fontWeight = area.getFontState().getFontWeight();
- writeStartTag("<LineArea font-weight=\""
+ if (!isCoarseXml()) {
+ String fontWeight = area.getFontState().getFontWeight();
+ writeStartTag("<LineArea font-weight=\""
+ fontWeight + "\">");
- Enumeration e = area.getChildren().elements();
- while (e.hasMoreElements()) {
- Box b = (Box)e.nextElement();
- b.render(this);
- }
- writeEndTag("</LineArea>");
+ }
+ Enumeration e = area.getChildren().elements();
+ while (e.hasMoreElements()) {
+ Box b = (Box)e.nextElement();
+ b.render(this);
+ }
+ if (!isCoarseXml())
+ writeEndTag("</LineArea>");
+ else
+ this.writer.write("\n");
}
/**
public void renderPage(Page page) {
BodyAreaContainer body;
AreaContainer before, after;
- writeStartTag("<Page>");
+ writeStartTag("<Page number=\"" + page.getNumber() + "\">");
body = page.getBody();
before = page.getBefore();
after = page.getAfter();
* @param area the area to render
*/
public void renderLeaderArea(LeaderArea area) {
+ if (isCoarseXml()) return;
String leaderPattern = "";
switch (area.getLeaderPattern()) {
case LeaderPattern.SPACE:
"\" red=\"" + area.getRed() + "\" green=\"" + area.getGreen() +
"\" blue = \"" + area.getBlue() + "\"/>");
}
+
+ private boolean isCoarseXml() {
+ return ((Boolean)options.get("fineDetail")).booleanValue();
+ }
}