Added Error Log output when generating PDF from MSWord 2007.

Changed logic to do an integer rather than a float comparison to determine when the version is MSWord 2007 (12.0).
This commit is contained in:
Rich 2013-10-17 16:42:08 +00:00
parent 812ca6582e
commit 3029c35edf

View File

@ -10,6 +10,7 @@ namespace LBWordLibrary
{ {
public partial class LBApplicationClass : LBComObject public partial class LBApplicationClass : LBComObject
{ {
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary> /// <summary>
/// This gives the option of specifying Background = false to print in the foreground. /// This gives the option of specifying Background = false to print in the foreground.
/// </summary> /// </summary>
@ -41,14 +42,23 @@ namespace LBWordLibrary
// This key only worked for Vista // This key only worked for Vista
//RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"Installer\Components\12B306B24E250DD428FC7016B6FB4BD8"); //RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"Installer\Components\12B306B24E250DD428FC7016B6FB4BD8");
// This key works for Windows Vista and Windows 7 // This key works for Windows Vista and Windows 7
try
{
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\0E5C161912A2A6C4C93C76678926C56C"); RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components\0E5C161912A2A6C4C93C76678926C56C");
if (key != null) if (key != null)
{ {
key.Close(); key.Close();
return true; return true;
} }
_MyLog.WarnFormat("MSWord2007 PDF Export Registry Key Missing");
return false; return false;
} }
catch (Exception ex)
{
_MyLog.WarnFormat("MSWord2007 PDF Export Registry Key Failure {0} - {1}", ex.GetType().Name, ex.Message);
return false;
}
}
} }
private bool CanCreatePDFFile(string pdfFileName) private bool CanCreatePDFFile(string pdfFileName)
{ {
@ -113,12 +123,15 @@ namespace LBWordLibrary
public string CreatePDF(string pdfFileName) public string CreatePDF(string pdfFileName)
{ {
pdfFileName = AvailableFileName(pdfFileName); pdfFileName = AvailableFileName(pdfFileName);
if (Convert.ToSingle(Version) > 12.0F) if (((int)Convert.ToSingle(Version)) > 12)
return CreatePDF2007(pdfFileName); return CreatePDF2007(pdfFileName);
if (Convert.ToSingle(Version) == 12.0F && WordPDFExporterInstalled) if (((int)Convert.ToSingle(Version)) == 12 && WordPDFExporterInstalled)
return CreatePDF2007(pdfFileName); return CreatePDF2007(pdfFileName);
else if (VolianPDFInstalled) else if (VolianPDFInstalled)
{
_MyLog.WarnFormat("Using VolianPDFWriter - MSWord Version = '{0}'", Version);
return CreatePDF2003BG(pdfFileName); return CreatePDF2003BG(pdfFileName);
}
else else
throw new Exception("No PDF Writer support installed for MS Word sections"); throw new Exception("No PDF Writer support installed for MS Word sections");
} }