*
* The spacing between the last four regions and the fo:region-body is determined by subtracting
* the relevant extent trait on the side regions from the trait that corresponds to the "margin-x"
* property on the fo:region-body.
*/
RegionBody rb = getFactory().createRegionBody();
rb.setMarginLeft("0mm");
rb.setMarginRight("0mm");
float halfPageHeight = page.getPgSz().getH().intValue()/40; // convert from twips, then * 0.5
String halfPageHeightPts = halfPageHeight + "pt";
spm.setRegionBody(rb);
if (needBefore) {
//Header
RegionBefore rBefore = getFactory().createRegionBefore();
rBefore.setRegionName("xsl-region-before-"+appendRegionName);
spm.setRegionBefore(rBefore);
// Margin top on SPM is space between the page edge and the start of the header
int marginTopTwips
= page.getHeaderMargin();
spm.setMarginTop( UnitsOfMeasurement.twipToBest(marginTopTwips ) );
// Size header manually
rBefore.setExtent( halfPageHeightPts); // A4 portrait is 297mm high
// Leave room for this region in body margin
rb.setMarginTop(halfPageHeightPts);
} else {
// No header
spm.setMarginTop( UnitsOfMeasurement.twipToBest(page.getPgMar().getTop().intValue() ) );
}
if (needAfter) {
// Footer
RegionAfter rAfter = getFactory().createRegionAfter();
rAfter.setRegionName("xsl-region-after-"+appendRegionName);
spm.setRegionAfter(rAfter);
int marginBottomTwips= page.getFooterMargin();
spm.setMarginBottom( UnitsOfMeasurement.twipToBest(marginBottomTwips) );
// Size footer manually
rAfter.setExtent( halfPageHeightPts); // A4 portrait is 297mm high
// Leave room for this region in body margin
rb.setMarginBottom(halfPageHeightPts );
} else {
// No footer
spm.setMarginBottom( UnitsOfMeasurement.twipToBest(page.getPgMar().getBottom().intValue()) );
}