*/
package org.apache.fop.apps;
-// Java
-import java.awt.print.PrinterJob;
-
// FOP
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.FOTreeBuilder;
* <ul>
* <li>RENDER_PDF</li>
* <li>RENDER_AWT</li>
+ * <li>RENDER_PRINT</li>
* <li>RENDER_MIF</li>
* <li>RENDER_XML</li>
* <li>RENDER_PCL</li>
case RENDER_AWT:
throw new IllegalArgumentException("Use renderer form of setRenderer() for AWT");
case RENDER_PRINT:
- // a PrinterJob object is needed to create this renderer
- PrinterJob pj = PrinterJob.getPrinterJob();
- int copies = AWTPrintRenderer.getIntProperty("copies", 1);
- pj.setCopies(copies);
- if (System.getProperty("dialog") != null) {
- if (!pj.printDialog()) {
- throw new IllegalArgumentException("Printing cancelled by operator");
- }
- }
- setRenderer(new AWTPrintRenderer(pj));
+ setRenderer("org.apache.fop.render.awt.AWTPrintRenderer");
break;
case RENDER_PCL:
setRenderer("org.apache.fop.render.pcl.PCLRenderer");
private int copies = 1;
private PrinterJob printerJob;
- public AWTPrintRenderer(PrinterJob printerJob) {
+ public AWTPrintRenderer() {
super(null);
- this.printerJob = printerJob;
+ initialize();
+ }
+
+ private void initialize() throws IllegalArgumentException {
+ // read from command-line options
+ copies = getIntProperty("copies", 1);
startNumber = getIntProperty("start", 1) - 1;
endNumber = getIntProperty("end", -1);
- printerJob.setPageable(this);
- mode = EVEN_AND_ALL;
String str = System.getProperty("even");
if (str != null) {
mode = Boolean.valueOf(str).booleanValue() ? EVEN : ODD;
}
- }
+
+ printerJob = PrinterJob.getPrinterJob();
+ printerJob.setCopies(copies);
+ if (System.getProperty("dialog") != null) {
+ if (!printerJob.printDialog()) {
+ throw new IllegalArgumentException("Printing cancelled by operator");
+ }
+ }
+ printerJob.setPageable(this);
+ }
public void stopRenderer() throws IOException {
super.stopRenderer();
}
return vec;
}
-
- /* TODO: I'm not totally sure that this is necessary -Mark
- void setCopies(int val) {
- copies = val;
- Vector copie = tree.getPages();
- for (int i = 1; i < copies; i++) {
- tree.getPages().addAll(copie);
- }
- } */
} // class AWTPrintRenderer
import java.io.PrintWriter;
import java.util.List;
-import java.awt.print.PrinterJob;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
HttpServletResponse response) throws ServletException {
try {
Driver driver = new Driver(foFile, null);
- PrinterJob pj = PrinterJob.getPrinterJob();
- AWTPrintRenderer renderer = new AWTPrintRenderer(pj);
+ AWTPrintRenderer renderer = new AWTPrintRenderer();
driver.enableLogging(log);
driver.setRenderer(renderer);
HttpServletResponse response) throws ServletException {
try {
Driver driver = new Driver();
- PrinterJob pj = PrinterJob.getPrinterJob();
- AWTPrintRenderer renderer = new AWTPrintRenderer(pj);
-
- pj.setCopies(1);
+ AWTPrintRenderer renderer = new AWTPrintRenderer();
driver.enableLogging(log);
driver.setRenderer(renderer);