org.apache.fop.apps

## Class FopFactory

- java.lang.Object
- - org.apache.fop.apps.FopFactory

- All Implemented Interfaces:
    org.apache.xmlgraphics.image.loader.ImageContext

      public final class FopFactory
      extends Object
      implements org.apache.xmlgraphics.image.loader.ImageContext

  Factory class which instantiates new Fop and FOUserAgent instances. This class also holds environmental information and configuration used by FOP. Information that may potentially be different for each renderingq run can be found and managed in the FOUserAgent.

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addElementMapping(ElementMapping elementMapping)` Add the element mapping with the given class name.
    `ColorSpaceCache` | `getColorSpaceCache()` Returns the color space cache for this instance.
    `ContentHandlerFactoryRegistry` | `getContentHandlerFactoryRegistry()`
    `ElementMappingRegistry` | `getElementMappingRegistry()`
    `FontManager` | `getFontManager()`
    `Map<String,String>` | `getHyphenationPatternNames()`
    `InternalResourceResolver` | `getHyphenationResourceResolver()`
    `HyphenationTreeCache` | `getHyphenationTreeCache()`
    `Set<String>` | `getIgnoredNamespace()`
    `ImageHandlerRegistry` | `getImageHandlerRegistry()`
    `org.apache.xmlgraphics.image.loader.ImageManager` | `getImageManager()`
    `LayoutManagerMaker` | `getLayoutManagerMakerOverride()`
    `String` | `getPageHeight()`
    `String` | `getPageWidth()`
    `RendererFactory` | `getRendererFactory()`
    `float` | `getSourcePixelUnitToMillimeter()` Returns the conversion factor from pixel units to millimeters.
    `float` | `getSourceResolution()`
    `float` | `getTargetPixelUnitToMillimeter()` Returns the conversion factor from pixel units to millimeters.
    `float` | `getTargetResolution()`
    `Configuration` | `getUserConfig()` Get the user configuration.
    `XMLHandlerRegistry` | `getXMLHandlerRegistry()`
    `boolean` | `isBreakIndentInheritanceOnReferenceAreaBoundary()`
    `boolean` | `isNamespaceIgnored(String namespaceURI)`
    `Fop` | `newFop(FOUserAgent userAgent)` Returns a new `Fop` instance.
    `Fop` | `newFop(String outputFormat)` Returns a new `Fop` instance.
    `Fop` | `newFop(String outputFormat, FOUserAgent userAgent)` Returns a new `Fop` instance.
    `Fop` | `newFop(String outputFormat, FOUserAgent userAgent, OutputStream stream)` Returns a new `Fop` instance.
    `Fop` | `newFop(String outputFormat, OutputStream stream)` Returns a new `Fop` instance.
    `FOUserAgent` | `newFOUserAgent()` Returns a new FOUserAgent instance.
    `static FopFactory` | `newInstance(File fopConf)` Returns a new FopFactory instance that is configured using the `FopFactoryConfig` object that is created when the fopConf is parsed.
    `static FopFactory` | `newInstance(FopFactoryConfig config)` FOP has the ability, for some FO's, to continue processing even if the input XSL violates that FO's content model.
    `static FopFactory` | `newInstance(URI baseURI)` Returns a new FopFactory instance that is configured only by the default configuration parameters.
    `static FopFactory` | `newInstance(URI baseURI, InputStream confStream)` Returns a new FopFactory instance that is configured using the `FopFactoryConfig` object that is created when the fopConf is parsed.
    `boolean` | `validateStrictly()`
    `boolean` | `validateUserConfigStrictly()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### newInstance

          public static FopFactory newInstance(FopFactoryConfig config)

      FOP has the ability, for some FO's, to continue processing even if the input XSL violates that FO's content model. This is the default behavior for FOP. However, this flag, if set, provides the user the ability for FOP to halt on all content model violations if desired. Returns a new FopFactory instance that is configured using the `FopFactoryConfig` object.
      Parameters:
        `config` - the fop configuration
      Returns:
        the requested FopFactory instance.

    - #### newInstance

          public static FopFactory newInstance(File fopConf)
                                        throws SAXException,
                                               IOException

      Returns a new FopFactory instance that is configured using the `FopFactoryConfig` object that is created when the fopConf is parsed.
      Parameters:
        `fopConf` - the fop conf configuration file to parse
      Returns:
        the requested FopFactory instance.
      Throws:
        `IOException`
        `SAXException`

    - #### newInstance

          public static FopFactory newInstance(URI baseURI)

      Returns a new FopFactory instance that is configured only by the default configuration parameters.
      Parameters:
        `baseURI` - the base URI to resolve resource URIs against
      Returns:
        the requested FopFactory instance.

    - #### newInstance

          public static FopFactory newInstance(URI baseURI,
                                               InputStream confStream)
                                        throws SAXException,
                                               IOException

      Returns a new FopFactory instance that is configured using the `FopFactoryConfig` object that is created when the fopConf is parsed.
      Parameters:
        `baseURI` - the base URI to resolve resource URIs against
        `confStream` - the fop conf configuration stream to parse
      Returns:
        the requested FopFactory instance.
      Throws:
        `SAXException`
        `IOException`

    - #### newFOUserAgent

          public FOUserAgent newFOUserAgent()

      Returns a new FOUserAgent instance. Use the FOUserAgent to configure special values that are particular to a rendering run. Don't reuse instances over multiple rendering runs but instead create a new one each time and reuse the FopFactory.
      Returns:
        the newly created FOUserAgent instance initialized with default values

    - #### newFop

          public Fop newFop(String outputFormat)
                     throws FOPException

      Returns a new `Fop` instance. FOP will be configured with a default user agent instance.

      MIME types are used to select the output format (ex. "application/pdf" for PDF). You can use the constants defined in `MimeConstants`.

      Parameters:
        `outputFormat` - the MIME type of the output format to use (ex. "application/pdf").
      Returns:
        the new Fop instance
      Throws:
        `FOPException` - when the constructor fails

    - #### newFop

          public Fop newFop(String outputFormat,
                            FOUserAgent userAgent)
                     throws FOPException

      Returns a new `Fop` instance. Use this factory method if you want to configure this very rendering run, i.e. if you want to set some metadata like the title and author of the document you want to render. In that case, create a new `FOUserAgent` instance using `newFOUserAgent()`.

      MIME types are used to select the output format (ex. "application/pdf" for PDF). You can use the constants defined in `MimeConstants`.

      Parameters:
        `outputFormat` - the MIME type of the output format to use (ex. "application/pdf").
        `userAgent` - the user agent that will be used to control the rendering run
      Returns:
        the new Fop instance
      Throws:
        `FOPException` - when the constructor fails

    - #### newFop

          public Fop newFop(String outputFormat,
                            OutputStream stream)
                     throws FOPException

      Returns a new `Fop` instance. FOP will be configured with a default user agent instance. Use this factory method if your output type requires an output stream.

      MIME types are used to select the output format (ex. "application/pdf" for PDF). You can use the constants defined in `MimeConstants`.

      Parameters:
        `outputFormat` - the MIME type of the output format to use (ex. "application/pdf").
        `stream` - the output stream
      Returns:
        the new Fop instance
      Throws:
        `FOPException` - when the constructor fails

    - #### newFop

          public Fop newFop(String outputFormat,
                            FOUserAgent userAgent,
                            OutputStream stream)
                     throws FOPException

      Returns a new `Fop` instance. Use this factory method if your output type requires an output stream and you want to configure this very rendering run, i.e. if you want to set some metadata like the title and author of the document you want to render. In that case, create a new `FOUserAgent` instance using `newFOUserAgent()`.

      MIME types are used to select the output format (ex. "application/pdf" for PDF). You can use the constants defined in `MimeConstants`.

      Parameters:
        `outputFormat` - the MIME type of the output format to use (ex. "application/pdf").
        `userAgent` - the user agent that will be used to control the rendering run
        `stream` - the output stream
      Returns:
        the new Fop instance
      Throws:
        `FOPException` - when the constructor fails

    - #### newFop

          public Fop newFop(FOUserAgent userAgent)
                     throws FOPException

      Returns a new `Fop` instance. Use this factory method if you want to supply your own `Renderer` or `FOEventHandler` instance instead of the default ones created internally by FOP.
      Parameters:
        `userAgent` - the user agent that will be used to control the rendering run
      Returns:
        the new Fop instance
      Throws:
        `FOPException` - when the constructor fails

    - #### getRendererFactory

          public RendererFactory getRendererFactory()

      Returns:
        the RendererFactory

    - #### getXMLHandlerRegistry

          public XMLHandlerRegistry getXMLHandlerRegistry()

      Returns:
        the XML handler registry

    - #### getImageHandlerRegistry

          public ImageHandlerRegistry getImageHandlerRegistry()

      Returns:
        the image handler registry

    - #### getElementMappingRegistry

          public ElementMappingRegistry getElementMappingRegistry()

      Returns:
        the element mapping registry

    - #### getContentHandlerFactoryRegistry

          public ContentHandlerFactoryRegistry getContentHandlerFactoryRegistry()

      Returns:
        the content handler factory registry

    - #### addElementMapping

          public void addElementMapping(ElementMapping elementMapping)

      Add the element mapping with the given class name.
      Parameters:
        `elementMapping` - the class name representing the element mapping.

    - #### getImageManager

          public org.apache.xmlgraphics.image.loader.ImageManager getImageManager()

      See Also:
        `FopFactoryConfig.getImageManager()`

    - #### getLayoutManagerMakerOverride

          public LayoutManagerMaker getLayoutManagerMakerOverride()

      See Also:
        `FopFactoryConfig.getLayoutManagerMakerOverride()`

    - #### getHyphenationPatternNames

          public Map<String,String> getHyphenationPatternNames()

      See Also:
        `FopFactoryConfig.getHyphenationPatternNames()`

    - #### validateStrictly

          public boolean validateStrictly()

      See Also:
        `FopFactoryConfig.validateStrictly()`

    - #### isBreakIndentInheritanceOnReferenceAreaBoundary

          public boolean isBreakIndentInheritanceOnReferenceAreaBoundary()

      See Also:
        `FopFactoryConfig.isBreakIndentInheritanceOnReferenceAreaBoundary()`

    - #### getSourceResolution

          public float getSourceResolution()

      Specified by:
        `getSourceResolution` in interface `org.apache.xmlgraphics.image.loader.ImageContext`
      See Also:
        `FopFactoryConfig.getSourceResolution()`

    - #### getTargetResolution

          public float getTargetResolution()

      See Also:
        `FopFactoryConfig.getTargetResolution()`

    - #### getHyphenationResourceResolver

          public InternalResourceResolver getHyphenationResourceResolver()

    - #### getSourcePixelUnitToMillimeter

          public float getSourcePixelUnitToMillimeter()

      Returns the conversion factor from pixel units to millimeters. This depends on the desired source resolution.
      Returns:
        float conversion factor
      See Also:
        `getSourceResolution()`

    - #### getTargetPixelUnitToMillimeter

          public float getTargetPixelUnitToMillimeter()

      Returns the conversion factor from pixel units to millimeters. This depends on the desired target resolution.
      Returns:
        float conversion factor
      See Also:
        `getTargetResolution()`

    - #### getPageHeight

          public String getPageHeight()

      See Also:
        `FopFactoryConfig.getPageHeight()`

    - #### getPageWidth

          public String getPageWidth()

      See Also:
        `FopFactoryConfig.getPageWidth()`

    - #### isNamespaceIgnored

          public boolean isNamespaceIgnored(String namespaceURI)

      See Also:
        `FopFactoryConfig.isNamespaceIgnored(String)`

    - #### getIgnoredNamespace

          public Set<String> getIgnoredNamespace()

      See Also:
        `FopFactoryConfig.getIgnoredNamespaces()`

    - #### getUserConfig

          public Configuration getUserConfig()

      Get the user configuration.
      Returns:
        the user configuration

    - #### validateUserConfigStrictly

          public boolean validateUserConfigStrictly()

      See Also:
        `FopFactoryConfig.validateUserConfigStrictly()`

    - #### getFontManager

          public FontManager getFontManager()

      See Also:
        `FopFactoryConfig.getFontManager()`

    - #### getColorSpaceCache

          public ColorSpaceCache getColorSpaceCache()

      Returns the color space cache for this instance.

      Note: this method should not be considered as part of FOP's external API.

      Returns:
        the color space cache

    - #### getHyphenationTreeCache

          public HyphenationTreeCache getHyphenationTreeCache()

Copyright © 2023 Apache Software Foundation. All rights reserved.