diff --git a/PROMS/Volian.Print.Library/Pagination.cs b/PROMS/Volian.Print.Library/Pagination.cs index a1340ad6..a947479d 100644 --- a/PROMS/Volian.Print.Library/Pagination.cs +++ b/PROMS/Volian.Print.Library/Pagination.cs @@ -105,7 +105,18 @@ namespace Volian.Print.Library if ((MyItemInfo.IsCaution || MyItemInfo.IsNote) && MyItemInfo.MyParent.IsSubStep) { StepConfig scs = MyItemInfo.MyParent.MyConfig as StepConfig; - if (MyItemInfo.MyPrevious == null && scs.Step_PreferredPagebreak) return 2; + if (MyItemInfo.MyPrevious == null && scs.Step_PreferredPagebreak) + { + // B2018-103: The following flags a break within the step. Before returning a '2' (flags break within step), clear it out of the + // ParaBreaks. Without the 'RemoveAt', a page break will occur after this step also. + if (MyPageHelper.ParaBreaks != null && MyPageHelper.ParaBreaks.Count > 0 && this == MyPageHelper.ParaBreaks[0]) + { + MyPageHelper.ParaBreaks.RemoveAt(0); + string reason1 = AddReason("Partial Step - Case 5"); + ShowPageBreak(1, reason1, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); + } + return 2; + } } // Now see if there is a preferred page break on this step. StepConfig sci = MyItemInfo.MyConfig as StepConfig; @@ -189,8 +200,13 @@ namespace Volian.Print.Library ShowPageBreak(1, reason, "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); return 2; // break on this item within a step } - // PageBreakOnStep flags break for cautions/notes/HLS in backgrounds & deviations. - else if (!MyPageHelper.ParaBreaks[0].PageBreakOnStep && this.YTopMost > MyPageHelper.ParaBreaks[0].YTopMost) + /////////////////// + // The following else ifs are reached if something previously went wrong in pagination & this code tries to account for it. + /////////////////// + // PageBreakOnStep flags break for cautions/notes/HLS in backgrounds & deviations. Don't check for that case. + // If you are in this code debugging, consider looking at ToPdf to see why the 'pagebreak above' (MyPageHelper.ParaBreaks[0]) + // the current step (this) has not caused a page break in the pdf prior to reaching this code. (RHM & KBR) + else if (!MyPageHelper.ParaBreaks[0].PageBreakOnStep && this.YTopMost > MyPageHelper.ParaBreaks[0].YTopMost) // current step is further down on page than MyPageHelper.ParaBreaks[0] { MyPageHelper.ParaBreaks.RemoveAt(0); reason = AddReason("Partial Step - Case 3");