aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-04-17 13:33:07 +0000
committerJeremias Maerki <jeremias@apache.org>2008-04-17 13:33:07 +0000
commite5ee5c2bcf5872ecaf03c6e6e8c5a73904ee4a67 (patch)
treead01d4137cef97518339231cfd6c8d5b40ff9f85 /examples
parent54e844c8c55d8f4adc7a4579771276dc7229794b (diff)
downloadxmlgraphics-fop-e5ee5c2bcf5872ecaf03c6e6e8c5a73904ee4a67.tar.gz
xmlgraphics-fop-e5ee5c2bcf5872ecaf03c6e6e8c5a73904ee4a67.zip
Bugzilla #44678:
Added ability to pass in the PrinterJob instance through the renderer options. Submitted by: Antti Karanta <Antti.Karanta.at.napa.fi> Modifications/Additions to patch: - Don't remove the contructor with the PrinterJob parameter, just deprecate it. - Adjust old-style print example to use renderer options git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@649091 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'examples')
-rw-r--r--examples/embedding/java/embedding/ExampleFO2OldStylePrint.java24
1 files changed, 8 insertions, 16 deletions
diff --git a/examples/embedding/java/embedding/ExampleFO2OldStylePrint.java b/examples/embedding/java/embedding/ExampleFO2OldStylePrint.java
index 588d2c5d7..d9bc1d11d 100644
--- a/examples/embedding/java/embedding/ExampleFO2OldStylePrint.java
+++ b/examples/embedding/java/embedding/ExampleFO2OldStylePrint.java
@@ -24,21 +24,18 @@ import java.awt.print.PrinterJob;
import java.io.File;
import java.io.IOException;
-//JAXP
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.Source;
-import javax.xml.transform.Result;
-import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamSource;
-
-// FOP
+import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
-import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FopFactory;
-import org.apache.fop.render.print.PrintRenderer;
+import org.apache.fop.apps.MimeConstants;
/**
* This class demonstrates printing an FO file to a PrinterJob instance.
@@ -63,15 +60,10 @@ public class ExampleFO2OldStylePrint {
try {
//Set up a custom user agent so we can supply our own renderer instance
FOUserAgent userAgent = fopFactory.newFOUserAgent();
+ userAgent.getRendererOptions().put("printerjob", printerJob);
- //Set up our own PrintRenderer instance so we can supply a special PrinterJob instance.
- PrintRenderer renderer = new PrintRenderer(printerJob);
- renderer.setUserAgent(userAgent);
-
- userAgent.setRendererOverride(renderer);
-
- // Construct fop with desired output format (here, it is set through the user agent)
- Fop fop = fopFactory.newFop(userAgent);
+ // Construct FOP with desired output format
+ Fop fop = fopFactory.newFop(MimeConstants.MIME_FOP_PRINT, userAgent);
// Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();