Class FoUtils


  • public class FoUtils
    extends java.lang.Object
    FO Sink utilities.
    Since:
    1.1
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static javax.xml.transform.TransformerFactory TRANSFORMER_FACTORY
      To reuse the TransformerFactory
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private FoUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void convertFO2PDF​(java.io.File fo, java.io.File pdf, java.lang.String resourceDir)
      Converts an FO file to a PDF file using FOP.
      static void convertFO2PDF​(java.io.File fo, java.io.File pdf, java.lang.String resourceDir, DocumentModel documentModel)
      Converts an FO file to a PDF file using FOP.
      private static java.net.URI getBaseURI​(java.io.File fo, java.lang.String resourceDir)
      Returns a base URI.
      private static void prepareUserAgent​(org.apache.fop.apps.FOUserAgent foUserAgent, DocumentModel documentModel)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TRANSFORMER_FACTORY

        private static final javax.xml.transform.TransformerFactory TRANSFORMER_FACTORY
        To reuse the TransformerFactory
    • Constructor Detail

      • FoUtils

        private FoUtils()
    • Method Detail

      • prepareUserAgent

        private static void prepareUserAgent​(org.apache.fop.apps.FOUserAgent foUserAgent,
                                             DocumentModel documentModel)
      • convertFO2PDF

        public static void convertFO2PDF​(java.io.File fo,
                                         java.io.File pdf,
                                         java.lang.String resourceDir,
                                         DocumentModel documentModel)
                                  throws javax.xml.transform.TransformerException
        Converts an FO file to a PDF file using FOP.
        Parameters:
        fo - the FO file, not null.
        pdf - the target PDF file, not null.
        resourceDir - The base directory for relative path resolution, could be null. If null, defaults to the parent directory of fo.
        documentModel - the document model to add PDF metadatas like author, title and keywords, could be null.
        Throws:
        javax.xml.transform.TransformerException - In case of a conversion problem.
        Since:
        1.1.1
      • convertFO2PDF

        public static void convertFO2PDF​(java.io.File fo,
                                         java.io.File pdf,
                                         java.lang.String resourceDir)
                                  throws javax.xml.transform.TransformerException
        Converts an FO file to a PDF file using FOP.
        Parameters:
        fo - the FO file, not null.
        pdf - the target PDF file, not null.
        resourceDir - The base directory for relative path resolution, could be null. If null, defaults to the parent directory of fo.
        Throws:
        javax.xml.transform.TransformerException - In case of a conversion problem.
        See Also:
        convertFO2PDF(File, File, String, DocumentModel)
      • getBaseURI

        private static java.net.URI getBaseURI​(java.io.File fo,
                                               java.lang.String resourceDir)
        Returns a base URI.
        Parameters:
        fo - the FO file.
        resourceDir - the resource directory.
        Returns:
        URI.