From e648a50e9ba89a2cf9f5c482465dd7ff687bd1e7 Mon Sep 17 00:00:00 2001 From: Kathy Date: Thu, 8 Nov 2012 17:10:04 +0000 Subject: [PATCH] --- PROMS/Volian.Print.Library/Pagination.cs | 50 ++++++++--- PROMS/Volian.Print.Library/PromsPrinter.cs | 33 +++----- .../Volian.Print.Library/VlnSvgPageHelper.cs | 43 ++++++++-- PROMS/Volian.Print.Library/vlnBox.cs | 2 +- PROMS/Volian.Print.Library/vlnChangeBar.cs | 2 +- PROMS/Volian.Print.Library/vlnHeader.cs | 2 +- PROMS/Volian.Print.Library/vlnMacro.cs | 2 +- PROMS/Volian.Print.Library/vlnParagraph.cs | 84 ++++++++----------- PROMS/Volian.Print.Library/vlnPrintObject.cs | 6 +- PROMS/Volian.Print.Library/vlnRNOSeparator.cs | 2 +- PROMS/Volian.Print.Library/vlnTab.cs | 23 +++-- PROMS/Volian.Print.Library/vlnText.cs | 2 +- 12 files changed, 146 insertions(+), 105 deletions(-) diff --git a/PROMS/Volian.Print.Library/Pagination.cs b/PROMS/Volian.Print.Library/Pagination.cs index 0fb977de..96c53366 100644 --- a/PROMS/Volian.Print.Library/Pagination.cs +++ b/PROMS/Volian.Print.Library/Pagination.cs @@ -29,6 +29,15 @@ namespace Volian.Print.Library private int Paginate(float yLocation, float yTopMargin, float yBottomMargin) { float yPageSize = yTopMargin - yBottomMargin; + // yPageSizeNextPage is the page size of the 'next' page. A format variable exists off of the docstyle + // For UseOnFirstPage vs UseOnAllButFirstPage. If this is set for this format, and processing the FIRST + // page, the size of next page, which may be different, is used in pagination calculationstop. + // If this format flag is not set, or not printing the first page of the section with this flag, + // this next page size is the same as current page size. + float yPageSizeNextPage = yPageSize; + if (!MyPageHelper.DidFirstPageDocStyle && (MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnFirstPage) > 0) + yPageSizeNextPage = GetYPageSizeUseOnAllButFirstPage(); + // TODO: This does not account for a long step as the last step that would exceed more than one page and // that has an end message that needs to be accounted for in determining pagination. To do that the last // child should be the only paragraph that accounts for the End message. @@ -150,20 +159,21 @@ namespace Volian.Print.Library // YSize includes a blank line after the step which we don't want to include in the page break test, thus the // YSize - SixLinesPerInch: - if (!KeepWithHeader && !KeepStepsOnPage && YSize - SixLinesPerInch + yEndMsg <= yPageSize) // if the entire step can fit on one page, do a page break + 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 //Console.WriteLine("'PageBreak',2,'Yes','HLS will fit on 1 Page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath); - ShowPageBreak(5, "HLS will fit on 1 Page at 6 LPI", "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); + // A page break will occur before the step is put out. ShowPageBreak with first argument of -1 is NOT a page break. + ShowPageBreak(5, "HLS will fit on 1 Page at 6 LPI", "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); return 1; } // TODO - yEndMsg - compressed size? // ySize7LPI includes a blank line after the step which we don't want to include in the page break test. - else if (!KeepStepsOnPage && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CompressSteps && (ySize7LPI - SixLinesPerInch) < (yPageSize * SixLinesPerInch / _SevenLinesPerInch)) + else if (!KeepStepsOnPage && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CompressSteps && (ySize7LPI - SixLinesPerInch) < (yPageSizeNextPage * SixLinesPerInch / _SevenLinesPerInch)) { //Console.WriteLine("'PageBreak',3,'Yes','HLS will fit on 1 Page at 7 LPI',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath); - ShowPageBreak(7, "HLS will fit on 1 Page at 7 LPI", "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); + ShowPageBreak(7, "HLS will fit on 1 Page at 7 LPI", "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); //Console.WriteLine("'7LPI',{0},{1}", MyItemInfo.DBSequence, YSize); return 3; // High Level Step can fit at SevenLinesPerInch } @@ -174,18 +184,22 @@ namespace Volian.Print.Library if (_Match16BitPagination) myFirstPieceSize += 2 * SixLinesPerInch; // TODO: Put this line back to case 0, i.e. previous line. This fixes a 16-bit vs 32-bit pagination diff in EO30 Step 20. //float myFirstPieceSize = GetFirstPieceSize() + 2 * SixLinesPerInch; //Case 10 - this is to match 16bit + //is the amount of space left (yWithinMargins) is greater than 1/2 of the current page (yPageSize / 2): if (KeepWithHeader ||( !ManualPageBreak && ((MyItemInfo.ActiveFormat.MyStepSectionLayoutData.SpecialPageBreakFlag && yWithinMargins > yPageSize / 2 && myFirstPieceSize < yWithinMargins) || KeepStepsOnPage))) { //Console.WriteLine("'PageBreak',4,'No','HLS will have to split anyway',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath); + // yPageSize is space on next page. This may be different if the format flag 'UseOnAllButFirst' is + // set. + // yWithinMargins is space available on current page. if(firstStep == "Yes") - ShowPageBreak(8, "First HLS has to split on current page", firstStep, YSize, yPageSize, yWithinMargins, ManualPageBreak); + ShowPageBreak(8, "First HLS has to split on current page", firstStep, YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); else - ShowPageBreak(6, "HLS will have to split on current page", "Special", YSize, yPageSize, yWithinMargins, ManualPageBreak); + ShowPageBreak(6, "HLS will have to split on current page", "Special", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); // if the HLS is part of a Smart Template (i.e. WCNCKL table), don't add in an extra line because // that makes pagination work incorrectly because the Smart Template has a 'table' line after the // text. - BuildPageBreakList(yWithinMargins + SixLinesPerInch, yPageSize + yExtra2, KeepStepsOnPage); // Case 5 - Determine items where page break(s) occur + BuildPageBreakList(yWithinMargins + SixLinesPerInch, yPageSizeNextPage + yExtra2, KeepStepsOnPage); // Case 5 - Determine items where page break(s) occur //BuildPageBreakList(yWithinMargins + (MyItemInfo.FormatStepData.UseSmartTemplate?0:SixLinesPerInch), yPageSize + yExtra2, KeepStepsOnPage); // Case 5 - Determine items where page break(s) occur return 0; // Stay on this page } @@ -193,16 +207,16 @@ namespace Volian.Print.Library // Less than half a page left, start printing on a new page. //Console.WriteLine("'PageBreak',5,'Yes','HLS will have to split',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath); if (firstStep == "Yes") - ShowPageBreak(9, "First HLS will have to split on new page", "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); + ShowPageBreak(9, "First HLS will have to split on new page", "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); else - ShowPageBreak(3, "HLS will have to split on new page", "Yes", YSize, yPageSize, yWithinMargins, ManualPageBreak); + ShowPageBreak(3, "HLS will have to split on new page", "Yes", YSize, yPageSizeNextPage, yWithinMargins, ManualPageBreak); // Determine items where page break(s) occur //BuildPageBreakList(yPageSize, yPageSize - 2 * SixLinesPerInch); // Case Base //BuildPageBreakList(yPageSize, yPageSize); // Case 1 :Works for ES05 Step 15 SubStep 7 // Pagination Fix Break1LineShort2 //BuildPageBreakList(yPageSize + yExtra, yPageSize); // Case 1 :Works for ES05 Step 15 SubStep 7 // Pagination Fix Break1LineShort4 - BuildPageBreakList(yPageSize + yExtra, yPageSize + yExtra2,KeepStepsOnPage); // Case 1 :Works for ES05 Step 15 SubStep 7 + BuildPageBreakList(yPageSize + yExtra, yPageSizeNextPage + yExtra2, KeepStepsOnPage); // Case 1 :Works for ES05 Step 15 SubStep 7 return 1; // Paginate on High Level Steps } //if (yWithinMargins > yPageSize / 2) @@ -216,6 +230,22 @@ namespace Volian.Print.Library //return 2; throw new Exception("PageBreak Logic Missing, vlnParagraph.cs"); } + + private float GetYPageSizeUseOnAllButFirstPage() + { + float _PointsPerPage = 792; + int indx = (int)MyItemInfo.MyDocStyle.IndexOtherThanFirstPage; + foreach (DocStyle ds in MyItemInfo.ActiveFormat.PlantFormat.DocStyles.DocStyleList) + { + if (ds.Index == indx) + { + float yTopMargin = _PointsPerPage - (float)ds.Layout.TopMargin; + float yBottomMargin = Math.Max(0, yTopMargin - (float)ds.Layout.PageLength); + return yTopMargin - yBottomMargin; + } + } + return 0; + } private void ForcePagination(PdfContentByte cb, ref float yPageStart, float yTopMargin, float yBottomMargin, ref float yLocation, ref float retval) { cb.PdfDocument.NewPage(); // pagination issue diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index 04f5c210..59178251 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -340,19 +340,6 @@ namespace Volian.Print.Library if ((mySection.MyContent.Number.ToUpper() == "FOLDOUT") != doingFoldout) continue; //if ((mySection.MyContent.Number.ToUpper() == "FOLDOUT" || mySection.MyContent.Text.ToUpper() == "FOLDOUT" ) != doingFoldout) continue; SectionConfig sc = mySection.MyConfig as SectionConfig; -#if AllButFirstPage - if (_MyHelper != null && mySection.IsStepSection && mySection.MyPrevious != null && mySection.MyPrevious.IsStepSection) - { - //SectionConfig.SectionPagination sPag = SectionConfig.SectionPagination.Separate; - //sPag = sc.Section_Pagination; - //if (sPag == SectionConfig.SectionPagination.Continuous) - if (sc.Section_Pagination == SectionConfig.SectionPagination.Continuous) - { - if (mySection.MyDocStyle.StructureStyle.Where == E_DocStyleUse.UseOnFirstPage) - mySection.DidFirstPageDocStyle = true; - } - } -#endif PrintOverride.CompressSuper = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSuper; PrintOverride.CompressSub = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSub; OnStatusChanged((mySection.DisplayNumber ?? "") == "" ? mySection.DisplayText : mySection.DisplayNumber, PromsPrinterStatusType.Progress, progress++); @@ -396,6 +383,7 @@ namespace Volian.Print.Library } else { + _MyHelper.DidFirstPageDocStyle = false; if (!mySection.IsStepSection) _MyHelper.PageBookmarks.Add((ItemInfo)mySection, ((mySection.DisplayNumber ?? "") == "" ? "" : mySection.DisplayNumber + " - ") + mySection.DisplayText, null); _MyHelper.MySection = mySection; OnStatusChanged("After Set Svg", PromsPrinterStatusType.SetSVG); @@ -474,6 +462,7 @@ namespace Volian.Print.Library _MyHelper.MyTOCPageNums.Add(tockey, _MyHelper.CurrentPageNumber+1); } } + float origYoff = (float)mySection.MyDocStyle.Layout.TopMargin; for (int ii = 0; ii < sectPageCount; ii++) { int pageNumber = 1 + ii; @@ -495,7 +484,9 @@ namespace Volian.Print.Library OnStatusChanged("Read MSWord", PromsPrinterStatusType.ReadMSWord); if (doimport2) { - AddImportedPageToLayer(cb.PdfWriter.DirectContent, _MSWordLayer, fgPage, 0, 0); + float yoff = 0; + if (_MyHelper.DidFirstPageDocStyle) yoff = origYoff - (float)mySection.MyDocStyle.Layout.TopMargin; + AddImportedPageToLayer(cb.PdfWriter.DirectContent, _MSWordLayer, fgPage, 0, yoff); DebugPagination.WriteLine("{0},'{1}',{2}", _MyHelper.MyPdfContentByte.PdfWriter.CurrentPageNumber, mySection.ShortPath,pageNumber); @@ -520,7 +511,12 @@ namespace Volian.Print.Library } OnStatusChanged("Before NewPage", PromsPrinterStatusType.Before); cb.PdfDocument.NewPage(); // Word Document - + + // if this document style has another style that is for pages other than first, we need to + // reset the document style off of this section AND reset docstyle values used. + _MyHelper.DidFirstPageDocStyle = true; + if ((mySection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnFirstPage) > 0) + _MyHelper.MySection = mySection; // this resets the docstyle/pagestyle if pagehelper OnStatusChanged("After NewPage", PromsPrinterStatusType.NewPage); } } @@ -529,7 +525,6 @@ namespace Volian.Print.Library cb.PdfDocument.NewPage(); // can we put out 'error on page'? } } - private void GenerateTOC(SectionInfo tocSection, ProcedureInfo myProcedure, PdfContentByte cb, PdfLayer textLayer) { iTextSharp.text.pdf.PdfWriter writer = cb.PdfWriter; @@ -675,10 +670,6 @@ namespace Volian.Print.Library private float _NoBreakYPageStart = 0; private void CreateStepPdf(SectionInfo section, PdfContentByte cb) { - //section.PageNumForDocStyle = 1; -#if AllButFirstPage - section.DidFirstPageDocStyle = false; // first step of the section -#endif iTextSharp.text.pdf.PdfWriter writer = cb.PdfWriter; ItemInfo myItemInfo = section as ItemInfo; // 792: 72 * 11 inches - TopRow - Top is high value @@ -694,7 +685,7 @@ namespace Volian.Print.Library float localYPageStart = 0; float yPageStart = yTopMargin; if (myItemInfo.HasChildren) - localYPageStart = myParagraph.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin); + localYPageStart = myParagraph.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); else PrintTextMessage(cb, "No Section Content", _TextLayer); SectionConfig.SectionPagination sp = SectionConfig.SectionPagination.Separate; // always the default diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index 7854c563..8e2e14c0 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -76,12 +76,17 @@ namespace Volian.Print.Library set { _MyPdfContentByte = value; } } private int _FinalMessageSectionID; - public int FinalMessageSectionID { get { return _FinalMessageSectionID; } set { _FinalMessageSectionID = value; } } + private bool _DidFirstPageDocStyle = false; + public bool DidFirstPageDocStyle + { + get { return _DidFirstPageDocStyle; } + set { _DidFirstPageDocStyle = value; } + } public override void OnCloseDocument(PdfWriter writer, iTextSharp.text.Document document) { AddBookmarks(writer); @@ -91,6 +96,7 @@ namespace Volian.Print.Library { if (!OnFoldoutPage) { + if (DidFirstPageDocStyle) ResetDocStyleAndValues(); AddBookmarks(writer); MyPageCounts.CanIncrement = true; base.OnEndPage(writer, document); @@ -113,6 +119,26 @@ namespace Volian.Print.Library PageListTopCheckOffHeader = null; PageListLastCheckOffHeader = null; YMultiplier = 1; + + } + + private void ResetDocStyleAndValues() + { + // if this document style has another style that is for pages other than first, we need to + // reset the document style off of this section AND reset docstyle values used. + if ((MySection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnFirstPage) > 0) + { + ItemInfo ii = (ItemInfo) MySection; + int indx = (int)MySection.MyDocStyle.IndexOtherThanFirstPage; + foreach (DocStyle ds in ii.ActiveFormat.PlantFormat.DocStyles.DocStyleList) + { + if (ds.Index == indx) + { + MySection.MyDocStyle = ds; + break; + } + } + } } private void DrawRuler(PdfContentByte cb) { @@ -215,31 +241,34 @@ namespace Volian.Print.Library } private void DrawMessages(PdfContentByte cb) { + float tmp = 0; if (TopMessage != null) { - TopMessage.ToPdf(cb, 0, 0, 0); + TopMessage.ToPdf(cb, 0, ref tmp, ref tmp); TopMessage = null; // Only output it once. } if (BottomMessage != null) { - BottomMessage.ToPdf(cb, 0, 0, 0); + BottomMessage.ToPdf(cb, 0, ref tmp, ref tmp); BottomMessage = null; // Only output it once. } } public void DrawBottomMessage(PdfContentByte cb) { + float tmp = 0; if (BottomMessage != null) { - BottomMessage.ToPdf(cb, 0, 0, 0); + BottomMessage.ToPdf(cb, 0, ref tmp, ref tmp); BottomMessage = null; // Only output it once. } } private void DrawChangeBars(PdfContentByte cb) { + float tmp = 0; foreach (vlnChangeBar vcb in MyChangeBars) { // TODO: Pass in zeroes because topdf is inherited. - vcb.ToPdf(cb, 0, 0, 0); + vcb.ToPdf(cb, 0, ref tmp, ref tmp); } _MyChangeBars = new List(); } @@ -271,6 +300,7 @@ namespace Volian.Print.Library { _MySection = value; MySectionTitle = ((_MySection.DisplayNumber ?? "")=="" ? "" : _MySection.DisplayNumber + " - ") + _MySection.DisplayText; + if (DidFirstPageDocStyle) ResetDocStyleAndValues(); Volian.Svg.Library.Svg sectSvg = BuildSvg(_MySection); if (sectSvg != null) MySvg = sectSvg; } @@ -651,9 +681,6 @@ namespace Volian.Print.Library foreach (VEPROMS.CSLA.Library.PageItem pageItem in pageStyle.PageItems) { VE_Font useFontForCheckOffHeader = null; -#if AllButFirstPage - if (sPag == SectionConfig.SectionPagination.Separate || ((sPag == SectionConfig.SectionPagination.Continuous || sPag ==0 )&& ((pageItem.Row < 0) || section.DidFirstPageDocStyle))) -#endif if (sPag == SectionConfig.SectionPagination.Separate || ((sPag == SectionConfig.SectionPagination.Continuous || sPag ==0 )&& (pageItem.Row < 0))) { //if (PrevRow > 0) diff --git a/PROMS/Volian.Print.Library/vlnBox.cs b/PROMS/Volian.Print.Library/vlnBox.cs index 14c713a9..e23e8c40 100644 --- a/PROMS/Volian.Print.Library/vlnBox.cs +++ b/PROMS/Volian.Print.Library/vlnBox.cs @@ -43,7 +43,7 @@ namespace Volian.Print.Library const string BoxFPLCaution = "\x2588.\x2580.\x2588.\x2588. . .\x2588.\x2588. .\x2584. . "; const string BoxAsterisk = " *.* .* . . . . *.* . .* . . "; - public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) + public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) { if (MyBox == null) return yPageStart; cb.SaveState(); diff --git a/PROMS/Volian.Print.Library/vlnChangeBar.cs b/PROMS/Volian.Print.Library/vlnChangeBar.cs index 50fa78f1..17391b28 100644 --- a/PROMS/Volian.Print.Library/vlnChangeBar.cs +++ b/PROMS/Volian.Print.Library/vlnChangeBar.cs @@ -131,7 +131,7 @@ namespace Volian.Print.Library { return string.Format("vlnChangeBar: X={0} Y={1} H={2} B={3} ID={4}", XOffset, YOffset, Height, YChangeBarBottom, MyParent.MyItemInfo.ItemID); } - public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) + public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) { cb.SaveState(); VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; diff --git a/PROMS/Volian.Print.Library/vlnHeader.cs b/PROMS/Volian.Print.Library/vlnHeader.cs index c1347953..506dea0a 100644 --- a/PROMS/Volian.Print.Library/vlnHeader.cs +++ b/PROMS/Volian.Print.Library/vlnHeader.cs @@ -25,7 +25,7 @@ namespace Volian.Print.Library XOffset = xoffset; MyFont = vFont; } - public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) + public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) { string fontFace = MyFont.WindowsFont.Name; int fontStyle = (MyFont.WindowsFont.Bold ? iTextSharp.text.Font.BOLD : 0) + (MyFont.WindowsFont.Italic ? iTextSharp.text.Font.ITALIC : 0); diff --git a/PROMS/Volian.Print.Library/vlnMacro.cs b/PROMS/Volian.Print.Library/vlnMacro.cs index 52c3aa3c..ba8d73f0 100644 --- a/PROMS/Volian.Print.Library/vlnMacro.cs +++ b/PROMS/Volian.Print.Library/vlnMacro.cs @@ -22,7 +22,7 @@ namespace Volian.Print.Library XOffset = xoffset; MacroDef = macroDef; } - public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) + public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) { cb.SaveState(); MyContentByte = cb; diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index e9a1b7da..a3a9fa3e 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -111,7 +111,7 @@ namespace Volian.Print.Library { foreach (vlnParagraph child in this) { - yPageStart = child.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin); + yPageStart = child.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); } return yPageStart; } @@ -140,7 +140,7 @@ namespace Volian.Print.Library if (Processed) return yPageStart; //float localYPageStart = yPageStart; Processed = true; - if (_PartsAbove != null && _PartsAbove.Count > 0) yPageStart = PartsAbove.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin); + if (_PartsAbove != null && _PartsAbove.Count > 0) yPageStart = PartsAbove.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); if (MyItemInfo.IsHigh && MyItemInfo.MyDocStyle.SpecialStepsFoldout) yPageStart -= SixLinesPerInch; float yLocation = CalculateYOffset(yPageStart, yTopMargin); if (MyItemInfo.HasChangeBar && MyPageHelper.ChangeBarDefinition.MyChangeBarType != PrintChangeBar.Without) MyPageHelper.AddChangeBar(DoChangeBar(cb, MyItemInfo, MyPageHelper, XOffset, yLocation, MyPageHelper.MaxRNO, MyItemInfo.ActiveFormat), cbMess); @@ -200,10 +200,10 @@ namespace Volian.Print.Library } } //Height = yLocation - retval; - if (_PartsLeft != null && _PartsLeft.Count > 0) yPageStart = PartsLeft.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin); - if (_PartsRight != null && _PartsRight.Count > 0) yPageStart = PartsRight.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin); - if (_PartsBelow != null && _PartsBelow.Count > 0) yPageStart = PartsBelow.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin); - if (_PartsContainer != null && _PartsContainer.Count > 0) yPageStart = PartsContainer.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin); + if (_PartsLeft != null && _PartsLeft.Count > 0) yPageStart = PartsLeft.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); + if (_PartsRight != null && _PartsRight.Count > 0) yPageStart = PartsRight.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); + if (_PartsBelow != null && _PartsBelow.Count > 0) yPageStart = PartsBelow.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); + if (_PartsContainer != null && _PartsContainer.Count > 0) yPageStart = PartsContainer.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); //if (localYPageStart != yPageStart) DebugText.WriteLine("ParToPdf-yPagestartDiff:{0},{1},{2}", MyItemInfo.ItemID, localYPageStart, yPageStart); return yPageStart; @@ -462,12 +462,31 @@ namespace Volian.Print.Library return string.Format("DebugID = {0}, ID={1} Type={2} TypeName='{3}' StepLevel={4} DBSequence={5}", DebugId, MyItemInfo.ItemID, MyItemInfo.FormatStepType, MyItemInfo.FormatStepData==null?"NoStepData":MyItemInfo.FormatStepData.Type, MyItemInfo.StepLevel, MyItemInfo.DBSequence); } } - public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) + private void ResetDocStyleAndValues(ref float yTopMargin, ref float yBottomMargin) + { + // if this document style has another style that is for pages other than first, we need to + // reset the document style off of this section AND reset docstyle values used. + if ((MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnFirstPage) > 0) + { + float _PointsPerPage = 792; + ItemInfo ii = (ItemInfo)MyItemInfo.MyActiveSection; + int indx = (int)MyItemInfo.MyActiveSection.MyDocStyle.IndexOtherThanFirstPage; + foreach (DocStyle ds in ii.ActiveFormat.PlantFormat.DocStyles.DocStyleList) + { + if (ds.Index == indx) + { + MyItemInfo.MyActiveSection.MyDocStyle = ds; + break; + } + } + MyPageHelper.DidFirstPageDocStyle = true; + MyPageHelper.MySection = (SectionInfo)MyItemInfo.MyActiveSection; + yTopMargin = _PointsPerPage - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.TopMargin; + yBottomMargin = Math.Max(0, yTopMargin - (float)MyItemInfo.MyActiveSection.MyDocStyle.Layout.PageLength); + } + } + public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) { -#if AllButFirstPage - // 792: 72 * 11 inches - TopRow - Top is high value - float _PointsPerPage = 792; -#endif if (IsWordDocPara) { PdfReader tmp = null; @@ -484,9 +503,7 @@ namespace Volian.Print.Library DebugText.WriteLine("ToPdf1:{0},'{1}',{2},{3},{4},{5}", MyItemInfo.ItemID, MyItemInfo.ShortSearchPath, XOffset, yLocation, yPageStart, YTopMost); int paginate = Paginate(yLocation, yTopMargin, yBottomMargin); bool firstHighLevelStep = MyItemInfo.IsHigh && (MyItemInfo.MyPrevious == null); -#if AllButFirstPage - SectionInfo currentSectionInfo = MyItemInfo.ActiveSection as SectionInfo;//MyItemInfo as SectionInfo; -#endif + switch (paginate) { case 0: // No page break @@ -499,19 +516,8 @@ namespace Volian.Print.Library break; case 1: // Break on High Level Step OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); -#if AllButFirstPage - - // need logic for AllButFirstPage - // recac yTopMargin, YBottomMargin, YTopMost??? - currentSectionInfo.DidFirstPageDocStyle = true; - //MyItemInfo.DidFirstPageDocStyle = true; - yTopMargin = _PointsPerPage - (float)currentSectionInfo.MyDocStyle.Layout.TopMargin; //(float)MyItemInfo.MyDocStyle.Layout.TopMargin; - yBottomMargin = Math.Max(0, yTopMargin - (float)currentSectionInfo.MyDocStyle.Layout.PageLength); //(float)MyItemInfo.MyDocStyle.Layout.PageLength); -#endif cb.PdfDocument.NewPage(); -#if AllButFirstPage - MyPageHelper.MySection = currentSectionInfo; -#endif + ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); DebugText.WriteLine("Paginate1"); if (MyItemInfo.IsSection) { @@ -557,19 +563,8 @@ namespace Volian.Print.Library } MyPageHelper.BottomMessage = new vlnText(cb, this, myMsg, myMsg, docstyle.Layout.LeftMargin + XOffsetBox + docstyle.Continue.Bottom.Margin ?? 0, msg_yLocation, docstyle.Continue.Bottom.Font);// MyItemInfo.ActiveFormat.PlantFormat.FormatData.Font); } -#if AllButFirstPage - // need logic for AllButFirstPage - // recac yTopMargin, YBottomMargin, YTopMost??? - //currentSectionInfo.DidFirstPageDocStyle = true; - currentSectionInfo.DidFirstPageDocStyle = true; - //MyItemInfo.DidFirstPageDocStyle = true; - yTopMargin = _PointsPerPage - (float)currentSectionInfo.MyDocStyle.Layout.TopMargin; //(float)MyItemInfo.MyDocStyle.Layout.TopMargin; - yBottomMargin = Math.Max(0, yTopMargin - (float)currentSectionInfo.MyDocStyle.Layout.PageLength); //(float)MyItemInfo.MyDocStyle.Layout.PageLength); -#endif cb.PdfDocument.NewPage(); -#if AllButFirstPage - MyPageHelper.MySection = currentSectionInfo; -#endif + ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); DebugText.WriteLine("Paginate2"); if ((MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style ?? 0 & E_DocStructStyle.UseSectionFoldout) != 0 || MyPageHelper.DoFloatingFoldout) PromsPrinter.DoFoldoutPage(cb, "Break within Step", MyPageHelper.TextLayer, MyPageHelper); // temporary foldout @@ -602,19 +597,8 @@ namespace Volian.Print.Library if (!firstHighLevelStep) { OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin); -#if AllButFirstPage - - // need logic for AllButFirstPage - // recac yTopMargin, YBottomMargin, YTopMost??? - currentSectionInfo.DidFirstPageDocStyle = true; - //MyItemInfo.DidFirstPageDocStyle = true; - yTopMargin = _PointsPerPage - (float)currentSectionInfo.MyDocStyle.Layout.TopMargin; //(float)MyItemInfo.MyDocStyle.Layout.TopMargin; - yBottomMargin = Math.Max(0, yTopMargin - (float)currentSectionInfo.MyDocStyle.Layout.PageLength); //(float)MyItemInfo.MyDocStyle.Layout.PageLength); -#endif cb.PdfDocument.NewPage(); // HLS (7 lpi) breakif (MyItemInfo.IsSection) -#if AllButFirstPage - MyPageHelper.MySection = currentSectionInfo; -#endif + ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin); DebugText.WriteLine("Paginate3"); if (MyItemInfo.IsSection) { diff --git a/PROMS/Volian.Print.Library/vlnPrintObject.cs b/PROMS/Volian.Print.Library/vlnPrintObject.cs index d37f5032..b5bccc17 100644 --- a/PROMS/Volian.Print.Library/vlnPrintObject.cs +++ b/PROMS/Volian.Print.Library/vlnPrintObject.cs @@ -328,7 +328,7 @@ namespace Volian.Print.Library } return para; } - public abstract float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin); + public abstract float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin); protected float CalculateYOffset(float yPageStart, float yTopMargin) { float yLocation = yPageStart - YOffset; @@ -369,11 +369,11 @@ namespace Volian.Print.Library } public partial class vlnPrintObjects : List { - public float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) + public float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) { foreach (vlnPrintObject part in this) { - yPageStart = part.ToPdf(cb, yPageStart, yTopMargin, yBottomMargin); + yPageStart = part.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin); } return yPageStart; } diff --git a/PROMS/Volian.Print.Library/vlnRNOSeparator.cs b/PROMS/Volian.Print.Library/vlnRNOSeparator.cs index 79777eb6..263085bb 100644 --- a/PROMS/Volian.Print.Library/vlnRNOSeparator.cs +++ b/PROMS/Volian.Print.Library/vlnRNOSeparator.cs @@ -37,7 +37,7 @@ namespace Volian.Print.Library MyFont = formatInfo.PlantFormat.FormatData.Font; Width = sepStr.Length * MyFont.CharsToTwips + _WidthAdjust; } - public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) + public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) { MyContentByte = cb; float yLocation = CalculateYOffset(yPageStart, yTopMargin); diff --git a/PROMS/Volian.Print.Library/vlnTab.cs b/PROMS/Volian.Print.Library/vlnTab.cs index 50ed9201..bb61c6f0 100644 --- a/PROMS/Volian.Print.Library/vlnTab.cs +++ b/PROMS/Volian.Print.Library/vlnTab.cs @@ -79,7 +79,6 @@ namespace Volian.Print.Library } private float GetTextWidth(VE_Font vefont, string txt, string symblFontName) { - System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont)); System.Drawing.Font symbFont = new System.Drawing.Font(symblFontName, (float)vefont.Size); iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font); @@ -131,11 +130,21 @@ namespace Volian.Print.Library Width = (float)myparent.MyItemInfo.FormatStepData.TabData.IdentWidth; else if (CCCs != IIIs) { - origTab1 = origTab1.TrimStart(" ".ToCharArray()); - // 6 = number of points per character. 4 characters between end of tab and beginning of text - // origTab1.Trim... is number of non-space characters of the tab string. - // Tested for FPL & NSP - Width = 6 * (4+origTab1.Trim(" ".ToCharArray()).Length); + if (myparent.MyItemInfo.ActiveFormat.Name.Contains("SHE")) // Temporary for SHE development. need better way to do this check + { + if (myparent.MyItemInfo.IsHigh) + Width = 6 * origTab.Length; + else + Width = GetTextWidth(MyFont, (Text != null ? Text : origTab), symblFontName); //MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length); + } + else + { + origTab1 = origTab1.TrimStart(" ".ToCharArray()); + // 6 = number of points per character. 4 characters between end of tab and beginning of text + // origTab1.Trim... is number of non-space characters of the tab string. + // Tested for FPL & NSP + Width = 6 * (4 + origTab1.Trim(" ".ToCharArray()).Length); + } } else Width = GetTextWidth(MyFont, (Text != null ? Text : origTab), symblFontName); //MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length); @@ -264,7 +273,7 @@ namespace Volian.Print.Library } } - public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) + public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) { if (MyParent.MyItemInfo.FormatStepData != null && MyParent.MyItemInfo.FormatStepData.StepPrintData != null) XOffset += (float)(MyParent.MyItemInfo.FormatStepData.StepPrintData.PosAdjust ?? 0); diff --git a/PROMS/Volian.Print.Library/vlnText.cs b/PROMS/Volian.Print.Library/vlnText.cs index 4727a188..2dda61fd 100644 --- a/PROMS/Volian.Print.Library/vlnText.cs +++ b/PROMS/Volian.Print.Library/vlnText.cs @@ -40,7 +40,7 @@ namespace Volian.Print.Library public vlnText() { } - public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin) + public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) { // The END message was not printing for NSP. The yLocation was getting set to a negative number, thus printing off the page. // Found that the YOffset, cacluated when the bottom message was created, is really the actual location, at least in this case.