Products Downloads


French version


Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

This macro must be called in the nested content of a hardisFO.foStaticContent macro. This macro is used to include an XSL-FO document fragment, i.e. other hardisFO.foxxx macros (or include the content of an .ftlx file containing an XSL-FO document fragment) in a <fo:static-content> tag, and to automatically update the physical space dedicated to it in the XSL-FO result document.

 


Remember: in an XSL-FO document definition, before (header), after (footer), start (column on the "left" side of the page) and end (column on the "right" side of the page) regions can be declared.

 


To create these regions in the document, you need to:

...

Pas de format
<@hardisFo.foStaticContent flowName="pageHeader"><#>
<#-- In this example, the <fo:static-content> content is divided into two sections to define the page header --><@hardisAdv.staticSection><#>
<@hardisAdv.staticSection>
	<#-- document fragment: un block --><@hardisFo>
	<@hardisFo.foBlock>I'm the block of the first section</@hardisFo.foBlock><foBlock>
</@hardisAdv.staticSection><@hardisAdv.staticSection><@hardisFostaticSection>
<@hardisAdv.staticSection>
	<@hardisFo.foBlock>I'm the block of the second section</@hardisFo.foBlock><@hardisAdvfoBlock>
<@hardisAdv.staticSection includeFile="subtemplate.ftlx"></@hardisAdv.staticSection><staticSection>
</@hardisAdv.staticSection><staticSection>
</@hardisFo.foStaticContent> 
And the subtemplate.ftlx sub-template contains the fragment:
<@hardisFo.foBlock>I'm the block from the sub template</@hardisFo.foBlock>

 


And the subtemplate.ftlx sub-template contains the fragment:

Pas de format
<@hardisFo.foBlock>I'm the block from the sub template</@hardisFo.foBlock>
Hardis - Haut de page

↑ Top of page

...


Section visibility

The display of a staticSection macro can be made conditional, i.e. allow its content to be dynamically displayed (on template execution): the Boolean-type "delete" parameter makes the display conditional. The "true" value indicates that the content will not be present in the result document (and "false" if content will be present).

Hardis - Haut de page

↑ Top of page

Section height

A height can be set to a staticSection macro using the "height" parameter. It must contain a height value as defined in standard XSL 1.1 (click here for more details). When the "height" parameter is set, the macro encapsulates its content in an <fo :block-container> tag. In this case, you need to make sure that the type of nested content may be inserted in an <fo:block-container> tag: Specification XSL 1.1 states that only <fo:block>, <fo:block-container>, <fo:table> and <fo:list-block> tags can be inside an <fo:block-container> tag (click here for more details). An invisible section ("delete" parameter is "false") has a height of 0.

 


For example

Pas de format
<@hardisAdv.staticSection height="2cm"><@hardisFo>
	<@hardisFo.foBlock>Content of section with height set</@hardisFo.foBlock><foBlock>
</@hardisAdv.staticSection> 

...


produces in the result document:

Pas de format
<fo:block-container height="2cm"><fo>
	<fo:block>Content of section with height set</fo:block><block>
</fo:block-container>

 



If the content of an <fo:static-content> tag is fully nested in one or more staticSection macros, when they are executed, the height of the content can be deduced by adding the heights of each section. In the case of nested staticSection macros, when a macro has a set height, the heights of nested macros are not taken into account in the final height calculation. 


Example 1:
Pas de format
<@hardisFo.foStaticContent><@hardisAdvfoStaticContent>
<@hardisAdv.staticSection height="2cm">...</@hardisAdv.staticSection><@hardisAdvstaticSection>
<@hardisAdv.staticSection height="1cm">...</@hardisAdv.staticSection><@hardisAdvstaticSection>
<@hardisAdv.staticSection height="4cm" delete=true>...</@hardisAdv.staticSection><staticSection>
</@hardisFo.foStaticContent> 

...


On execution, the total height is "2cm + 1cm".


Example 2
Pas de format
<@hardisFo.foStaticContent><@hardisAdv.staticSection><@hardisAdvfoStaticContent>
	<@hardisAdv.staticSection>
		<@hardisAdv.staticSection height="1cm">...</@hardisAdv.staticSection><@hardisAdvstaticSection>
		<@hardisAdv.staticSection height="40mm">...</@hardisAdv.staticSection><staticSection>
	</@hardisAdv.staticSection><@hardisAdvstaticSection>
	<@hardisAdv.staticSection height="12pt">...</@hardisAdv.staticSection><@hardisAdvstaticSection>
	<@hardisAdv.staticSection includeFile="subtemplate.ftlx"></@hardisAdv.staticSection><@hardisAdvstaticSection>
	<@hardisAdv.staticSection height="5cm"><@hardisAdv>
		<@hardisAdv.staticSection height="10cm">...</@hardisAdv.staticSection><staticSection>
	</@hardisAdv.staticSection><staticSection>
</@hardisFo.foStaticContent> 

...

Pas de format
<@hardisAdv.staticSection height="1cm">...</@hardisAdv.staticSection><@hardisAdvstaticSection>
<@hardisAdv.staticSection height="2.5cm" delete=true>...</@hardisAdv.staticSection>

 


On execution, the total height is "1cm + 40mm + 12pt + 1cm + 5cm".

Hardis - Haut de page

Top of page

Region updating

After executing a hardisFo.foStaticContent macro, if it contains staticSection macros, the total height of the sections is calculated automatically and propagated in the associated region declaration.

 


According to the value of the flowName parameter (which must contain a region name) and the reference to the current page master sequence (masterReference parameter of the hardisFo.foPageSequence macro encompassing the hardisFo.foStaticContent macro), it is possible to find the associated <fo:region-xxx> tag declaration as well as the corresponding <fo:region-body> tag and assign the calculated height value to "extent" and "marginxxx" attributes. 


This step only works if the regions concerned do not have a height already defined by the user: if the "extent" attribute is present in the <fo:region-xxx> tag, its value is not changed. Likewise, the margin-xxx attribute of the corresponding <fo:region-body> tag is not added.

...

Pas de format
<?xml version="1.0" encoding="utf-8"?><@hardisFo.foRoot><@hardisFo.foLayoutMasterSet><@hardisFo>
<@hardisFo.foRoot>
	<@hardisFo.foLayoutMasterSet>
		<@hardisFo.foSimplePageMaster masterName="sampleLayout" pageHeight="29.7cm" pageWidth="21cm" marginTop="2.5cm" marginBottom="2.5cm" marginLeft="1cm" marginRight="1cm"><@hardisFo>
			<@hardisFo.foRegionBody/><@hardisFo>
			<@hardisFo.foRegionBefore regionName="headerPage"/><@hardisFo>
			<@hardisFo.foRegionAfter regionName="footerPage"/><>
		</@hardisFo.foSimplePageMaster><foSimplePageMaster>
	</@hardisFo.foLayoutMasterSet><@hardisFofoLayoutMasterSet>
	<@hardisFo.foPageSequence masterReference="sampleLayout"><@hardisFo>
		<@hardisFo.foStaticContent flowName="headerPage"><@hardisAdv>
			<@hardisAdv.staticSection height="1cm"><@hardisFo>
				<@hardisFo.foBlock>Page header</@hardisFo.foBlock><foBlock>
			</@hardisAdv.staticSection><@hardisAdvstaticSection>
			<@hardisAdv.staticSection height="1cm"><@hardisFo>
				<@hardisFo.foBlock>My company</@hardisFo.foBlock><foBlock>
			</@hardisAdv.staticSection><staticSection>
		</@hardisFo.foStaticContent> 

		<@hardisFo.foStaticContent flowName="footerPage"><@hardisAdv>
			<@hardisAdv.staticSection height="1cm"><@hardisFo.foBlock>Page>
				<@hardisFo.foBlock>Page footer</@hardisFo.foBlock><foBlock>
			</@hardisAdv.staticSection><staticSection>
		</@hardisFo.foStaticContent> 

		<@hardisFo.foFlow flowName="xsl-region-body"><@hardisFo>
			<@hardisFo.foBlock>Page body</@hardisFo.foBlock><foBlock>
		</@hardisFo.foFlow><foFlow>
	</@hardisFo.foPageSequence><foPageSequence>
</@hardisFo.foRoot> 

...


Produces as a result:

Pas de format
<?xml version="1.0" encoding="UTFutf-8"?><fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"><fo:layout-master-set><fo:simple-page-master master-name="sampleLayout" margin-right="1cm" margin-bottom>
<@hardisFo.foRoot>
	<@hardisFo.foLayoutMasterSet>
		<@hardisFo.foSimplePageMaster masterName="sampleLayout" pageHeight="29.7cm" pageWidth="21cm" marginTop="2.5cm" page-heightmarginBottom="292.7cm5cm" page-widthmarginLeft="21cm1cm" margin-topmarginRight="2.5cm" margin-left="1cm"><fo:region-body margin-top="1cm+1cm" margin-bottom="1cm" margin-left="0pt" margin-right="0pt"/><fo:region-before region-name="headerPage" extent="1cm+1cm"/><fo:region-after region-name="footerPage" extent="1cm"/></fo:simple-page-master></fo:layout-master-set><fo:page-sequence master-reference="sampleLayout"><fo:static-content flow-name="headerPage"><fo:block-container height="1cm"><fo:block>Page header</fo:block></fo:block-container><fo:block-container height="1cm"><fo:block>My company</fo:block></fo:block-container></fo:static-content><fo:static-content flow-name="footerPage"><fo:block-container height="1cm"><fo:block>Page footer</fo:block></fo:block-container></fo:static-content><fo:flow flow-name1cm">
			<@hardisFo.foRegionBody/>
			<@hardisFo.foRegionBefore regionName="headerPage"/>
			<@hardisFo.foRegionAfter regionName="footerPage"/>
		</@hardisFo.foSimplePageMaster>
	</@hardisFo.foLayoutMasterSet>
	<@hardisFo.foPageSequence masterReference="sampleLayout">
		<@hardisFo.foStaticContent flowName="headerPage">
			<@hardisAdv.staticSection height="1cm">
				<@hardisFo.foBlock>Page header</@hardisFo.foBlock>
			</@hardisAdv.staticSection>
			<@hardisAdv.staticSection height="1cm">
				<@hardisFo.foBlock>My company</@hardisFo.foBlock>
			</@hardisAdv.staticSection>
		</@hardisFo.foStaticContent> 

		<@hardisFo.foStaticContent flowName="footerPage">
			<@hardisAdv.staticSection height="1cm">
				<@hardisFo.foBlock>Page footer</@hardisFo.foBlock>
			</@hardisAdv.staticSection>
		</@hardisFo.foStaticContent> 

		<@hardisFo.foFlow flowName="xsl-region-body"><fo:block>Page>
			<@hardisFo.foBlock>Page body</fo:block></fo:flow></fo:page-sequence></fo:root>@hardisFo.foBlock>
		</@hardisFo.foFlow>
	</@hardisFo.foPageSequence>
</@hardisFo.foRoot> 
Hardis - Haut de page

↑ Top of page

Page master type detection

...


An initial solution involves specifying the content of each <fo:static-content> tag corresponding to the chosen region and chosen page master type. 


For example

Pas de format
<?xml version="1.0" encoding="utf-8"?><@hardisFo.foRoot><@hardisFo.foLayoutMasterSet><#>
<@hardisFo.foRoot>
	<@hardisFo.foLayoutMasterSet>
		<#-- Page master declaration --> 

		<#-- "other" position-type page master --><@hardisFo>
		<@hardisFo.foSimplePageMaster masterName="otherPage" pageHeight="29.7cm" pageWidth="21cm" marginTop="1cm" marginBottom="1cm" marginLeft="2.5cm" marginRight="2.5cm"><@hardisFo>
			<@hardisFo.foRegionBody /><@hardisFo>
			<@hardisFo.foRegionBefore regionName="otherPageHeader" /><>
		</@hardisFo.foSimplePageMaster> 


		<#-- "first" position type page master --><@hardisFo>
		<@hardisFo.foSimplePageMaster masterName="firstPage"><@hardisFo>
			<@hardisFo.foRegionBody /><@hardisFo>
			<@hardisFo.foRegionBefore regionName="firstPageHeader" /></ />
		</@hardisFo.foSimplePageMaster> 
		
		<#-- "last" position type page master --><@hardisFo>
		<@hardisFo.foSimplePageMaster masterName="lastPage"><@hardisFo>
			<@hardisFo.foRegionBody /><@hardisFo>
			<@hardisFo.foRegionBefore regionName="lastPageHeader" /><>
		</@hardisFo.foSimplePageMaster> 


		<#-- Page master sequence declaration --><@hardisFo>
		<@hardisFo.foPageSequenceMaster masterName="allPage"><@hardisFo>
			<@hardisFo.foRepeatablePageMasterAlternatives maximumRepeats="no-limit"><#>
				<#-- The first page of the document will have "firstPage" as a page master --><@hardisFo>
				<@hardisFo.foConditionalPageMasterReference masterReference="firstPage" pagePosition="first" /><#>
				<#-- The last page of the docuement will have "lastPage" as a page master --><@hardisFo>
				<@hardisFo.foConditionalPageMasterReference masterReference="lastPage" pagePosition="last" /><#>
				<#-- The other pages of the document will have "otherPage" as a page master --><@hardisFo>
				<@hardisFo.foConditionalPageMasterReference masterReference="otherPage" pagePosition="rest" /><>
			</@hardisFo.foRepeatablePageMasterAlternatives><foRepeatablePageMasterAlternatives>
		</@hardisFo.foPageSequenceMaster><foPageSequenceMaster>
	</@hardisFo.foLayoutMasterSet> 

	<@hardisFo.foPageSequence masterReference="allPage"><#>
		<#-- Content of the page header of other pages --><@hardisFo>
		<@hardisFo.foStaticContent flowName="otherPageHeader"><@hardisAdv.staticSection><#"otherPageHeader">
			<@hardisAdv.staticSection>
				<#-- Specify the content of the page header of other pages here --><>
			</@hardisAdv.staticSection><staticSection>
		</@hardisFo.foStaticContent><#foStaticContent>
		<#-- Content of the page header of the first page --><@hardisFo>
		<@hardisFo.foStaticContent flowName="firstHeader"><@hardisAdv.staticSection><#>
			<@hardisAdv.staticSection>
			<#-- Specify the content of the page header of the first page here --><>
			</@hardisAdv.staticSection><staticSection>
		</@hardisFo.foStaticContent><#foStaticContent>
		<#-- Content of the page header of the last page --><@hardisFo>
		<@hardisFo.foStaticContent flowName="lastHeader"><@hardisAdv.staticSection><#>
			<@hardisAdv.staticSection>
			<#-- Specify the content of the page header of the last page here --><>
			</@hardisAdv.staticSection><staticSection>
		</@hardisFo.foStaticContent><#foStaticContent>
		<#-- Page body content --><@hardisFo>
		<@hardisFo.foFlow flowName="xsl-region-body">...</@hardisFo.foFlow><foFlow>
	</@hardisFo.foPageSequence><foPageSequence>
</@hardisFo.foRoot> 

 



If the content of three page headers (first, last and others) does not differ significantly, there will be content fragment duplication in the three hardisAdv.staticSection macros.

If content duplication causes a problem, a second solution involves factorizing the header content in a sub-template and including it in each section via the "includeFile" attribute. In a staticSection macro, the page master type linked to the region can be retrieved using the following (Boolean-type) variables:

Hardis - Tableau personnalisé
alternateColorstrue
firstLineHeadertrue
marginLeft30px

Variable name

Description

hardisAdv.isFirstPage

"true" if this macro is executed in an <fo:static-content> tag associated with a page master with a "first" or "only" or "any" position criterion.

hardisAdv.isLastPage

"true" if this macro is executed in an <fo:static-content> tag associated with a page master with a "last" or "only" or "any" position criterion.

hardisAdv.isMiddlePage

"true" if this macro is executed in an <fo:static-content> tag associated with a page master with a "rest" or "any" position criterion.

hardisAdv.isOddPage

"true" if this macro is executed in an <fo:static-content> tag associated with a page master with an "odd" or "any" parity criterion.

hardisAdv.isEvenPage

"true" if this macro is executed in an <fo:static-content> tag associated with a page master with an "even" or "any" parity criterion.

hardisAdv.isBlankPage

"true" if this macro is executed in an <fo:static-content> tag associated with a page master with a "blank" or "any" content criterion.

hardisAdv.isNotBlankPage

"true" if this macro is executed in an <fo:static-content> tag associated with a page master with a "not-blank" or "any" content criterion.



 For example

Pas de format
<?xml version="1.0" encoding="utf-8"?><@hardisFo.foRoot><@hardisFo.foLayoutMasterSet><#>
<@hardisFo.foRoot>
	<@hardisFo.foLayoutMasterSet>
		<#-- Page master declaration --> 
		<#-- "other" position-type page master --><@hardisFo>
		<@hardisFo.foSimplePageMaster masterName="otherPage" pageHeight="29.7cm" pageWidth="21cm" marginTop="1cm" marginBottom="1cm" marginLeft="2.5cm" marginRight="2.5cm"><@hardisFo>
			<@hardisFo.foRegionBody /><@hardisFo>
			<@hardisFo.foRegionBefore regionName="otherPageHeader" /><>
		</@hardisFo.foSimplePageMaster> 

		<#-- "first" position type page master --><@hardisFo>
		<@hardisFo.foSimplePageMaster masterName="firstPage"><@hardisFo>
			<@hardisFo.foRegionBody /><@hardisFo>
			<@hardisFo.foRegionBefore regionName="firstPageHeader" /><>
		</@hardisFo.foSimplePageMaster> 

		<#-- "last" position type page master --><@hardisFo-->
		<@hardisFo.foSimplePageMaster masterName="lastPage"><@hardisFo>
			<@hardisFo.foRegionBody /><@hardisFo>
			<@hardisFo.foRegionBefore regionName="lastPageHeader" /><>
		</@hardisFo.foSimplePageMaster> 

		<#-- Page master sequence declaration --><@hardisFo>
		<@hardisFo.foPageSequenceMaster masterName="allPage"><@hardisFo>
			<@hardisFo.foRepeatablePageMasterAlternatives maximumRepeats="no-limit"><#>
				<#-- The first page of the document will have "firstPage" as a page master --><@hardisFo>
				<@hardisFo.foConditionalPageMasterReference masterReference="firstPage" pagePosition="first" /><#>
				<#-- The last page of the document will have "lastPage" as a page master --><@hardisFo-->
				<@hardisFo.foConditionalPageMasterReference masterReference="lastPage" pagePosition="last" /><#>
				<#-- The other pages of the document will have "otherPage" as a page master --><@hardisFo>
				<@hardisFo.foConditionalPageMasterReference masterReference="otherPage" pagePosition="rest" /><>
			</@hardisFo.foRepeatablePageMasterAlternatives><foRepeatablePageMasterAlternatives>
		</@hardisFo.foPageSequenceMaster><foPageSequenceMaster>
	</@hardisFo.foLayoutMasterSet> 

	<@hardisFo.foPageSequence masterReference="allPage"><#>
		<#-- Content of the page header of other pages --><@hardisFo>
		<@hardisFo.foStaticContent flowName="otherPageHeader"><@hardisAdv>
			<@hardisAdv.staticSection includeFile="headerFirstLastRestPage.ftlx"><>
			</@hardisAdv.staticSection><staticSection>
		</@hardisFo.foStaticContent><#foStaticContent>
		<#-- Content of the page header of the first page --><@hardisFo>
		<@hardisFo.foStaticContent flowName="firstHeader"><@hardisAdv>
			<@hardisAdv.staticSection includeFile="headerFirstLastRestPage.ftlx"><>
			</@hardisAdv.staticSection><staticSection>
		</@hardisFo.foStaticContent><#foStaticContent>
		<#-- Content of the page header of the last page --><@hardisFo>
		<@hardisFo.foStaticContent flowName="lastHeader"><@hardisAdv>
			<@hardisAdv.staticSection includeFile="headerFirstLastRestPage.ftlx"><>
			</@hardisAdv.staticSection><staticSection>
		</@hardisFo.foStaticContent><#foStaticContent>
		<#-- Page body content --><@hardisFo>
		<@hardisFo.foFlow flowName="xsl-region-body">...</@hardisFo.foFlow><foFlow>
	</@hardisFo.foPageSequence<foPageSequence
</@hardisFo.foRoot> 

...


And the headerFirstLastRestPage.ftlx template contains:

Pas de format
<#if hardisAdv.isFirstPage><#isFirstPage>
	<#-- Specify the content for the first page --></#if><#if>
</#if>
<#if hardisAdv.isLastPage><#isLastPage>
	<#-- Specfify the content for the last page --></#if><#if>
</#if>
<#if hardisAdv.isMiddlePage><#isMiddlePage>
	<#-- Specify the content for the other pages --><>
</#if>

 

 




Empty directive: No

 


Parameters

Hardis - Tableau personnalisé
alternateColorstrue

Boolean

delete

Deletion of section and its content

Optional. The default value is "false"

String

height

Section height.

Optional.

String

includeFile

Relative path to an .ftlx sub-template.

Optional

...



 


For example

Pas de format
?<#-- Associate the "green" value to the color attribute --><@hardisFo>
<@hardisFo.foStaticContent flowName="headerPage"><#>
	<#-- Create a 1cm high conditional section --><@hardisAdv>
	<@hardisAdv.staticSection height="1cm" delete =.data_model.hideCopyright><@hardisFohideCopyright>
		<@hardisFo.foBlock>? My company 2018</@hardisFo.foBlock><foBlock>
	</@hardisAdv.staticSection><#staticSection>
	<#-- Create a dynamic section displaying the document authors with a header line and one author per line --><#>
	<#-- Section height=(Number of authors + 1) x line height --><#>
	<#-- In the section, the height of a line is set with the lineHeight attribute --><@hardisAdv>
	<@hardisAdv.staticSection height =((.data_model.authorsList?size + 1) * 12 + "pt") delete =(.data_model.authorsList?size == 0) lineHeight="12pt"><@hardisFo>
		<@hardisFo.foBlock>Authors of the document:</@hardisFo.foBlock><#listfoBlock>
		<#list.data_model.authorsList as aAuthor><@hardisFoaAuthor>
			<@hardisFo.foBlock> ${aAuthor} </@hardisFo.foBlock></#list><foBlock>
		</#list>
	</@hardisAdv.staticSection><staticSection>
</@hardisFo.foStaticContent>
Hardis - Haut de page

↑ Top of page