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