diff --git a/PROMS/LBWordLibrary/LBComObject.cs b/PROMS/LBWordLibrary/LBComObject.cs index a8a585a3..7f5729b5 100644 --- a/PROMS/LBWordLibrary/LBComObject.cs +++ b/PROMS/LBWordLibrary/LBComObject.cs @@ -339,9 +339,7 @@ namespace LBWordLibrary } public void ExportAsFixedFormat(string OutputFileName, LBWdExportFormat ExportFormat) { - // iso 19005-1 compliant (PDF/A) should be set to false. setting it to true causes the background - // for x/y plots to be set to black rather than transparent. (2nd to last parameter (field is: UseISO19005_1) in next line) - InvokeMethod("ExportAsFixedFormat", OutputFileName, ExportFormat, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, false, Missing.Value); + InvokeMethod("ExportAsFixedFormat", OutputFileName, ExportFormat, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); } public void ExportAsFixedFormat(string OutputFileName, LBWdExportFormat ExportFormat, Boolean OpenAfterExport, LBWdExportOptimizeFor OptimizeFor, LBWdExportRange Range, int From, int To, LBWdExportItem Item, Boolean IncludeDocProps, Boolean KeepIRM, LBWdExportCreateBookmarks CreateBookmarks, Boolean DocStructureTags, Boolean BitmapMissingFonts, Boolean UseISO19005_1, object FixedFormatExtClassPtr) { diff --git a/PROMS/LBWordLibrary/LBObjectExtension.cs b/PROMS/LBWordLibrary/LBObjectExtension.cs index 4596b445..a9a94b59 100644 --- a/PROMS/LBWordLibrary/LBObjectExtension.cs +++ b/PROMS/LBWordLibrary/LBObjectExtension.cs @@ -38,26 +38,26 @@ namespace LBWordLibrary { get { - // this is to determine if ExportAsFixedFormat was installed in MSOffice - // This key only worked for Vista - //RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"Installer\Components\12B306B24E250DD428FC7016B6FB4BD8"); - // 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"); - if (key != null) + // this is to determine if ExportAsFixedFormat was installed in MSOffice + // This key only worked for Vista + //RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"Installer\Components\12B306B24E250DD428FC7016B6FB4BD8"); + // This key works for Windows Vista and Windows 7 + try { - key.Close(); + 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; } - _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; - } + 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) @@ -90,9 +90,9 @@ namespace LBWordLibrary } throw new Exception("Cannot find a name to use"); } - public string CreatePDF(string pdfFileName, bool openPDF) + public string CreatePDF(string pdfFileName, bool openPDF,int DebugStatus) { - pdfFileName = CreatePDF(pdfFileName); + pdfFileName = CreatePDF(pdfFileName, DebugStatus); if (openPDF) OpenPDF(pdfFileName); return pdfFileName; } @@ -120,13 +120,13 @@ namespace LBWordLibrary Console.WriteLine("{0:yyyy-MM-dd HH:mm:ss.ffff} {1:yyyy-MM-dd HH:mm:ss.ffff} {2}", DateTime.Now, proc.ExitTime ,TimeSpan.FromTicks(proc.ExitTime.Ticks - tStart.Ticks).TotalMilliseconds); } - public string CreatePDF(string pdfFileName) + public string CreatePDF(string pdfFileName, int DebugStatus) { pdfFileName = AvailableFileName(pdfFileName); if (((int)Convert.ToSingle(Version)) > 12) - return CreatePDF2007(pdfFileName); + return CreatePDF2007(pdfFileName, DebugStatus); if (((int)Convert.ToSingle(Version)) == 12 && WordPDFExporterInstalled) - return CreatePDF2007(pdfFileName); + return CreatePDF2007(pdfFileName, DebugStatus); else if (VolianPDFInstalled) { _MyLog.WarnFormat("Using VolianPDFWriter - MSWord Version = '{0}'", Version); @@ -198,13 +198,13 @@ namespace LBWordLibrary throw new Exception("Error creating PDF - LBApplicationClass.CreatePDF2003BG", ex); } } - public string CreatePDF2007(string pdfFileName, bool openPDF) + public string CreatePDF2007(string pdfFileName, bool openPDF, int DebugStatus) { - pdfFileName = CreatePDF2007(pdfFileName); + pdfFileName = CreatePDF2007(pdfFileName, DebugStatus); if (openPDF) OpenPDF(pdfFileName); return pdfFileName; } - public string CreatePDF2007(string pdfFileName) + public string CreatePDF2007(string pdfFileName,int DebugStatus) { pdfFileName = AvailableFileName(pdfFileName); // Removed to support MSWord 2010 and beyond. @@ -212,7 +212,7 @@ namespace LBWordLibrary // throw new Exception("MS Word PDF Exporter is not installed"); try { - ActiveDocument.ExportAsFixedFormat(pdfFileName, LBWdExportFormat.wdExportFormatPDF); + ActiveDocument.ExportAsFixedFormat(pdfFileName, LBWdExportFormat.wdExportFormatPDF, DebugStatus); return pdfFileName; } catch (Exception ex) @@ -234,6 +234,12 @@ namespace LBWordLibrary } public partial class LBDocumentClass : LBComObject { + public void ExportAsFixedFormat(string OutputFileName, LBWdExportFormat ExportFormat, int DebugStatus) + { + // iso 19005-1 compliant (PDF/A) [UseISO19005_1] should be set to false. for compare print + // iso 19005-1 compliant (PDF/A) [UseISO19005_1] should be set to true for production print + InvokeMethod("ExportAsFixedFormat", OutputFileName, ExportFormat, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, DebugStatus == 0, Missing.Value); + } private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); public void SaveAs2000(string fileName) {