CTM pageCTM = CTM.getCTMandRelDims(pageSeq.getReferenceOrientation(),
Constants.EN_LR_TB, referenceRect, reldims);
Page page = new Page(referenceRect, pageNumber, pageNumberString, isBlank);
PageViewport pv = page.getPageViewport();
org.apache.fop.area.Page pageArea = new org.apache.fop.area.Page();
pv.setPage(pageArea);
RegionViewport rv = new RegionViewport(referenceRect);
rv.setIPD(referenceRect.width);
rv.setBPD(referenceRect.height);
rv.setClip(true);
BodyRegion body = new BodyRegion(Constants.FO_REGION_BODY,
"fop-image-region", rv, 1, 0);
body.setIPD(imageSize.width);
body.setBPD(imageSize.height);
body.setCTM(pageCTM);
rv.setRegionReference(body);
pageArea.setRegionViewport(
Constants.FO_REGION_BODY, rv);
//Set unique key obtained from the AreaTreeHandler
pv.setKey(areaTreeHandler.generatePageViewportKey());
//Also creates first normal flow region
pv.createSpan(false);
return page;
}