Project转PDF方法
引用:
using Microsoft.Office.Interop.MSProject;
方法:
/// <summary> /// 把Project文件转换成PDF格式文件 /// </summary> /// <param name="sourcePath">源文件路径</param> /// <param name="targetPath">目标文件路径</param> /// <returns>true=转换成功</returns> public static bool ProjectToPDF(string sourcePath, string targetPath) { bool result; object missing = Type.Missing; Microsoft.Office.Interop.MSProject.ApplicationClass application = null; try { application = new Microsoft.Office.Interop.MSProject.ApplicationClass(); application.Visible = false; application.FileOpenEx(sourcePath); application.DocumentExport(targetPath, Microsoft.Office.Interop.MSProject.PjDocExportType.pjPDF); result = true; } catch (Exception e) { Console.WriteLine(e.Message); result = false; } finally { if (application != null) { application.DocClose(); application.Quit(); application = null; } GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); } return result; }
【原文地址】http://www.51aras.com/?id=19