> How to stop a render FOP ?

Philippe,

        I'm going to assume that you want a human or a program to stop a FOP run
that is embedded in a program that should otherwise remain running.  If you
mean the command line, you can, of course, use ^C or whatever interrupt
command is appropriate to your shell.

        It would be preferable to be able to run FOP in a separate thread, and 
then
set some flag from the main thread that FOP would notice and abort on.  If
such a simple, programmatic mechanism for doing this exists, I don't know of
it.

        I have been able to implement the following though....

        I wanted to put up a modal progress dialog that would indicate how many
pages have been rendered thus far.  I did this by creating
ProgressDialogLogger, an implementation of the
org.apache.avalon.framework.logger.Logger interface, and set it as the
logger for the rendering run.

        Then, from the main thread I put up the modal progress dialog with an
initial message of "Initializing...".  Then I launch FOP in a separate
thread.

        Every time FOP logs a message, particularly the INFO messages counting 
off
the rendered pages, I update the message in the progress dialog.  When FOP
finishes, the dialog is disposed of.

        That all worked fine.  Then I wanted to put a "Cancel" button on the
dialog.

        The Cancel button sets a flag on the ProgressDialogLogger.  The next 
time
that FOP attempts to log a message, the ProgressDialogLogger notices this
flag and throws a "CancelError", a subclass of Error.  I chose an Error
subclass on the assumption that FOP would not have any "catch (Error error)"
blocks, which appears correct.

        Then, my background thread running FOP catches the CancelError, closes 
the
streams it opened for FOP, disposes of the progress dialog, and exits.

        Hope this helps.

Patrick Rusk


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to