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

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.

AlexAn75541 added a commit to AlexAn75541/FileConverter that referenced this pull request Oct 21, 2026
…kflow

- Fix FFmpeg stdout pipe deadlock hanging conversions (PR Tichau#732)
- Bundle NetOffice DLLs in WiX installer to prevent clean-install crash (PR Tichau#779)
- Fix Word/PowerPoint SaveAs automation for modern M365 DISP_E_TYPEMISMATCH (PR Tichau#779)
- Fix ImageMagick Ghostscript page count probe crash (PR Tichau#806)
- Preserve SVG transparency and add ICO bgra pixel format (PR Tichau#808)
- Enhance shell extension fallback paths against missing registry keys (PR Tichau#804)
- Add SettingsViewModel guards against root folder removal and null handlers
- Add GitHub Actions CI workflow to build MSI and upload artifacts
- Add BRANCHES.md and AGENTS.md documentation
@Rengoku30

Copy link
Copy Markdown

Confirming the Installer/Product.wxs part of this PR fixes the v2.2 crash reported in #721 and #717.

On a v2.2 x64 install with Microsoft 365 Word (Windows 11), I copied the same 6 assemblies this PR adds (lib/net45 from the NetOffice.* 1.7.4.11 NuGet packages, PublicKeyToken=7292cd2a8b1e0703) into the install folder. The FileNotFoundException in ConversionJob_Word.GetOutputFilesCount went away and a 38-page docx converted to a valid PDF.

ExportAsFixedFormat still worked for Word on this machine once the DLLs were present. I didn't test the SaveAs changes or PowerPoint.

Details and the manual workaround are in #721.

neosmith20 referenced this pull request in neosmith20/FileRecast Nov 27, 2026
… fixes

Conversions (ffmpeg)
- Fix conversions stuck forever: stdout (-progress) and stderr are now both read
  asynchronously, so ffmpeg can never block on a full pipe (upstream #749 #780 #800, PR #809 #732).
- Watchdog kills a frozen ffmpeg; cancel kills ffmpeg immediately.
- Progress parsed from -progress output (works when the bitrate is unknown).
- Failures detected from the exit code instead of "Error" substrings in the log.
- MP4 drops subtitles it can't store, MKV keeps them; audio from video uses -vn.

GPU encoding
- H.264 / H.265 / AV1 codec choice for MP4 and MKV.
- NVIDIA NVENC, AMD AMF and new Intel Quick Sync encoders for the three codecs.
- New Automatic mode (probes which GPU encoder works) and automatic CPU fallback
  when GPU encoding fails (upstream PR #702).
- Filters run on the CPU, so rotate/scale presets work with every GPU mode.

Upstream PRs/issues merged or reimplemented
- Animated WebP (#804), BMP/TIFF outputs (#775), ALAC (#562), AMR input (#811),
  progressive JPEG (#814), Markdown to PDF/DOCX via Word (#802), multipage TIFF (#812),
  SVG transparency (#808), PDF rangecheck crash (#806), path template tokens (#797/#813),
  Office conversions broken in 2.2 (#778 #779), context menu disappearing (#798).
- Translations: Catalan (#707), Khmer (#761, junk text removed), Italian (#712, XML fixed),
  Chinese (#698 #763). Translations were not loaded at all (#787): fixed the post-build step
  that shipped empty satellite assemblies and added the probing path. Urdu file renamed so it loads.

Other fixes
- Never delete/move the input file when no output was generated; restore the _TEMP renamed input on failure.
- Office: no dialogs, COM objects released, ExportAsFixedFormat fallback to SaveAs.
- Atomic settings save; explorer extension reloads presets when they change.
- Installer: NetOffice and Markdig libraries; unsigned builds when Installer.sign is absent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LMhX9UyqkxoopVuSF4tg9g

This branch has not been deployed

No deployments
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.

2 participants