Skip to content

Fix docx/pptx → PDF conversion broken in v2.2 (clean install + recent Microsoft 365) - #779

Open
mzyqzmd wants to merge 1 commit into
Tichau:integrationfrom
mzyqzmd:integration
Open

Fix docx/pptx → PDF conversion broken in v2.2 (clean install + recent Microsoft 365)#779
mzyqzmd wants to merge 1 commit into
Tichau:integrationfrom
mzyqzmd:integration

Conversation

@mzyqzmd

@mzyqzmd mzyqzmd commented Jul 13, 2026

Copy link
Copy Markdown

Summary

Since v2.2, converting Word/PowerPoint documents to PDF fails.
This PR fixes both root causes so the conversion works again on a
clean install and on current Microsoft 365 builds.

Root cause

v2.2 migrated the Office interop from the Office PIA to NetOffice,
which introduced two independent regressions:

  1. Missing dependencies in the installer (clean-install failure)
    Installer/Product.wxs was not updated to ship the NetOffice
    assemblies. On a clean machine the conversion crashes with
    FileNotFoundException / TypeLoadException because
    NetOffice.dll, OfficeApi.dll, WordApi.dll, ExcelApi.dll,
    PowerPointApi.dll, VBIDEApi.dll are missing from the package.

  2. ExportAsFixedFormat throws on recent Microsoft 365 (runtime failure)
    The late-bound ExportAsFixedFormat calls throw
    DISP_E_TYPEMISMATCH (0x80020005) on Microsoft 365 builds with
    tightened type libraries, breaking the conversion even when the
    assemblies are present.

Changes

  • ConversionJob_Word.cs
    • Replaced ExportAsFixedFormat with
      document.SaveAs(path, WdSaveFormat.wdFormatPDF).
    • Set application.DisplayAlerts = wdAlertsNone so headless
      conversion does not block on format-compatibility dialogs.
  • ConversionJob_PowerPoint.cs
    • Replaced ExportAsFixedFormat with
      document.SaveAs(path, PpSaveAsFileType.ppSaveAsPDF, msoFalse).
  • Installer/Product.wxs
    • Added the 6 NetOffice assemblies so they deploy on clean installs.

Testing

  • Verified Word and PowerPoint conversion produce correct PDFs
    (page count, CJK fonts, embedded images) via the CLI:
    FileConverter.exe --conversion-preset "To Pdf" input.docx
  • Verified the installer now bundles the NetOffice DLLs
    (extract via dark.exe -x).

Scope / known follow-up

Excel → PDF still uses ExportAsFixedFormat because Workbook.SaveAs
does not support PDF output; left unchanged. Same M365 regression
may affect Excel and is a known follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant