/** * Returns a new {@link Fop} instance. Use this factory method if you want to supply your * own {@link org.apache.fop.render.Renderer Renderer} or * {@link org.apache.fop.fo.FOEventHandler FOEventHandler} * instance instead of the default ones created internally by FOP. * @param userAgent the user agent that will be used to control the rendering run * @return the new Fop instance * @throws FOPException when the constructor fails */ public Fop newFop(FOUserAgent userAgent) throws FOPException { if (userAgent.getRendererOverride() == null && userAgent.getFOEventHandlerOverride() == null && userAgent.getDocumentHandlerOverride() == null) { throw new IllegalStateException("An overriding renderer," + " FOEventHandler or IFDocumentHandler must be set on the user agent" + " when this factory method is used!"); } return newFop(null, userAgent); }
/** * Creates a {@link IFDocumentHandler} object based on the desired output format. * @param userAgent the user agent for access to configuration * @param outputFormat the MIME type of the output format to use (ex. "application/pdf"). * @return the new {@link IFDocumentHandler} instance * @throws FOPException if the document handler cannot be properly constructed */ public IFDocumentHandler createDocumentHandler(FOUserAgent userAgent, String outputFormat) throws FOPException { if (userAgent.getDocumentHandlerOverride() != null) { return userAgent.getDocumentHandlerOverride(); } AbstractIFDocumentHandlerMaker maker = getDocumentHandlerMaker(outputFormat); if (maker == null) { throw new UnsupportedOperationException( "No IF document handler for the requested format available: " + outputFormat); } IFDocumentHandler documentHandler = maker.makeIFDocumentHandler(new IFContext(userAgent)); // TODO: do all the configuration in the makeIfDocumentHandler method, that would beam when // you ask for a document handler, a configured one is returned to you. Getting it and // configuring it in two steps doesn't make sense. IFDocumentHandlerConfigurator configurator = documentHandler.getConfigurator(); if (configurator != null) { configurator.configure(documentHandler); } return new EventProducingFilter(documentHandler, userAgent); }
if (userAgent.getDocumentHandlerOverride() != null) { return createRendererForDocumentHandler(userAgent.getDocumentHandlerOverride()); } else if (userAgent.getRendererOverride() != null) { return userAgent.getRendererOverride();
AbstractIFDocumentHandlerMaker documentHandlerMaker = null; boolean outputStreamMissing = (userAgent.getRendererOverride() == null) && (userAgent.getDocumentHandlerOverride() == null); if (rendMaker == null) { documentHandlerMaker = getDocumentHandlerMaker(outputFormat); || userAgent.getDocumentHandlerOverride() != null || documentHandlerMaker != null) { if (outputStreamMissing) {