We don't currently provide a way of gracefully stopping FOP in
mid-process. You could experiment with subclassing RenderPagesModel and
check for a "stop" boolean in addPage() and throw a RuntimeException.
For that you'll also have to subclass AreaTreeHandler. I'll just
copy/paste some code here I once used to play with CachedRenderPagesModel.
I'm sure you can adjust that to your needs.
private static class MyAreaTreeHandler extends AreaTreeHandler {
public MyAreaTreeHandler(FOUserAgent userAgent, String outputFormat,
OutputStream stream) throws FOPException {
super(userAgent, outputFormat, stream);
}
protected void setupModel(FOUserAgent userAgent, String outputFormat,
OutputStream stream) throws FOPException {
this.model = new CachedRenderPagesModel(userAgent,
outputFormat, fontInfo,
stream);
}
}
[..]
Fop fop = fopFactory.newFop(outputFormat, ua, out);
AreaTreeHandler atHandler = new MyAreaTreeHandler(ua,
outputFormat, out);
ua.setFOEventHandlerOverride(atHandler);
Maybe that helps.
On 21.07.2008 23:32:36 fletcher111 wrote:
>
> Hi Everyone,
>
> I am wondering if there is anyway to stop a FOP process once you have
> started it from Java.
>
> To be more exact I am using starting FOP in a new Thread in Java and then
> opening the window which the pdf which is generated will be shown. But if
> the user decides that is not what they wanted to do they close the window
> but it does not stop FOP. Yes I know that I could just kill the Thread but
> there is no fail-safe way to do that.
>
> Is there any way that I can tell FOP itself from the Java program that it
> should stop it's processing. I am not worried about keeping stuff that it
> has generated and it will be dropped automatically.
>
> Any help is great,
> Thanks,
> fletcher111
> --
> View this message in context:
> http://www.nabble.com/Stopping-FOP-in-Java-tp18578026p18578026.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
>
>
Jeremias Maerki
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]