Issue while exporting the word to PDF using the interOp dll


I have a program to convert the word document into PDF document , it has a code like below :

m_document.ExportAsFixedFormat(string OutputFileName, WdExportFormat ExportFormat, bool OpenAfterExport = false, WdExportOptimizeFor OptimizeFor = WdExportOptimizeFor.wdExportOptimizeForPrint, WdExportRange Range = WdExportRange.wdExportAllDocument, int From = 1, int To = 1, WdExportItem Item = WdExportItem.wdExportDocumentContent, bool IncludeDocProps = false, bool KeepIRM = true, WdExportCreateBookmarks CreateBookmarks = WdExportCreateBookmarks.wdExportCreateNoBookmarks, bool DocStructureTags = true, bool BitmapMissingFonts = true, bool UseISO19005_1 = false, ref object FixedFormatExtClassPtr);

of which is I have used the values of DocStructureTags , BitmapMissingFonts and UseISO19005_1 as in two ways :

1) True , true and false 2) false , false and true.

For both combination I was able to generate a PDF document in my machine ( MS Office 365 pro , MS word 2013 and Visual studio 2017 professional) but in other machines ( Ms office 365 and VS 2019 professional) only the first case work. For the second case am getting the exception as

System.Runtime.InteropServices.COMException (0x80004005): The export failed due to an unexpected error. at Microsoft.Office.Interop.Word.DocumentClass.ExportAsFixedFormat(String OutputFileName, WdExportFormat ExportFormat, Boolean OpenAfterExport, WdExportOptimizeFor OptimizeFor, WdExportRange Range, Int32 From, Int32 To, WdExportItem Item, Boolean IncludeDocProps, Boolean KeepIRM, WdExportCreateBookmarks CreateBookmarks, Boolean DocStructureTags, Boolean BitmapMissingFonts, Boolean UseISO19005_1, Object& FixedFormatExtClassPtr) at toc_Append.Program.startToc(String tocFilePath, String xmlFilePath) in D:\PDF_Generation\PDF Generation\toc_Append\Program.cs:line 372

what could be the reason for this export failure ?

asked on Stack Overflow Feb 19, 2020 by Deepak Raj • edited Mar 24, 2020 by Deepak Raj

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0