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
This commit is contained in:
John Jenko 2023-01-20 17:18:31 +00:00
parent 4617b63f43
commit d4c64c9920
2 changed files with 67 additions and 6 deletions

View File

@ -268,6 +268,19 @@ namespace VEPROMS.CSLA.Library
} }
} }
#endregion #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<bool> _DontInsertBlankPages;
public bool DontInsertBlankPages
{
get
{
return LazyLoad(ref _DontInsertBlankPages, "@DontInsertBlankPages");
}
}
#endregion
#region CenterLine #region CenterLine
//CenterLineX="261.9" CenterLineYTop="673.2" CenterLineYBottom="44.2" //CenterLineX="261.9" CenterLineYTop="673.2" CenterLineYBottom="44.2"
private LazyLoad<float?> _CenterLineX; private LazyLoad<float?> _CenterLineX;

View File

@ -1048,7 +1048,9 @@ namespace Volian.Print.Library
else if (!_MyHelper.CreatingFoldoutPage && _MyFoldoutReader.Count > 0 && InsertBlankPages) 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 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) // 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 // and the checkbox on the print dialog to add blank pages is checked
@ -1132,22 +1134,30 @@ namespace Volian.Print.Library
return outputFileName; return outputFileName;
} }
public void InsertBlankPage(PdfContentByte cb) public void InsertBlankPage(PdfContentByte cb, bool backOfLastPageOfSection = false)
{ {
_MyHelper.OnBlankPage = true; _MyHelper.OnBlankPage = true;
string baselinemsg = "==Insert Blank Page=="; string baselinemsg = "==Insert Blank Page==";
if (_BlankPageText != null && _BlankPageText != "") // C2019-004: Allow user to define duplex blank page text 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; string bsfontfamily = MyItem.ActiveFormat.PlantFormat.FormatData.StepDataList[0].Font.Family;
int bsfontsize = 26; 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)); 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); PrintTextMessage(cb, _BlankPageText, _TextLayer, font);
if (_MyHelper.IsLandscape)
cb.RestoreState();
// B2019-019: Add the blank page message to the baseline output file. // B2019-019: Add the blank page message to the baseline output file.
baselinemsg = string.Format("==Insert Blank Page With Message \"{0}\"==", _BlankPageText); baselinemsg = string.Format("==Insert Blank Page With Message \"{0}\"==", _BlankPageText);
} }
else else
cb.PdfDocument.Add(new iTextSharp.text.Table(1)); 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); Volian.Base.Library.BaselineMetaFile.WriteLine(baselinemsg);
} }
@ -1277,11 +1287,37 @@ namespace Volian.Print.Library
OnStatusChanged("Read MSWord", PromsPrinterStatusType.ReadMSWord); OnStatusChanged("Read MSWord", PromsPrinterStatusType.ReadMSWord);
if (doimport2) 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) // 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 // 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); //_MyLog.InfoFormat("NewPage 3 blank {0}", cb.PdfWriter.CurrentPageNumber);
} }
float yoff = 0; float yoff = 0;
@ -1353,7 +1389,19 @@ namespace Volian.Print.Library
_MyHelper.IsLandscape = true; _MyHelper.IsLandscape = true;
else else
_MyHelper.IsLandscape = false; _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); //_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 // if this document style has another style that is for pages other than first, we need to