Reputation: 1932
I am currently using FOP embedded using Driver as follows
Driver driver = new Driver();
driver.setRenderer(Driver.RENDER_PDF);
driver.setInputSource(new InputSource(new FileInputStream(tempout)));
File tempFile = File.createTempFile("W2P", ".pdf");
FileOutputStream pdfOutput = new FileOutputStream(tempFile);
tempFile.deleteOnExit();
driver.setOutputStream(pdfOutput);
driver.run();
but i would like to have access to configuration settings programatically specifically the output resolution as I have to produce multiple resolution files 72dpi 150dpi 300dpi the only way i can find of doing that is by changing to a FOPFactory as follows
FopFactory fopFactory = FopFactory.newInstance();
OutputStream out = new BufferedOutputStream(new FileOutputStream(new File("C:/Temp/myfile.pdf")));
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); // identity transformer
Source src = new StreamSource(new File("C:/Temp/myfile.fo"));
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);
Is there a way of controling the FOP engine using Driver or will i have to switch to FOPFactory and what are the benefits/problems in doing so?
Upvotes: 2
Views: 4470
Reputation: 50947
The Driver
class is only available in old and unmaintained versions of FOP (0.20.5 and earlier). A "new stable API" (including FopFactory
) was introduced years ago. So my advice would be to use FopFactory
and the latest FOP (1.0).
Upvotes: 5