Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ protected override void Convert()
this.UserState = Properties.Resources.ConversionStateConversion;

Debug.Log("Convert PowerPoint document to pdf.");
this.document.ExportAsFixedFormat(this.intermediateFilePath, PowerPoint.Enums.PpFixedFormatType.ppFixedFormatTypePDF);

// Use SaveAs with the native PDF file type instead of ExportAsFixedFormat.
// On recent Microsoft 365 builds the late-bound ExportAsFixedFormat call
// throws DISP_E_TYPEMISMATCH (0x80020005), which broke pptx -> pdf in v2.2.
// SaveAs(path, ppSaveAsPDF) is the supported, robust automation path.
this.document.SaveAs(this.intermediateFilePath, PowerPoint.Enums.PpSaveAsFileType.ppSaveAsPDF, NetOffice.OfficeApi.Enums.MsoTriState.msoFalse);

Debug.Log($"Close PowerPoint document '{this.InputFilePath}'.");
this.document.Close();
Expand Down
23 changes: 11 additions & 12 deletions Application/FileConverter/ConversionJobs/ConversionJob_Word.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,13 @@ protected override void Convert()
this.UserState = Properties.Resources.ConversionStateConversion;

Debug.Log("Convert word document to pdf.");
// this.document.ExportAsFixedFormat(this.intermediateFilePath, Word.WdExportFormat.wdExportFormatPDF);
this.document.ExportAsFixedFormat(this.intermediateFilePath,
Word.Enums.WdExportFormat.wdExportFormatPDF,
false,
Word.Enums.WdExportOptimizeFor.wdExportOptimizeForPrint,
Word.Enums.WdExportRange.wdExportAllDocument,
1, 1,
Word.Enums.WdExportItem.wdExportDocumentContent,
true,
true,
Word.Enums.WdExportCreateBookmarks.wdExportCreateHeadingBookmarks,
true);

// Use SaveAs with the native PDF format instead of ExportAsFixedFormat.
// On recent Microsoft 365 builds the late-bound ExportAsFixedFormat call
// throws DISP_E_TYPEMISMATCH (0x80020005), which broke docx -> pdf in v2.2.
// SaveAs(path, wdFormatPDF) is the robust, supported automation path and is
// not affected by the tightened type libraries.
this.document.SaveAs(this.intermediateFilePath, Word.Enums.WdSaveFormat.wdFormatPDF);

Debug.Log($"Close word document '{this.InputFilePath}'.");
this.document.Close(Word.Enums.WdSaveOptions.wdDoNotSaveChanges);
Expand Down Expand Up @@ -163,6 +158,10 @@ protected override void InitializeOfficeApplicationInstanceIfNecessary()
{
Visible = false
};

// Suppress modal dialogs (e.g. format-compatibility prompts) so the headless
// conversion does not block waiting for user input when exporting to PDF.
this.application.DisplayAlerts = Word.Enums.WdAlertLevel.wdAlertsNone;
}

protected override void ReleaseOfficeApplicationInstanceIfNeeded()
Expand Down
22 changes: 22 additions & 0 deletions Installer/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,28 @@
<Component Guid="{6268D6C0-42D8-4487-AC4B-33C9874C9E2F}">
<File Id="WpfAnimatedGif.dll" KeyPath="yes" Source="$(var.FileConverter.TargetDir)WpfAnimatedGif.dll" Checksum="yes" />
</Component>

<!-- NetOffice assemblies (Word/Excel/PowerPoint interop). These were missing
from the v2.2 MSI, causing FileNotFoundException/TypeLoadException and
breaking every Office (docx/xlsx/pptx) conversion on a clean install. -->
<Component Guid="{C1A2B3C4-D5E6-4F70-8A91-B2C3D4E5F607}">
<File Id="NetOffice.dll" Source="$(var.FileConverter.TargetDir)NetOffice.dll" KeyPath="yes" Checksum="yes" />
</Component>
<Component Guid="{D2B3C4D5-E6F7-4081-9B02-C3D4E5F60718}">
<File Id="OfficeApi.dll" Source="$(var.FileConverter.TargetDir)OfficeApi.dll" KeyPath="yes" Checksum="yes" />
</Component>
<Component Guid="{E3C4D5E6-F708-4192-AC13-D4E5F6071829}">
<File Id="WordApi.dll" Source="$(var.FileConverter.TargetDir)WordApi.dll" KeyPath="yes" Checksum="yes" />
</Component>
<Component Guid="{F4D5E6F7-0891-42A3-BD24-E5F60718293A}">
<File Id="ExcelApi.dll" Source="$(var.FileConverter.TargetDir)ExcelApi.dll" KeyPath="yes" Checksum="yes" />
</Component>
<Component Guid="{A5E6F708-192A-43B4-CE35-F60718293A4B}">
<File Id="PowerPointApi.dll" Source="$(var.FileConverter.TargetDir)PowerPointApi.dll" KeyPath="yes" Checksum="yes" />
</Component>
<Component Guid="{B6F70819-2A3B-44C5-DF46-0718293A4B5C}">
<File Id="VBIDEApi.dll" Source="$(var.FileConverter.TargetDir)VBIDEApi.dll" KeyPath="yes" Checksum="yes" />
</Component>

<!-- Configuration and documentation -->
<Component Guid="{AD58807A-2AE2-48BE-AB55-9BDE9BBE37F3}">
Expand Down