diff --git a/PROMS/Volian.Print.Library/Pagination.cs b/PROMS/Volian.Print.Library/Pagination.cs index 029b7682..9927e0c1 100644 --- a/PROMS/Volian.Print.Library/Pagination.cs +++ b/PROMS/Volian.Print.Library/Pagination.cs @@ -243,12 +243,31 @@ namespace Volian.Print.Library // ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); if (MyPageHelper.DidFirstPageDocStyle && (MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnAllButFirstPage) > 0) yPageSizeNextPage = GetYPageSizeUseOnAllButFirstPage(); - if (KeepStepsOnPage && !MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.PaginateOnLowerStepLevel && YSize == ySizeIncludingFirst && YSize + yEndMsg > yWithinMargins) + + if (KeepStepsOnPage + && !MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.PaginateOnLowerStepLevel + && YSize == ySizeIncludingFirst + && YSize + yEndMsg > yWithinMargins) { // If the first step is the size of the entire step and the step has an end message then don't try to break the step KeepStepsOnPage = false; //_MyLog.WarnFormat("Kick Step to Next Page {0},{1}", MyItemInfo.ItemID, MyItemInfo.ShortPath); } + if (yWithinMargins < SixLinesPerInch) KeepStepsOnPage = false; // if there is no room to print, don't keep steps on the page + // The following was added for IP2 background printing. There were situations where there was a HLS and its paragraph was + // put on next page (IP2 bck: E-3/References), and a paragraph was writing into the footer (FR-H.1 step 2.2.3.1. KBR 10/14/14) + if (KeepStepsOnPage + && MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.StepSectionLayoutData.PaginateOnLowerStepLevel + && YSize == ySizeIncludingFirst + && ((ChildrenBelow.Count >= 1 && ChildrenBelow[0].MyItemInfo.IsParagraph && ChildrenBelow[0].ChildrenBelow.Count == 0) + || ChildrenBelow.Count == 0)) + { + KeepStepsOnPage = false; + } + + // Keep figure (the only figure, i.e. count==1) with its parent. + if (ChildrenBelow.Count == 1 && ChildrenBelow[0].MyItemInfo.IsFigure) KeepStepsOnPage = false; + if (!KeepWithHeader && !KeepStepsOnPage && YSize - SixLinesPerInch + yEndMsg <= yPageSizeNextPage) // if the entire step can fit on one page, do a page break { // Don't want extra line before step diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index f8d597a7..dff0edc8 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -2055,6 +2055,8 @@ namespace Volian.Print.Library return ItemInfo.RomanNumbering(CurrentPageNumber).ToLower(); case "{SETREV}": return MySection.MyDocVersion.DocVersionConfig.ProcedureSetRev; + case "{NULLDOCCURPAGE}": + return ""; } if (!_MissingTokens.Contains(match.Value)) { diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index 54eb1f5b..b08d2709 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -795,7 +795,11 @@ namespace Volian.Print.Library yPageStart = yTopMargin + YVeryTop; yLocation = yPageStart - YOffset; // yLocation is physical location from bottom of page. } - if (yLocation - Height < 24) _MyLog.WarnFormat("Very Low {0},{1},{2},{3},{4},{5}",MyItemInfo.ShortPath,MyItemInfo.ItemID,yLocation,Height,yLocation-Height,yTopMargin - MyItemInfo.MyDocStyle.Layout.PageLength); + if (yLocation - Height < 24) + { + if (DebugPagination.IsOpen) + DebugPagination.WriteLine("Very Low {0},{1},{2},{3},{4},{5}", MyItemInfo.ShortPath, MyItemInfo.ItemID, yLocation, Height, yLocation - Height, yTopMargin - MyItemInfo.MyDocStyle.Layout.PageLength); + } retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo + string.Format(",YLines = {0}",YSize/SixLinesPerInch), yBottomMargin); if (retval == 0) // problem occurred - paragraph was not able to be printed on page { // pagination logic needs to be fixed. @@ -1918,6 +1922,13 @@ namespace Volian.Print.Library get { return _Suffix; } set { _Suffix = value; } } + private float RoughSizeOfPage + { + get + { + return (float)(MyItemInfo.MyDocStyle.Layout.PageLength - MyItemInfo.MyDocStyle.Layout.TopMargin - MyItemInfo.MyDocStyle.Layout.FooterLength); + } + } public vlnParagraph(vlnParagraph parent, PdfContentByte cb, ItemInfo itemInfo, float xoff, float yoff, int rnoLevel, int maxRNO, FormatInfo formatInfo, string prefix, string suffix, float yoffRightParent, bool loadChildren) { Prefix = prefix; @@ -2393,7 +2404,10 @@ namespace Volian.Print.Library string[] vals = val.Split("\n".ToCharArray()); Width = Int32.Parse(vals[3], System.Globalization.NumberStyles.AllowHexSpecifier) * MyItemInfo.FormatStepData.Font.CharsToTwips; int lines = Int32.Parse(vals[2], System.Globalization.NumberStyles.AllowHexSpecifier); - Height = lines * SixLinesPerInch; + // Check that the Height of figure isn't too big to fit on the page, if it is + // set the Height to the printable part of page - Height of the HLS and an extra line + // for between HLS & figure. + Height = Math.Min(lines * SixLinesPerInch, RoughSizeOfPage - MyParent.Height - SixLinesPerInch); //yForCheckoff = yoff + Height - SixLinesPerInch; if (dropCheckoff) yForCheckoff += Height - SixLinesPerInch; // place checkoff on last row of text