先下载Microsoft.Office.Interop.Word.dll
引用using Word = Microsoft.Office.Interop.Word;
2种方式
/ <summary>
/// Word转换成pdf
/// </summary>
/// <param name="sourcePath">源文件路径</param>
/// <param name="targetPath">目标文件路径</param>
/// <returns>true=转换成功</returns>
public static bool WordToPDF(string sourcePath, string targetPath)
{
bool result = false;
if (File.Exists(sourcePath))
{
Word.Document document = null;
try
{
Microsoft.Office.Interop.Word.Application application = new Microsoft.Office.Interop.Word.Application();
if (File.Exists(targetPath))
File.