背景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;
}
}
当转换有一些ppt时报如下异常“ 存储此文件时发生错误”。
背景2:该ppt我在用office2007打开的时候,选择另存为pdf的时候,在转换的过程中报错“ 存储此文件时发生错误”,网上我搜了下说问题的原因是ppt使用的字体样式在pdf中不存在,不能转换。
我的Ppt里面图片比较多的,我想问下这种情况应该怎么处理? 告诉我直接在word里面转成功的方法也行,还有如果在.NET里面应该怎么去解决这个问题?背景3(可选):我用C#代码检测了下 我的原ppt使用的字体都是pdf包括的系统字体。(也有可能我的检查代码写的不正确)
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);
}
}
}
}
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;
}
}
当转换有一些ppt时报如下异常“ 存储此文件时发生错误”。
背景2:该ppt我在用office2007打开的时候,选择另存为pdf的时候,在转换的过程中报错“ 存储此文件时发生错误”,网上我搜了下说问题的原因是ppt使用的字体样式在pdf中不存在,不能转换。
我的Ppt里面图片比较多的,我想问下这种情况应该怎么处理? 告诉我直接在word里面转成功的方法也行,还有如果在.NET里面应该怎么去解决这个问题?背景3(可选):我用C#代码检测了下 我的原ppt使用的字体都是pdf包括的系统字体。(也有可能我的检查代码写的不正确)
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);
}
}
}
}
解决方案 »
- 大家帮个忙分析下这段JQUERY代码的onclick为什么不起作用
- 送分了,求一个正则!标题要长········急···································
- 关于VS2005中AJAX中验证组件的使用问题。
- 39分,在线等
- pos票据打印机 打印问题???
- 请问能不能用VC++.Net写asp.net
- 在一段程序里打开两个DataReader就会报错,难道不允许打开两个DATAREADER ???
- 请问一个关于触发事件,引起页面刷新的问题!
- 怎样使弹出来的窗体固定在最前面??
- 图片不显示
- http://localhost:3927/mas/register.aspx?pid=6D-1F-CA-A6-AF-E7-7E
- 请问,如何学习ASP.NET
http://topic.csdn.net/u/20120717/07/55bb1837-07a7-465b-bc88-895a7c45882a.html
我这里是使用它转换成SWF文件 同理这个第三方也可以将文件转换成PDF.