diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index bc638180..cd6fbf0e 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -1015,9 +1015,18 @@ namespace Volian.Print.Library float pdfSize = 0; using (PdfInfo myPdf = PdfInfo.Get(mySection,false)) { - sectPageCount = (int)(Math.Ceiling(myPdf.PageCount)); - locEndOfWordDoc = (float)(myPdf.PageCount - (sectPageCount - 1)) * 100; - pdfSize = (float)myPdf.PageCount; + if (myPdf == null) // B2017-218 Handle invalid word sections + { + cb.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED), 20); + cb.SetTextMatrix(cb.PdfDocument.Left+200,cb.PdfDocument.Bottom+cb.PdfDocument.Top / 2); + cb.ShowText("Word Section Invalid"); + } + else + { + sectPageCount = (int)(Math.Ceiling(myPdf.PageCount)); + locEndOfWordDoc = (float)(myPdf.PageCount - (sectPageCount - 1)) * 100; + pdfSize = (float)myPdf.PageCount; + } } string tocKey = string.Format("TOC{0}", mySection.ItemID); if (_MyHelper.MyTOCPageCounts.ContainsKey(tocKey)) @@ -2288,6 +2297,12 @@ namespace Volian.Print.Library { try { + FileInfo fi = new FileInfo(MyPdfFile); + if (fi.Length == 0) // B2017-218 Handle invalid word sections + { + MessageBox.Show(si.DisplayNumber + " " + si.DisplayText + " is not valid", "Invalid Word Section", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } MyReader = MyPdfFile != null ? new PdfReader(MyPdfFile) : null; string key = string.Empty; for (int i = 1; i <= MyReader.NumberOfPages; i++)