B2017-218 - Handle invalid MS Word sections when printing
This commit is contained in:
parent
73593b8546
commit
7a97ee3b07
@ -1015,9 +1015,18 @@ namespace Volian.Print.Library
|
|||||||
float pdfSize = 0;
|
float pdfSize = 0;
|
||||||
using (PdfInfo myPdf = PdfInfo.Get(mySection,false))
|
using (PdfInfo myPdf = PdfInfo.Get(mySection,false))
|
||||||
{
|
{
|
||||||
sectPageCount = (int)(Math.Ceiling(myPdf.PageCount));
|
if (myPdf == null) // B2017-218 Handle invalid word sections
|
||||||
locEndOfWordDoc = (float)(myPdf.PageCount - (sectPageCount - 1)) * 100;
|
{
|
||||||
pdfSize = (float)myPdf.PageCount;
|
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);
|
string tocKey = string.Format("TOC{0}", mySection.ItemID);
|
||||||
if (_MyHelper.MyTOCPageCounts.ContainsKey(tocKey))
|
if (_MyHelper.MyTOCPageCounts.ContainsKey(tocKey))
|
||||||
@ -2288,6 +2297,12 @@ namespace Volian.Print.Library
|
|||||||
{
|
{
|
||||||
try
|
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;
|
MyReader = MyPdfFile != null ? new PdfReader(MyPdfFile) : null;
|
||||||
string key = string.Empty;
|
string key = string.Empty;
|
||||||
for (int i = 1; i <= MyReader.NumberOfPages; i++)
|
for (int i = 1; i <= MyReader.NumberOfPages; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user