From 92eb33c044e5474167411062a59b707fbd5a1882 Mon Sep 17 00:00:00 2001 From: Rich Date: Wed, 29 Nov 2017 15:35:48 +0000 Subject: [PATCH] B2017-264 Limit Right Margin and Bottom Margin so that they cannot be negative.This was causing a problem when a Landscape section was added. --- PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index ca4bfe25..1ce50415 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -1382,15 +1382,19 @@ namespace VEPROMS.CSLA.Library else { myDoc.PageSetup.TopMargin = 0; - myDoc.PageSetup.LeftMargin = 0; - myDoc.PageSetup.RightMargin = (8.5F * 72) - newWidth + newLeft; + myDoc.PageSetup.LeftMargin = 0;// B2017-264 Limit the value for right margin so that it cannot be negative. + float rm = (8.5F * 72) - newWidth + newLeft; + myDoc.PageSetup.RightMargin = Math.Max(0,rm); // For OHLP, docstyle (ohlpdoc.in) in 16-bit for "Cover Page", pagelen seems to be incorrect. It would // put out text on a second page. The following code is to catch this condition and reset the bottom margin. // 11 * 72 -> 11 inches converted to points. newLength is printable part so BottomMargin is unprintable part + float bm; if (newTop + 36 > ((11 * 72) - newLength)) // 36 is 1/2 inch - myDoc.PageSetup.BottomMargin = newTop + 36; // makes an 1/2 inch bottom margin + bm = newTop + 36; // makes an 1/2 inch bottom margin else - myDoc.PageSetup.BottomMargin = (11 * 72) - newLength; + bm = (11 * 72) - newLength; + // B2017-264 Limit the value for bottom margin so that it cannot be negative + myDoc.PageSetup.BottomMargin = Math.Max(0, bm); } } public static void CloseApp()