Package org.apache.fop.render.ps
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 java.lang.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
ResourceHandler.IncludeResourceListener
-
Field Summary
Fields Modifier and Type Field Description private PSEventProducer
eventProducer
private FontInfo
fontInfo
private java.util.Map
globalFormResources
private java.util.Map
inlineFormResources
private static org.apache.commons.logging.Log
log
logging instanceprivate org.apache.xmlgraphics.ps.dsc.ResourceTracker
resTracker
private FOUserAgent
userAgent
-
Fields inherited from interface org.apache.xmlgraphics.ps.dsc.DSCParserConstants
COMMENT, DSC_COMMENT, EOF, HEADER_COMMENT, LINE
-
Fields inherited from interface org.apache.fop.render.ps.PSSupportedFlavors
LEVEL_2_FLAVORS_FORM, LEVEL_2_FLAVORS_INLINE, LEVEL_3_FLAVORS_FORM, LEVEL_3_FLAVORS_INLINE
-
-
Constructor Summary
Constructors Constructor Description ResourceHandler(FOUserAgent userAgent, PSEventProducer eventProducer, FontInfo fontInfo, org.apache.xmlgraphics.ps.dsc.ResourceTracker resTracker, java.util.Map formResources)
Main constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
determineInlineForms(java.util.Map formResources)
This method splits up the form resources map into two.private void
generateFormForImage(org.apache.xmlgraphics.ps.PSGenerator gen, PSImageFormResource form)
private void
generateForms(java.util.Map formResources, org.apache.xmlgraphics.ps.PSGenerator gen)
void
process(java.io.InputStream in, java.io.OutputStream out, int pageCount, java.awt.geom.Rectangle2D documentBoundingBox, PSRenderingUtil psUtil)
Rewrites the temporary PostScript file generated by PSRenderer adding all needed resources (fonts and images).private static void
registerSuppliedForms(org.apache.xmlgraphics.ps.dsc.ResourceTracker resTracker, java.util.Map formResources)
private static void
reportInvalidDSC()
-
-
-
Field Detail
-
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 java.util.Map globalFormResources
-
inlineFormResources
private java.util.Map inlineFormResources
-
-
Constructor Detail
-
ResourceHandler
public ResourceHandler(FOUserAgent userAgent, PSEventProducer eventProducer, FontInfo fontInfo, org.apache.xmlgraphics.ps.dsc.ResourceTracker resTracker, java.util.Map formResources)
Main constructor.- Parameters:
userAgent
- the FO user agenteventProducer
- the event producerfontInfo
- the font informationresTracker
- the resource tracker to useformResources
- Contains all forms used by this document (maintained by PSRenderer)
-
-
Method Detail
-
determineInlineForms
private void determineInlineForms(java.util.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(java.io.InputStream in, java.io.OutputStream out, int pageCount, java.awt.geom.Rectangle2D documentBoundingBox, PSRenderingUtil psUtil) throws org.apache.xmlgraphics.ps.dsc.DSCException, java.io.IOException
Rewrites the temporary PostScript file generated by PSRenderer adding all needed resources (fonts and images).- Parameters:
in
- the InputStream for the temporary PostScript fileout
- the OutputStream to write the finished file topageCount
- 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 filejava.io.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, java.util.Map formResources) throws java.io.IOException
- Throws:
java.io.IOException
-
generateForms
private void generateForms(java.util.Map formResources, org.apache.xmlgraphics.ps.PSGenerator gen) throws java.io.IOException
- Throws:
java.io.IOException
-
generateFormForImage
private void generateFormForImage(org.apache.xmlgraphics.ps.PSGenerator gen, PSImageFormResource form) throws java.io.IOException
- Throws:
java.io.IOException
-
-