Send reply to: [EMAIL PROTECTED]
Date sent: Thu, 03 Jun 2004 14:42:37 +0200
From: Rudy RENTSCH <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: How can i do to print directly in a embedded FOP
application?
> Hi,
>
> I've an application which uses JPanel, and I embedded FOP to have the
> possibility to print information contained in a frame.
> I followed the code provided in your example called
> "ExampleObj2PDF.java", and I manage to transform informations in a PDF
> file. But in the beggining, i'd like to print these information
> directly, without generating a PDF file.
> The problem is if I specify Driver.RENDER_PRINT when I set the renderer
> of the Driver ( by this command :
> "driver.setRenderer(Driver.RENDER_PRINT);" ), then I obtain an error
> indicating :
> "IllegalArgumentException : Use renderer form of setRenderer() for PRINT"
> which is normal in according to the class Driver. But if I use the
> method "setRenderer(Renderer renderer)", I can't put a PrintRenderer
> like parameter (abstract class)...
> Can you help me please, telling me how can I do to specify that I want a
> printed output?
>
> Thanks.
>
> Rudy
>
Hi,
with this function 'use_fop_prt' i can print directly to my
standardprinter,
but sometimes the result look a bit different to a generated PDF-file.
The 'fileSource' is the fo-file that was produced frpm the xml and
xls-File
a step before.
private void use_fop_prt(String fileSrc)
throws FileNotFoundException, IOException, FOPException
{
File source;
PrinterJob pj;
int copies;
AWTRenderer renderer;
File UserConfigFile = new File("fop/conf/userconfig.xml");
Options op = new Options(UserConfigFile);
source = new File (fileSrc);
pj = PrinterJob.getPrinterJob();
copies = 1;
renderer = new AWTRenderer(pj);
pj.setCopies(copies);
Configuration.put("baseDir",
new
File(source.getAbsolutePath()).getParentFile().toURL().toExternalForm());
Driver driver = new Driver(new InputSource(fileSrc), null);
Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
MessageHandler.setScreenLogger(logger);
driver.setLogger(logger);
driver.setRenderer(renderer);
driver.run();
}
Hope this helps a bit
Ralf
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]