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);