diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index 21462a2f..023378f7 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -235,7 +235,6 @@ namespace Volian.Print.Library if (retstr == null) return null; BeforePageNumberPdf = retstr; ProcedureInfo.RefreshPageNumTransitions(_MyItem as ProcedureInfo); - MyContentByte = null; _MyReaderHelper = new ReaderHelper(this); return Print(_MyItem as ProcedureInfo, pdfFolder, makePlacekeeper); } @@ -289,13 +288,13 @@ namespace Volian.Print.Library _WatermarkLayer.SetPrint("Watermark", true); } } - - private void CloseDocument(PdfContentByte cb, string fileName) + private void CloseDocument(string fileName) { int profileDepth = ProfileTimer.Push(">>>> CloseDocument"); try { - cb.PdfDocument.Close(); + MyContentByte.PdfDocument.Close(); + MyContentByte = null; } catch (Exception ex) { @@ -314,7 +313,7 @@ namespace Volian.Print.Library set { _MyContentByte = value; - MyReaderHelper.LoadTree(MyItem); + if(value != null)MyReaderHelper.LoadTree(MyItem); } } public void NewPage() @@ -328,11 +327,7 @@ namespace Volian.Print.Library if (_MyHelper != null) { SectionInfo currentSection = _MyHelper.MySection; - //if (currentSection.InList(79359)) Console.WriteLine("Here"); - //currentSection = currentSection.ActiveParent as SectionInfo; SectionInfo nextSection = GetNextSection(currentSection); // _MyHelper.MySection.NextItem as SectionInfo; - //if (nextSection == null) Console.WriteLine("Here"); - //if (nextSection != null && nextSection.InList(79359)) Console.WriteLine("Here"); SectionConfig sc = (nextSection ?? currentSection).MyConfig as SectionConfig; bool wordMargins = (sc != null && sc.Section_WordMargin == "Y"); if (wordMargins) @@ -342,7 +337,7 @@ namespace Volian.Print.Library LastWordSection = nextSection; _PageCountOfWordSection = 1; MyReaderHelper.MySectionInfo = LastWordSection; - ShowNeedForPageSize(); + //ShowNeedForPageSize(); rct = MyReaderHelper.GetSize(LastWordSection, 1); } else if (!currentSection.IsStepSection) //current section is a word section @@ -355,7 +350,7 @@ namespace Volian.Print.Library else _PageCountOfWordSection++; MyReaderHelper.MySectionInfo = LastWordSection; - ShowNeedForPageSize(); + //ShowNeedForPageSize(); rct = MyReaderHelper.GetSize(LastWordSection, _PageCountOfWordSection); } } @@ -363,10 +358,10 @@ namespace Volian.Print.Library { rct = PageSize.LETTER; } - Console.WriteLine("\"{0}\"\t\"{1}\"\t\"{2}\"\t\"{3}\"\t{4}" - , currentSection == null ? "" : currentSection.DisplayNumber + " " + currentSection.DisplayText - , nextSection == null ? "" : nextSection.DisplayNumber + " " + nextSection.DisplayText - , sectionChange, wordMargins,_PageCountOfWordSection); + //Console.WriteLine("\"{0}\"\t\"{1}\"\t\"{2}\"\t\"{3}\"\t{4}" + // , currentSection == null ? "" : currentSection.DisplayNumber + " " + currentSection.DisplayText + // , nextSection == null ? "" : nextSection.DisplayNumber + " " + nextSection.DisplayText + // , sectionChange, wordMargins,_PageCountOfWordSection); } MyContentByte.PdfDocument.SetPageSize(rct); MyContentByte.PdfDocument.NewPage(); @@ -400,13 +395,13 @@ namespace Volian.Print.Library } } private int _PageCountOfWordSection = 0; - private void ShowNeedForPageSize() - { - if(PreviousWordSection != null && PreviousWordSection != LastWordSection) - Console.WriteLine("Switch From {0}.{1} ",PreviousWordSection.DisplayNumber,PreviousWordSection.DisplayText); - Console.WriteLine("To {0}.{1} Page: {2}",LastWordSection.DisplayNumber,LastWordSection.DisplayText,_PageCountOfWordSection); - PreviousWordSection = LastWordSection; - } + //private void ShowNeedForPageSize() + //{ + // if(PreviousWordSection != null && PreviousWordSection != LastWordSection) + // Console.WriteLine("Switch From {0}.{1} ",PreviousWordSection.DisplayNumber,PreviousWordSection.DisplayText); + // Console.WriteLine("To {0}.{1} Page: {2}",LastWordSection.DisplayNumber,LastWordSection.DisplayText,_PageCountOfWordSection); + // PreviousWordSection = LastWordSection; + //} private PdfContentByte OpenDoc(string outputFileName, iTextSharp.text.Rectangle rect) { PdfWriter writer=null; @@ -428,7 +423,7 @@ namespace Volian.Print.Library sb.AppendLine("If it is open, close and retry."); MessageBox.Show(sb.ToString(), "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning); //MessageBox.Show("Could not create " + outputFileName + ". If it is open, close and retry.", "Error on CreatePdf"); - return null; + return MyContentByte = null; } document.Open(); // Create Layers @@ -443,7 +438,8 @@ namespace Volian.Print.Library PrintOverride.ChangeBarColor = System.Drawing.Color.Red; PrintOverride.DebugColor = System.Drawing.Color.CadetBlue; } - return MyContentByte = writer.DirectContent; + MyContentByte = writer.DirectContent; + return MyContentByte; } //private string CreateFileName(string procNumber, string sectNumber, string sectTitle) //{ @@ -771,7 +767,7 @@ namespace Volian.Print.Library } OnStatusChanged(myProcedure.DisplayNumber + " PDF Creation Completed", PromsPrinterStatusType.Progress, progress); if (DebugPagination.IsOpen) DebugPagination.TotalPages += cb.PdfWriter.CurrentPageNumber; - CloseDocument(cb, outputFileName); + CloseDocument(outputFileName); if (_MyHelper != null && makePlacekeeper) { // Setting the default font to Arial since that is what Calvert is currently using for their Placekeeper pages @@ -1608,7 +1604,8 @@ namespace Volian.Print.Library } public void LoadTree(ItemInfo ii) { - if (dicPage.Count == 0) + dicPage = new Dictionary(); + dicSize = new Dictionary(); LoadSectionTree(ii); } private void LoadSectionTree(ItemInfo ii)