1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > C# office word转换为pdf

C# office word转换为pdf

时间:2022-02-07 06:45:12

相关推荐

C# office word转换为pdf

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软件

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。