Class ResourceHandler

java.lang.Object
org.apache.fop.render.ps.ResourceHandler
All Implemented Interfaces:
PSSupportedFlavors, org.apache.xmlgraphics.ps.dsc.DSCParserConstants

public class ResourceHandler extends Object implements org.apache.xmlgraphics.ps.dsc.DSCParserConstants, PSSupportedFlavors
This class is used when two-pass production is used to generate the PostScript file (setting "optimize-resources"). It uses the DSC parser from XML Graphics Commons to go over the temporary file generated by the PSRenderer and adds all used fonts and images as resources to the PostScript file.
  • Field Details

    • log

      private static org.apache.commons.logging.Log log
      logging instance
    • userAgent

      private FOUserAgent userAgent
    • fontInfo

      private FontInfo fontInfo
    • eventProducer

      private PSEventProducer eventProducer
    • resTracker

      private org.apache.xmlgraphics.ps.dsc.ResourceTracker resTracker
    • globalFormResources

      private Map globalFormResources
    • inlineFormResources

      private Map inlineFormResources
  • Constructor Details

    • ResourceHandler

      public ResourceHandler(FOUserAgent userAgent, PSEventProducer eventProducer, FontInfo fontInfo, org.apache.xmlgraphics.ps.dsc.ResourceTracker resTracker, Map formResources)
      Main constructor.
      Parameters:
      userAgent - the FO user agent
      eventProducer - the event producer
      fontInfo - the font information
      resTracker - the resource tracker to use
      formResources - Contains all forms used by this document (maintained by PSRenderer)
  • Method Details

    • determineInlineForms

      private void determineInlineForms(Map formResources)
      This method splits up the form resources map into two. One for global forms which have been referenced more than once, and one for inline forms which have only been used once. The latter is to conserve memory in the PostScript interpreter.
      Parameters:
      formResources - the original form resources map
    • process

      public void process(InputStream in, OutputStream out, int pageCount, Rectangle2D documentBoundingBox, PSRenderingUtil psUtil) throws org.apache.xmlgraphics.ps.dsc.DSCException, IOException
      Rewrites the temporary PostScript file generated by PSRenderer adding all needed resources (fonts and images).
      Parameters:
      in - the InputStream for the temporary PostScript file
      out - the OutputStream to write the finished file to
      pageCount - the number of pages (given here because PSRenderer writes an "(atend)")
      documentBoundingBox - the document's bounding box (given here because PSRenderer writes an "(atend)")
      psUtil -
      Throws:
      org.apache.xmlgraphics.ps.dsc.DSCException - If there's an error in the DSC structure of the PS file
      IOException - In case of an I/O error
    • reportInvalidDSC

      private static void reportInvalidDSC() throws org.apache.xmlgraphics.ps.dsc.DSCException
      Throws:
      org.apache.xmlgraphics.ps.dsc.DSCException
    • registerSuppliedForms

      private static void registerSuppliedForms(org.apache.xmlgraphics.ps.dsc.ResourceTracker resTracker, Map formResources) throws IOException
      Throws:
      IOException
    • generateForms

      private void generateForms(Map formResources, org.apache.xmlgraphics.ps.PSGenerator gen) throws IOException
      Throws:
      IOException
    • generateFormForImage

      private void generateFormForImage(org.apache.xmlgraphics.ps.PSGenerator gen, PSImageFormResource form) throws IOException
      Throws:
      IOException