- wxRect pageMarginsRect(paperRect.x + wxRound(mmToDeviceX * topLeft.x),
- paperRect.y + wxRound(mmToDeviceY * topLeft.y),
- paperRect.width - wxRound(mmToDeviceX * (topLeft.x + bottomRight.x)),
+
+ // paper size in device units
+ wxRect paperRect = GetPaperRectPixels();
+
+ // margins in mm
+ wxPoint topLeft = pageSetupData.GetMarginTopLeft();
+ wxPoint bottomRight = pageSetupData.GetMarginBottomRight();
+
+ // calculate margins in device units
+ wxRect pageMarginsRect(
+ paperRect.x + wxRound(mmToDeviceX * topLeft.x),
+ paperRect.y + wxRound(mmToDeviceY * topLeft.y),
+ paperRect.width - wxRound(mmToDeviceX * (topLeft.x + bottomRight.x)),