cognidox / OfficeToPDF

A command line tool to convert Microsoft Office documents to PDFs
https://www.cognidox.com/
Other
610 stars 137 forks source link

Converted PDFs missing markup #38

Closed AlbrightPatents closed 4 years ago

AlbrightPatents commented 5 years ago

Firstly, really useful piece of software so many thanks!

I am having an issue with markup not appearing in the converted PDF and have some suggested changes:

git diff of changes below:

--- a/OfficeToPDF/WordConverter.cs
+++ b/OfficeToPDF/WordConverter.cs
@@ -90,7 +90,7 @@ namespace OfficeToPDF
                         try
                         {
                             // Try to set a property on the object
-                            word.ScreenUpdating = false;
+                            word.Visible = false;
                         }
                         catch (COMException)
                         {
@@ -286,16 +286,18 @@ namespace OfficeToPDF
                     }
                     catch (Exception) { }

-                    // Hide comments
+                    // Show revisons if required
                     try
                     {
+                        bool withMarkup = showMarkup == WdExportItem.wdExportDocumentWithMarkup;
                         word.PrintPreview = false;
+                        docWinView.MarkupMode = WdRevisionsMode.wdInLineRevisions;
                         docWinView.RevisionsView = WdRevisionsView.wdRevisionsViewFinal;
-                        docWinView.ShowRevisionsAndComments = false;
-                        docWinView.ShowComments = false;
-                        docWinView.ShowFormatChanges = false;
-                        docWinView.ShowInkAnnotations = false;
-                        docWinView.ShowInsertionsAndDeletions = false;
+                        docWinView.ShowRevisionsAndComments = withMarkup;
+                        docWinView.ShowComments = withMarkup;
+                        docWinView.ShowFormatChanges = withMarkup;
+                        docWinView.ShowInkAnnotations = withMarkup;
+                        docWinView.ShowInsertionsAndDeletions = withMarkup;
                     }
                     catch (SystemException e) {
                         Console.WriteLine("Failed to set revision settings {0}", e.Message);
AlbrightPatents commented 4 years ago

Now using your latest code and it seems to be working fine with the new options. Many thanks for making these changes.