Package org.docx4j.convert.out
Interface FORenderer
public interface FORenderer
The pdf conversion process needs a fo renderer to convert the
fo document into the requested format. The fo renderer is encapsulated in
this interface.
The FORenderer can be: 1. The default ApacheFORenderer that gets used if no custom FORenderer has been passed. This renderer contains the functionality and replaces the classes FopFactoryUtil and FopResultUtils. The configuration and the result mime is passed via the FOSettings. 2. A custom implementation of the FORenderer interface that gets passed via the FOSettings to the conversion process. 3. The DummyFORenderer, that gets used if INTERNAL_FO_MIME has been selected as the output format in apacheFopMime. Passing the INTERNAL_FO_MIME as the result mime acts as a flag, it selects the DummyFORenderer and ensures that the rendering is done as a one pass process (in this case, the result might not be correct, since a two pass conversion may be necessary). The DummyFORenderer itself just passes the generated fo to the output stream. The conversion process might need a two pass conversion, if this is the case, then the body of some elements might contain a placeholder that needs to be replaced with the page count in the document or the page count in the section. A placeholder for the page count of the document is defined as
A placeholder for the page count of a section is defined as
The values need to be calculated by the renderer and the placeholder replaced. The format of the numbers is defined for the page count of the document by getDocumentPageCountFoFormat() and the one for the section by getSectionPageCountFoFormat();
The FORenderer can be: 1. The default ApacheFORenderer that gets used if no custom FORenderer has been passed. This renderer contains the functionality and replaces the classes FopFactoryUtil and FopResultUtils. The configuration and the result mime is passed via the FOSettings. 2. A custom implementation of the FORenderer interface that gets passed via the FOSettings to the conversion process. 3. The DummyFORenderer, that gets used if INTERNAL_FO_MIME has been selected as the output format in apacheFopMime. Passing the INTERNAL_FO_MIME as the result mime acts as a flag, it selects the DummyFORenderer and ensures that the rendering is done as a one pass process (in this case, the result might not be correct, since a two pass conversion may be necessary). The DummyFORenderer itself just passes the generated fo to the output stream. The conversion process might need a two pass conversion, if this is the case, then the body of some elements might contain a placeholder that needs to be replaced with the page count in the document or the page count in the section. A placeholder for the page count of the document is defined as
PLACEHOLDER_PREFIX + getDocumentPageCountID() + PLACEHOLDER_SUFFIX
A placeholder for the page count of a section is defined as
PLACEHOLDER_PREFIX + getSectionPageCountID() + PLACEHOLDER_SUFFIX
The values need to be calculated by the renderer and the placeholder replaced. The format of the numbers is defined for the page count of the document by getDocumentPageCountFoFormat() and the one for the section by getSectionPageCountFoFormat();
- Since:
- 3.0
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
FORenderer.SectionPageInformation
The definition for the IDs and formats for the page count of one Section. -
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PLACEHOLDER_PREFIX
static java.lang.String
PLACEHOLDER_SUFFIX
-
Method Summary
Modifier and Type Method Description void
render(java.lang.String foDocument, FOSettings settings, boolean twoPass, java.util.List<FORenderer.SectionPageInformation> pageNumberInformation, java.io.OutputStream outputStream)
Render the foDocument to the requested format, if needed do a 2 pass conversion.
-
Field Details
-
PLACEHOLDER_PREFIX
static final java.lang.String PLACEHOLDER_PREFIX- See Also:
- Constant Field Values
-
PLACEHOLDER_SUFFIX
static final java.lang.String PLACEHOLDER_SUFFIX- See Also:
- Constant Field Values
-
-
Method Details
-
render
void render(java.lang.String foDocument, FOSettings settings, boolean twoPass, java.util.List<FORenderer.SectionPageInformation> pageNumberInformation, java.io.OutputStream outputStream) throws Docx4JExceptionRender the foDocument to the requested format, if needed do a 2 pass conversion.- Parameters:
foDocument
- the fo document to be rendered.settings
- the conversion settings passed to the conversion processtwoPass
- a two pass rendering might be needed, i.e. the body of some tags contain placeholder How the renderer calculates the corresponding values and replaces them is its responsabilitypageNumberInformation
- This list contains an entry for each section in the document. It defines the IDs of the corresponding placeholders and the number format (as a fo format).
This List is only available if twoPass = true.outputStream
- The output stream on which the output should be rendered- Throws:
Docx4JException
-