C2024-002-Print-Section

This commit is contained in:
2024-01-25 09:18:48 -05:00
parent 9b59810c89
commit 0095b2883b
6 changed files with 278 additions and 197 deletions

View File

@@ -179,6 +179,12 @@ namespace Volian.Print.Library
get { return _PDFFile; }
set { _PDFFile = value; }
}
private int _pntSectID = -1;
public int PntSectID
{
get { return _pntSectID; }
set { _pntSectID = value; }
}
private bool _DebugOutput;
public bool DebugOutput
{
@@ -942,190 +948,193 @@ namespace Volian.Print.Library
}
foreach (SectionInfo mySection in myProcedure.Sections)
{
// B2020-115 Calculate maximum available space on a page for figures
vlnParagraph.hMax = ((float)mySection.MyDocStyle.Layout.PageLength);
vlnParagraph.wMax = ((float)mySection.MyDocStyle.Layout.PageWidth) - ((float)mySection.MyDocStyle.Layout.LeftMargin - 12);
NeedSupInfoBreak = true;
bool isFoldoutSection = (mySection.MyConfig as SectionConfig).Section_IsFoldout == "Y"; //C2019-042 Section_IsFoldout checks Section Number, Section Title, and use of check box
if (((isFoldoutSection && myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.SectionLevelFoldouts)
|| (myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.AlternateFloatingFoldout && isFoldoutSection))
!= doingFoldout) continue;
if (myFoldoutSection != null && myFoldoutSection.ItemID != mySection.ItemID) continue;
PrintOverride.CompressSuper = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSuper;
PrintOverride.CompressSub = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSub;
PrintOverride.CompressPropSubSup = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressPropSubSup;
if(PntSectID == -1 || (PntSectID > -1 && mySection.ItemID == PntSectID) )
{
// B2020-115 Calculate maximum available space on a page for figures
vlnParagraph.hMax = ((float)mySection.MyDocStyle.Layout.PageLength);
vlnParagraph.wMax = ((float)mySection.MyDocStyle.Layout.PageWidth) - ((float)mySection.MyDocStyle.Layout.LeftMargin - 12);
NeedSupInfoBreak = true;
bool isFoldoutSection = (mySection.MyConfig as SectionConfig).Section_IsFoldout == "Y"; //C2019-042 Section_IsFoldout checks Section Number, Section Title, and use of check box
if (((isFoldoutSection && myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.SectionLevelFoldouts)
|| (myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.AlternateFloatingFoldout && isFoldoutSection))
!= doingFoldout) continue;
if (myFoldoutSection != null && myFoldoutSection.ItemID != mySection.ItemID) continue;
PrintOverride.CompressSuper = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSuper;
PrintOverride.CompressSub = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSub;
PrintOverride.CompressPropSubSup = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressPropSubSup;
OnStatusChanged((mySection.DisplayNumber ?? "") == "" ? mySection.DisplayText : mySection.DisplayNumber, PromsPrinterStatusType.Progress, progress++);
// Set up Helper for the particular Section
if (_MyHelper == null)
{
LastFmtName = mySection.ActiveFormat.Name;
lastDocStyle = (int)mySection.MyDocStyle.Index;
string hlsText = "";
int hlsItemId = 0;
if (mySection.IsStepSection && mySection.Steps != null && mySection.Steps.Count > 0)
OnStatusChanged((mySection.DisplayNumber ?? "") == "" ? mySection.DisplayText : mySection.DisplayNumber, PromsPrinterStatusType.Progress, progress++);
// Set up Helper for the particular Section
if (_MyHelper == null)
{
hlsItemId = mySection.Steps[0].ItemID;
hlsText = mySection.Steps[0].DisplayText; // save the High level step text for use in the page list
}
cb.PdfWriter.PageEvent = _MyHelper = new VlnSvgPageHelper(mySection, this, hlsText, hlsItemId);
_MyHelper.AllowAllWatermarks = AllowAllWatermarks;
_MyHelper.MyPdfWriter = cb.PdfWriter;
_MyHelper.CreatingFoldoutPage = doingFoldout;
_MyHelper.CreatingSupInfoPage = false;
_MyHelper.MyPdfContentByte = cb;
if (!mySection.IsStepSection) _MyHelper.PageBookmarks.Add((ItemInfo)mySection, ((mySection.DisplayNumber ?? "") == "" ? "" : mySection.DisplayNumber + " - ") + mySection.DisplayText, null);
if (DebugOutput)
{
// 16-bit background
string procedureFileName = BackgroundFolder + "\\" + PDFFile.Trim();//CreateFileName(myProcedure.DisplayNumber);
FileInfo VEPromsFile = new FileInfo(procedureFileName);
if (VEPromsFile.Exists && !doingFoldout)
{
_MyHelper.BackgroundFile = procedureFileName;
float x = 0;
float y = 0;
if (!(mySection.ActiveFormat.Name.ToUpper().StartsWith("WST") || _MyHelper.Back32BitPROMS)) // compare folder contains PROMS generated PDF
{
// X value below = 16-bit pdf OverrideLeftMargin = -2 characters at the plant format's default Font's
// characters per inch.
// 16bit OverrideLeftMargin, defined as -2 in driver\drvin.rtf, - override took 2 characters out, so we're adding it back in:
// These values adjust if overlay is 16bit versus 32bit. This is
// used so that the comparison is an exact match. Use 0,0 if comparing to another 32bit
// pdf, i.e. won't process the following 2 lines of code.
x = 2 * 72F / (float)myProcedure.ActiveFormat.PlantFormat.FormatData.Font.CPI;
y = -9.5F;
}
x += 72F * VlnSettings.GetCommandFloat("X", 0);
y -= 72F * VlnSettings.GetCommandFloat("Y", 0);
_MyHelper.BackgroundOffset = new PointF(x, y);
_MyHelper.BackgroundPageOffset = 0;
}
_MyHelper.WatermarkLayer = _WatermarkLayer;
_MyHelper.PageListLayer = _PagelistLayer;
_MyHelper.TextLayer = _TextLayer;
_MyHelper.BackgroundLayer = _BackgroundLayer;
_MyHelper.DebugLayer = _DebugLayer;
_MyHelper.PROMSVersionLayer = _PROMSVersionLayer; //C2018-009 print PROMS version
}
_MyHelper.Rev = _Rev;
_MyHelper.Watermark = _Watermark;
// C2019-039 Remove automatic zoom on Overlay PDFs
//_MyHelper.DoZoomOMatic = DebugOutput;
_MyHelper.OriginalPageBreak = OriginalPageBreak;
_MyHelper.PROMSVersion = _PromsVersion; //C2018-009 print PROMS version
_MyHelper.WatermarkColor = WatermarkOverrideColor; // C2021-019: save the override for the watermark color
OnStatusChanged("After Set PageEvent", PromsPrinterStatusType.SetPageEvent);
}
else
{
//added by jcb to reset mygaps when changing a section. found old section gaps were carrying over to new section
_MyHelper.MyGaps.Clear();
//Console.WriteLine("'{0}' PromsPrinter", mySection.DisplayText);
// if pagination is separate or we've changed the format, we have not done the first page
// (if this format has the useonfirst page docstyle flag)
if (LastFmtName != mySection.ActiveFormat.Name || lastDocStyle != (int)mySection.MyDocStyle.Index || mySection.SectionConfig.Section_Pagination == SectionConfig.SectionPagination.Separate)
{
_MyHelper.DidFirstPageDocStyle = false;
lastDocStyle = (int)mySection.MyDocStyle.Index;
LastFmtName = mySection.ActiveFormat.Name;
}
if (!mySection.IsStepSection) _MyHelper.PageBookmarks.Add((ItemInfo)mySection, ((mySection.DisplayNumber ?? "") == "" ? "" : mySection.DisplayNumber + " - ") + mySection.DisplayText, null);
_MyHelper.MySection = mySection;
//OnStatusChanged("After Set Svg", PromsPrinterStatusType.SetSVG);
}
// if this format uses phonelists, see if this section has one. We need to know the number
//of lines to adjust the pagelength for pagination and printing.
_MyHelper.PhoneListHeight = 0;
if (mySection.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList)
{
// get config for section
SectionConfig sc = mySection.MyConfig as SectionConfig;
if (sc.Section_PhoneList != null && sc.Section_PhoneList == "Y")
{
DocVersionConfig dvc = mySection.MyDocVersion.MyConfig as DocVersionConfig;
if (dvc != null)
lastDocStyle = (int)mySection.MyDocStyle.Index;
string hlsText = "";
int hlsItemId = 0;
if (mySection.IsStepSection && mySection.Steps != null && mySection.Steps.Count > 0)
{
string phlist = dvc.Print_PhoneList;
if (phlist != null && phlist != "")
{
// count lines:
int cl = 0;
int indx = phlist.IndexOf("\n");
while (indx > 0)
{
cl++;
if (indx + 1 > phlist.Length)
indx = -1;
else
indx = phlist.IndexOf("\n", indx + 1);
}
if (cl == 0) cl = 1; // phone list is a single line without an ending newline
_MyHelper.PhoneListHeight = cl * vlnPrintObject.SixLinesPerInch;
}
hlsItemId = mySection.Steps[0].ItemID;
hlsText = mySection.Steps[0].DisplayText; // save the High level step text for use in the page list
}
}
}
_MyHelper.FinalMessageSectionID = finalMessageSectionID; // set VlnSvgPageHelper with the finalMessageSectionID
cb.PdfWriter.PageEvent = _MyHelper = new VlnSvgPageHelper(mySection, this, hlsText, hlsItemId);
_MyHelper.AllowAllWatermarks = AllowAllWatermarks;
_MyHelper.MyPdfWriter = cb.PdfWriter;
_MyHelper.CreatingFoldoutPage = doingFoldout;
_MyHelper.CreatingSupInfoPage = false;
_MyHelper.MyPdfContentByte = cb;
if (mySection.IsAutoTOCSection)
{
if (((cb.PdfWriter.CurrentPageNumber % 2 == 0 && !_MyHelper.CreatingFoldoutPage) || myProcedure.ProcHasSupInfoData) && InsertBlankPages) // Bug Fix: B2016-181 - add blank page if page count is even
{
InsertBlankPage(cb);
}
GenerateTOC(mySection, myProcedure, cb, _TextLayer);
// B2020-102: extra page printing after auto TOC for summer. Retested for Farley and was successful also
// F2018-033: Farley Auto TOC. If doing foldouts or supinfo facing pages, add a blank page after also:
//if (myProcedure.ProcHasSupInfoData && InsertBlankPages) // Bug Fix: B2016-181 - add blank page if page count is even
//{
// InsertBlankPage(cb);
//}
}
else
{
if (mySection.IsStepSection)
{
if (mySection.Steps != null && mySection.Steps.Count > 0)
if (!mySection.IsStepSection) _MyHelper.PageBookmarks.Add((ItemInfo)mySection, ((mySection.DisplayNumber ?? "") == "" ? "" : mySection.DisplayNumber + " - ") + mySection.DisplayText, null);
if (DebugOutput)
{
// get first step to send to floating foldout indx.&& MyItemInfo.FoldoutIndex>-1)
ItemInfo firstStep = mySection.Steps[0];
// B2019-165 Don't print the duplex foldout (on the back of the page) if the Don't Include Duplex Foldout check box was checked in section properties
if (firstStep.FoldoutIndex() > -1 && (mySection.MyPrevious == null || !((mySection.MyPrevious.MyConfig as SectionConfig).Section_DontIncludeDuplexFoldout)))
DoFoldoutPage(cb, "Beginning of Step Section", _TextLayer, _MyHelper, firstStep.FoldoutIndex(), InsertBlankPages);
else if (!_MyHelper.CreatingFoldoutPage && _MyFoldoutReader.Count > 0 && InsertBlankPages)
// 16-bit background
string procedureFileName = BackgroundFolder + "\\" + PDFFile.Trim();//CreateFileName(myProcedure.DisplayNumber);
FileInfo VEPromsFile = new FileInfo(procedureFileName);
if (VEPromsFile.Exists && !doingFoldout)
{
// if it is continuous pagination, don't do blank page - not sure if this is correct place for this:
// 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)
_MyHelper.BackgroundFile = procedureFileName;
float x = 0;
float y = 0;
if (!(mySection.ActiveFormat.Name.ToUpper().StartsWith("WST") || _MyHelper.Back32BitPROMS)) // compare folder contains PROMS generated PDF
{
// 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);
//_MyLog.InfoFormat("NewPage Begin Step Sect blank {0}", cb.PdfWriter.CurrentPageNumber);
}
}
else
{
// If the procedure has supplemental facing pages, but this section does not & it's the first section,
// need a blank 'facing page'. Sections after the first will get blank 'facing page' in print's pagination logic
if (SupInfoPrintType == E_SupInfoPrintType.Merge && !mySection.HasSupInfoSteps && firstStepSec && InsertBlankPages)
{
InsertBlankPage(cb);
// X value below = 16-bit pdf OverrideLeftMargin = -2 characters at the plant format's default Font's
// characters per inch.
// 16bit OverrideLeftMargin, defined as -2 in driver\drvin.rtf, - override took 2 characters out, so we're adding it back in:
// These values adjust if overlay is 16bit versus 32bit. This is
// used so that the comparison is an exact match. Use 0,0 if comparing to another 32bit
// pdf, i.e. won't process the following 2 lines of code.
x = 2 * 72F / (float)myProcedure.ActiveFormat.PlantFormat.FormatData.Font.CPI;
y = -9.5F;
}
x += 72F * VlnSettings.GetCommandFloat("X", 0);
y -= 72F * VlnSettings.GetCommandFloat("Y", 0);
_MyHelper.BackgroundOffset = new PointF(x, y);
_MyHelper.BackgroundPageOffset = 0;
}
_MyHelper.WatermarkLayer = _WatermarkLayer;
_MyHelper.PageListLayer = _PagelistLayer;
_MyHelper.TextLayer = _TextLayer;
_MyHelper.BackgroundLayer = _BackgroundLayer;
_MyHelper.DebugLayer = _DebugLayer;
_MyHelper.PROMSVersionLayer = _PROMSVersionLayer; //C2018-009 print PROMS version
}
firstStepSec = false;
CreateStepPdf(mySection, cb);
_MyHelper.Rev = _Rev;
_MyHelper.Watermark = _Watermark;
// C2019-039 Remove automatic zoom on Overlay PDFs
//_MyHelper.DoZoomOMatic = DebugOutput;
_MyHelper.OriginalPageBreak = OriginalPageBreak;
_MyHelper.PROMSVersion = _PromsVersion; //C2018-009 print PROMS version
_MyHelper.WatermarkColor = WatermarkOverrideColor; // C2021-019: save the override for the watermark color
OnStatusChanged("After Set PageEvent", PromsPrinterStatusType.SetPageEvent);
}
else
{
CreateWordDocPdf(cb, mySection);
//added by jcb to reset mygaps when changing a section. found old section gaps were carrying over to new section
_MyHelper.MyGaps.Clear();
//Console.WriteLine("'{0}' PromsPrinter", mySection.DisplayText);
// if pagination is separate or we've changed the format, we have not done the first page
// (if this format has the useonfirst page docstyle flag)
if (LastFmtName != mySection.ActiveFormat.Name || lastDocStyle != (int)mySection.MyDocStyle.Index || mySection.SectionConfig.Section_Pagination == SectionConfig.SectionPagination.Separate)
{
_MyHelper.DidFirstPageDocStyle = false;
lastDocStyle = (int)mySection.MyDocStyle.Index;
LastFmtName = mySection.ActiveFormat.Name;
}
if (!mySection.IsStepSection) _MyHelper.PageBookmarks.Add((ItemInfo)mySection, ((mySection.DisplayNumber ?? "") == "" ? "" : mySection.DisplayNumber + " - ") + mySection.DisplayText, null);
_MyHelper.MySection = mySection;
//OnStatusChanged("After Set Svg", PromsPrinterStatusType.SetSVG);
}
// if this format uses phonelists, see if this section has one. We need to know the number
//of lines to adjust the pagelength for pagination and printing.
_MyHelper.PhoneListHeight = 0;
if (mySection.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList)
{
// get config for section
SectionConfig sc = mySection.MyConfig as SectionConfig;
if (sc.Section_PhoneList != null && sc.Section_PhoneList == "Y")
{
DocVersionConfig dvc = mySection.MyDocVersion.MyConfig as DocVersionConfig;
if (dvc != null)
{
string phlist = dvc.Print_PhoneList;
if (phlist != null && phlist != "")
{
// count lines:
int cl = 0;
int indx = phlist.IndexOf("\n");
while (indx > 0)
{
cl++;
if (indx + 1 > phlist.Length)
indx = -1;
else
indx = phlist.IndexOf("\n", indx + 1);
}
if (cl == 0) cl = 1; // phone list is a single line without an ending newline
_MyHelper.PhoneListHeight = cl * vlnPrintObject.SixLinesPerInch;
}
}
}
}
_MyHelper.FinalMessageSectionID = finalMessageSectionID; // set VlnSvgPageHelper with the finalMessageSectionID
if (mySection.IsAutoTOCSection)
{
if (((cb.PdfWriter.CurrentPageNumber % 2 == 0 && !_MyHelper.CreatingFoldoutPage) || myProcedure.ProcHasSupInfoData) && InsertBlankPages) // Bug Fix: B2016-181 - add blank page if page count is even
{
InsertBlankPage(cb);
}
GenerateTOC(mySection, myProcedure, cb, _TextLayer);
// B2020-102: extra page printing after auto TOC for summer. Retested for Farley and was successful also
// F2018-033: Farley Auto TOC. If doing foldouts or supinfo facing pages, add a blank page after also:
//if (myProcedure.ProcHasSupInfoData && InsertBlankPages) // Bug Fix: B2016-181 - add blank page if page count is even
//{
// InsertBlankPage(cb);
//}
}
else
{
if (mySection.IsStepSection)
{
if (mySection.Steps != null && mySection.Steps.Count > 0)
{
// get first step to send to floating foldout indx.&& MyItemInfo.FoldoutIndex>-1)
ItemInfo firstStep = mySection.Steps[0];
// B2019-165 Don't print the duplex foldout (on the back of the page) if the Don't Include Duplex Foldout check box was checked in section properties
if (firstStep.FoldoutIndex() > -1 && (mySection.MyPrevious == null || !((mySection.MyPrevious.MyConfig as SectionConfig).Section_DontIncludeDuplexFoldout)))
DoFoldoutPage(cb, "Beginning of Step Section", _TextLayer, _MyHelper, firstStep.FoldoutIndex(), 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:
// 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
InsertBlankPage(cb);
//_MyLog.InfoFormat("NewPage Begin Step Sect blank {0}", cb.PdfWriter.CurrentPageNumber);
}
}
else
{
// If the procedure has supplemental facing pages, but this section does not & it's the first section,
// need a blank 'facing page'. Sections after the first will get blank 'facing page' in print's pagination logic
if (SupInfoPrintType == E_SupInfoPrintType.Merge && !mySection.HasSupInfoSteps && firstStepSec && InsertBlankPages)
{
InsertBlankPage(cb);
}
}
}
firstStepSec = false;
CreateStepPdf(mySection, cb);
}
else
{
CreateWordDocPdf(cb, mySection);
}
}
_MyHelper.PrintedSectionPage = 0;
}
_MyHelper.PrintedSectionPage = 0;
}
if (_MyHelper != null && _MyHelper.BackgroundFile != null)
{