B2019-041: The merging of pdfs crashes when there is a bad (corrupt) procedure pdf to merge
This commit is contained in:
parent
3aa1834cca
commit
17ae2c3df7
@ -42,6 +42,7 @@ namespace Volian.Print.Library
|
||||
// selects the 'Merge' button off of the print dialog when doing a Print All. (C2019-012)
|
||||
public class MergedPdf
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private List<MergedPdfProc> _mergedPdfs = null; // This list has all procedure pdfs that will be included in the merged file.
|
||||
public List<MergedPdfProc> MergedPdfs
|
||||
{
|
||||
@ -116,7 +117,10 @@ namespace Volian.Print.Library
|
||||
FlexibleMessageBox.Show("Error in finding pdf files to merge. Cannot print with date/time as part of pdf name. Or check that individual pdfs were generated.", "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return false;
|
||||
}
|
||||
PdfReader reader = new PdfReader(_folder + @"\" + mpp.PdfFileName);
|
||||
PdfReader reader = null;
|
||||
try // B2019-041: added a try/catch for when a corrupt pdf was created for a procedure, just skip & add message to error log.
|
||||
{
|
||||
reader = new PdfReader(_folder + @"\" + mpp.PdfFileName);
|
||||
int numPages = reader.NumberOfPages;
|
||||
int currentPageNumber = 0;
|
||||
PdfOutline outline = null;
|
||||
@ -142,6 +146,12 @@ namespace Volian.Print.Library
|
||||
canvas.AddTemplate(page, 0, 0); // adds the page to the combined pdf
|
||||
} while (currentPageNumber < numPages);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string tmp = string.Format("Error merging pdf {0}", mpp.PdfFileName);
|
||||
_MyLog.Error(tmp, ex);
|
||||
}
|
||||
}
|
||||
doc.Close();
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user