From d4c64c9920115d6cd557bd0f59d1766da4a363d4 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 20 Jan 2023 17:18:31 +0000 Subject: [PATCH] C2023-001 added DontInsertBlankPages document style for Beave Valley CAS sections C2023-001 logic to support to DontInsertBlankPages document style when inserting blank pages for duplex printing --- .../VEPROMS.CSLA.Library/Format/DocStyles.cs | 13 ++++ PROMS/Volian.Print.Library/PromsPrinter.cs | 60 +++++++++++++++++-- 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Format/DocStyles.cs b/PROMS/VEPROMS.CSLA.Library/Format/DocStyles.cs index a89e9835..56e820e3 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/DocStyles.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/DocStyles.cs @@ -268,6 +268,19 @@ namespace VEPROMS.CSLA.Library } } #endregion + #region DontInsertBlankPages + [Category("Miscellaneous")] + [Description("Don't insert blank pages in this section when printing duplex with blank pages")] + //C2023-001 Added for Beaver Valley CAS sections (their two column format) + private LazyLoad _DontInsertBlankPages; + public bool DontInsertBlankPages + { + get + { + return LazyLoad(ref _DontInsertBlankPages, "@DontInsertBlankPages"); + } + } + #endregion #region CenterLine //CenterLineX="261.9" CenterLineYTop="673.2" CenterLineYBottom="44.2" private LazyLoad _CenterLineX; diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index 2c4e3493..66fe8d78 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -1048,7 +1048,9 @@ namespace Volian.Print.Library else if (!_MyHelper.CreatingFoldoutPage && _MyFoldoutReader.Count > 0 && InsertBlankPages) { // if it is continuous pagination, don't do blank page - not sure if this is correct place for this: - if (mySection.SectionConfig.Section_Pagination == SectionConfig.SectionPagination.Separate) + // C2023-001 if the previous section has the flag to not insert blank pages, + // then don't insert a blank page between the previous section and this one + if (mySection.SectionConfig.Section_Pagination == SectionConfig.SectionPagination.Separate && !mySection.SearchPrev.MyDocStyle.DontInsertBlankPages) { // only insert a blank page if this section does not have a foldout (but the procedure as a whole does) // and the checkbox on the print dialog to add blank pages is checked @@ -1132,22 +1134,30 @@ namespace Volian.Print.Library return outputFileName; } - public void InsertBlankPage(PdfContentByte cb) + public void InsertBlankPage(PdfContentByte cb, bool backOfLastPageOfSection = false) { _MyHelper.OnBlankPage = true; string baselinemsg = "==Insert Blank Page=="; if (_BlankPageText != null && _BlankPageText != "") // C2019-004: Allow user to define duplex blank page text { + if (_MyHelper.IsLandscape) // rotate the blank page message on landscaped pages + { + cb.SaveState(); + System.Drawing.Drawing2D.Matrix myMatrix = new System.Drawing.Drawing2D.Matrix(0, 1, -1, 0, cb.PdfDocument.PageSize.Height, 0); + cb.Transform(myMatrix); + } string bsfontfamily = MyItem.ActiveFormat.PlantFormat.FormatData.StepDataList[0].Font.Family; int bsfontsize = 26; iTextSharp.text.Font font = FontFactory.GetFont(bsfontfamily, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, bsfontsize, iTextSharp.text.Font.NORMAL, new iTextSharp.text.Color(PrintOverride.TextColor)); PrintTextMessage(cb, _BlankPageText, _TextLayer, font); + if (_MyHelper.IsLandscape) + cb.RestoreState(); // B2019-019: Add the blank page message to the baseline output file. baselinemsg = string.Format("==Insert Blank Page With Message \"{0}\"==", _BlankPageText); } else cb.PdfDocument.Add(new iTextSharp.text.Table(1)); - NewPage(); + NewPage(backOfLastPageOfSection); // backOfLastPageOfSection = true means that next page starts next section and to use the next section's page size Volian.Base.Library.BaselineMetaFile.WriteLine(baselinemsg); } @@ -1277,11 +1287,37 @@ namespace Volian.Print.Library OnStatusChanged("Read MSWord", PromsPrinterStatusType.ReadMSWord); if (doimport2) { - if (((!didFoldout && _MyFoldoutReader.Count > 0) || mySection.MyProcedure.ProcHasSupInfoData) && cb.PdfWriter.CurrentPageNumber > 1 && InsertBlankPages) + if (((!didFoldout && _MyFoldoutReader.Count > 0 ) || mySection.MyProcedure.ProcHasSupInfoData) && cb.PdfWriter.CurrentPageNumber > 1 && InsertBlankPages) { + bool doInsertBlankPage = true; + SectionInfo currentSection = _MyHelper.MySection; + iTextSharp.text.Rectangle curRecSize = cb.PdfDocument.PageSize; // save current PDF Doc Page Size // only insert a blank page if this section does not have a foldout (but the procedure as a whole does) // and the checkbox on the print dialog to add blank pages is checked - InsertBlankPage(cb); + if (mySection.MyDocStyle.DontInsertBlankPages) + { + // C2023-001 we are going to print the first page of a section that we don't insert blank pages + // but we do need to insert a blank page for the back of the previous section's last page + doInsertBlankPage = (pageNumber == 1); + } + if (doInsertBlankPage) + { + // get the current and previous section page size + // pass in whether the page sizes are different so when a new page is started + // we use the correct page size + SectionInfo prevSection = (mySection.MyPrevious != null) ? (SectionInfo)mySection.MyPrevious : currentSection; + iTextSharp.text.Rectangle prevRecSize = MyReaderHelper.GetSize(prevSection, 1); + curRecSize = MyReaderHelper.GetSize(currentSection, 1); + if (prevSection != currentSection) + { + _MyHelper.MySection = prevSection; // make sure the back page that we are inserting is the correct page size + } + InsertBlankPage(cb, (prevRecSize != curRecSize)); + if (prevSection != currentSection) + { + _MyHelper.MySection = currentSection; + } + } //_MyLog.InfoFormat("NewPage 3 blank {0}", cb.PdfWriter.CurrentPageNumber); } float yoff = 0; @@ -1353,7 +1389,19 @@ namespace Volian.Print.Library _MyHelper.IsLandscape = true; else _MyHelper.IsLandscape = false; - NewPage(ii == sectPageCount-1); // Word Document + // C2023-001 put in for Beaver Valley, DontInsertBlankPages is use on their CAS sections, which inlucde a hard page break + // with text saying that page folds out. Some procedures also have a PROMS foldout section that is printed on the + // back of the procedure step pages. When we are printing duplex with blank pages, we don't want to insert a blank + // page between the two pages of the CAS section + // "pageForNextSection" is used to tell NewPage() if it needs to check the page size of the next section before starting the + // next page - this fixes an issue where the page we inserted for the backside of the previous section was the larger page + // size (11x17 vs 8x11) + bool pageForNextSection = (ii == sectPageCount - 1 && !InsertBlankPages); + if (mySection.MyDocStyle.DontInsertBlankPages && ii == sectPageCount - 1) // C2023-001 beaver valley CAS section type (has hard page break for back of page) + { + pageForNextSection = true; + } + NewPage(pageForNextSection); // Word Document //_MyLog.InfoFormat("NewPage 3 {0}", cb.PdfWriter.CurrentPageNumber); // if this document style has another style that is for pages other than first, we need to