using Word = Microsoft.Office.Interop.Word;/// <summary>/// office word转化为pdf/// </summary>/// <param name="sourcePath"></param>/// <param name="abc"></param>/// <returns></returns>public static bool WordToPDF(string sourcePath, out string abc){bool result = false;abc = string.Empty;Word.Application application = new Word.Application();Word.Document document = null;try{application.Visible = false;document = application.Documents.Open(sourcePath);string PDFPath = sourcePath.Replace(".doc", ".pdf");//pdf存放位置if (!File.Exists(@PDFPath))//存在PDF,不需要继续转换{document.ExportAsFixedFormat(PDFPath, Word.WdExportFormat.wdExportFormatPDF);abc = PDFPath;}result = true;}catch (Exception e){//Console.WriteLine(e.Message);result = false;}finally{document.Close();}return result;}
备注:使word转换为pdf,需要下载office软件