高分求ppt转pdf问题!!!在线期待期待解决
背景1:ASP.NET 下在线ppt转Pdf ,我的实现方法是引用com组件的方式去实现。目前一般的ppt是可以实现转pdf的。主要实现代码
public static bool PPTToPdf(string sourcePath, string targetPath, PpSaveAsFileType targetFileType)
{
bool result;
object missing = Type.Missing;
ApplicationClass application = null;
Presentation persentation = null;
try
{
application = new ApplicationClass();
persentation = application.Presentations.Open(sourcePath, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
persentation.SaveAs(targetPath, targetFileType, Microsoft.Office.Core.MsoTriState.msoTrue);
result = true;
}
}
List<string> _fontNames = new List<string>();
foreach (PowerPoint.Slide slide in persentation.Slides)
{
foreach (PowerPoint.Shape shape in slide.Shapes)
{
if (shape.HasTextFrame ==MsoTriState.msoTrue &&
shape.TextFrame.HasText == MsoTriState.msoTrue)
{
PowerPoint.TextRange textRange = shape.TextFrame.TextRange;
for (int i = 0; i < textRange.Length; ++i)
{
PowerPoint.Font font = textRange.Characters(i, 1).Font;
if (!_fontNames.Contains(font.Name))
_fontNames.Add(font.Name);
}
}
}
}