From fdead6e9981eb39bc16f8a84e5c4ba6a743dc1c8 Mon Sep 17 00:00:00 2001 From: Kathy Date: Thu, 3 Dec 2020 16:28:15 +0000 Subject: [PATCH] B2020-159: Pagination Problems (Forced Pagination) reported to user via dialog --- PROMS/Volian.Print.Library/Pagination.cs | 13 ++++- PROMS/Volian.Print.Library/PromsPrinter.cs | 61 +++++++++++++++++++--- 2 files changed, 66 insertions(+), 8 deletions(-) diff --git a/PROMS/Volian.Print.Library/Pagination.cs b/PROMS/Volian.Print.Library/Pagination.cs index d510efbc..6b4d36d3 100644 --- a/PROMS/Volian.Print.Library/Pagination.cs +++ b/PROMS/Volian.Print.Library/Pagination.cs @@ -807,8 +807,17 @@ namespace Volian.Print.Library //_MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination - ItemID = {0}\r\nLocation = '{1}'", MyItemInfo.ItemID, MyItemInfo.ShortPath); _MyLog.ErrorFormat("<<< ERROR >>> Forced Pagination\r\n==>'Forced Pagination',{0},'{1}','{2}'" , MyItemInfo.ItemID, MyItemInfo.MyDocVersion.MyFolder.Name, MyItemInfo.ShortPath); - if(DebugPagination.IsOpen) DebugPagination.WriteLine("=====>,'Yes','Forced Pagination',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.ShortPath); - if (BaselineMetaFile.IsOpen) BaselineMetaFile.WriteLine("!! =====>,'Yes','Forced Pagination',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.ShortPath); //C2018-015 add debug pagination to meta file + if (DebugPagination.IsOpen) DebugPagination.WriteLine("=====>,'Yes','Forced Pagination',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.ShortPath); + if (BaselineMetaFile.IsOpen) + BaselineMetaFile.WriteLine("!! =====>,'Yes','Forced Pagination',{0},{1},,{3},'{4}'", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.ShortPath); //C2018-015 add debug pagination to meta file + else + { + // B2020-159: If forced pagination errors occurred, add a description to be placed on a dialog after printing. + if (PromsPrinter.ForcedPaginations == null) PromsPrinter.ForcedPaginations = new List(); + string path = MyItemInfo.Path.Replace(MyItemInfo.MyProcedure.DisplayText, "").Replace(MyItemInfo.MyProcedure.DisplayNumber, "").TrimStart(" ,".ToCharArray()); + PromsPrinter.ForcedPaginations.Add(string.Format("{0}\t{1}\t{2}", MyPromsPrinter.PDFFile.Substring(0,MyPromsPrinter.PDFFile.IndexOf(".")), path, MyItemInfo.PageNumber)); + + } if (MyPromsPrinter.SupInfoPrintType == E_SupInfoPrintType.Merge && MyPageHelper.CreatingSupInfoPage) MyPromsPrinter.SupInfoPdfPageCount++; // this adjusts the page count offset when Forced Pagination occures in a SupInfo page retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo, yBottomMargin, MyItemInfo.ItemID); // C2018-004 ItemID for create meta file for baseline compares diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index 168b90b0..d10bb044 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -97,7 +97,7 @@ namespace Volian.Print.Library get { return _SupInfoPdfPage; } set { _SupInfoPdfPage = value; } } - private bool _DoingFacingPage = false; // used to flag actual pdf generation of facing page within final print (so no section titles get printed) + private bool _DoingFacingPage = false; // used to flag actual pdf generation of facing page within final print (so no section titles get printed) public bool DoingFacingPage { get { return _DoingFacingPage; } @@ -201,7 +201,7 @@ namespace Volian.Print.Library get { return _MyChangeBarDefinition; } set { _MyChangeBarDefinition = value; } } - private bool _OriginalPageBreak; // use 16bit page breaks. + private bool _OriginalPageBreak; // use 16bit page breaks. public bool OriginalPageBreak { get { return _OriginalPageBreak; } @@ -213,12 +213,40 @@ namespace Volian.Print.Library get { return _InsertBlankPages; } set { _InsertBlankPages = value; } } - private bool _BatchPrint = true; // flags that a batch-type print is occurring, i.e. AllProcedures or Automatic testing + private bool _BatchPrint = true; // flags that a batch-type print is occurring, i.e. AllProcedures or Automatic testing public bool BatchPrint { get { return _BatchPrint; } set { _BatchPrint = value; } } + // B2020-159: When printing, if forced pagination errors occurred (see Pagination.cs), put up a dialog with + // the places they occurred. Do not do this is running baseline/automatic print testing. + private static List _ForcedPaginations = null; + public static List ForcedPaginations + { + get { return PromsPrinter._ForcedPaginations; } + set { PromsPrinter._ForcedPaginations = value; } + } + public static DialogResult ReportForcedPaginations() + { + if (ForcedPaginations != null && ForcedPaginations.Count > 0) + { + string pnProbl = null; + foreach (string pstr in ForcedPaginations) + pnProbl = pnProbl + "\r\n" + pstr; + Clipboard.SetText(pnProbl); + return FlexibleMessageBox.Show( + "PROMS has identified location(s) in the PDF file that was created that may not have paginated correctly." + + "\r\nOn or around the following pages should be reviewed to ensure that the procedure is correct." + + "\r\nVerify that there is no missing text on the page(s) designated." + + "\r\nIf not correct, the procedure writer will have to modify the procedure content or add hard returns." + + "\r\nContact Volian if assistance is needed." + + "\r\nThe following list was placed on the Windows Clipboard." + + "\r\n\r\nPDF File\t\tSection/Step\t\t\tPDF Page No.\r\n" + pnProbl, + "Forced Pagination", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + return DialogResult.OK; + } private static List _TransPageNumProblems = null; public static List TransPageNumProblems { @@ -342,16 +370,30 @@ namespace Volian.Print.Library // the list StepSectPageBreaksForSupInfo off of the section object // Second pass prints the supplemental information pdfs using the list generated in the first pass to know where to do the // supplemental information page breaks & then merges in those pages when printing the step sections. - SectionInfo.ResetLookupStepSectPageBreaks(); // B2017-192: Reset lists for tracking page breaks + SectionInfo.ResetLookupStepSectPageBreaks(); // B2017-192: Reset lists for tracking page breaks SectionInfo.ResetLookupStepSectPageBreaksForSupInfo(); SupInfoPrintType = E_SupInfoPrintType.DoPageBreaks; string retstr = Print(_MyItem as ProcedureInfo, pdfFolder, false, false); if (retstr == null) return null; SupInfoPrintType = E_SupInfoPrintType.Merge; - return Print(_MyItem as ProcedureInfo, pdfFolder, false, false); + string tmps = Print(_MyItem as ProcedureInfo, pdfFolder, false, false); + if (!BatchPrint && ForcedPaginations != null && ForcedPaginations.Count > 0) // B2020-159: Forced Pagination Reporting + { + ReportForcedPaginations(); + ForcedPaginations.Clear(); + } + return tmps; } else // B2017-186 Neither Facing Pages or Page Number Transitions - return Print(_MyItem as ProcedureInfo, pdfFolder, makePlacekeeper, makeContinuousActionSummary); + { + string tmpss = Print(_MyItem as ProcedureInfo, pdfFolder, makePlacekeeper, makeContinuousActionSummary); + if (!BatchPrint && ForcedPaginations != null && ForcedPaginations.Count > 0) // B2020-159: Forced Pagination Reporting + { + ReportForcedPaginations(); + ForcedPaginations.Clear(); + } + return tmpss; + } } else // B2017-186 Page Number Transitions { @@ -380,6 +422,12 @@ namespace Volian.Print.Library ProcedureInfo.RefreshPageNumTransitions(_MyItem as ProcedureInfo); _MyReaderHelper = new ReaderHelper(this); retstr = Print(_MyItem as ProcedureInfo, pdfFolder, makePlacekeeper, makeContinuousActionSummary); + if (! BatchPrint && ForcedPaginations != null && ForcedPaginations.Count > 0) // B2020-159: Forced Pagination Reporting + { + ReportForcedPaginations(); + ForcedPaginations.Clear(); + } + if (TransPageNumProblems.Count > 0) { if (BatchPrint || (MessageBox.Show("Page Number Transitions may be fixed if a second pass is performed. Do you want to perform a second pass?", "Page Number Transition Errors", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)) @@ -685,6 +733,7 @@ namespace Volian.Print.Library private static List _MyFoldoutSection = null; private string Print(ProcedureInfo myProcedure, string pdfFolder, bool makePlacekeeper, bool makeContinuousActionSummary) { + if (_ForcedPaginations != null) _ForcedPaginations.Clear(); int profileDepth = ProfileTimer.Push(">>>> PromsPrinter.Print"); if (_TransPageNumProblems == null) _TransPageNumProblems = new List();