使用Syncfusion将.ppt文件转换为PDF时出错

时间:2015-06-18 15:40:49

标签: c# syncfusion

下面的代码可以毫无问题地将pptx文件转换为pdf。

try
{
    //Opens the specified presentation
    IPresentation presentation = Presentation.Open(@"D:\YUs\Test\pp2.pptx");
    presentation.ChartToImageConverter = new ChartToImageConverter();
    presentation.ChartToImageConverter.ScalingMode = Syncfusion.OfficeChart.ScalingMode.Best;
    PresentationToPdfConverterSettings settings = new PresentationToPdfConverterSettings();

    settings.ShowHiddenSlides = true;

    PdfDocument doc = PresentationToPdfConverter.Convert(presentation, settings);

    doc.Save(@"D:\YUs\Test\pp2.pdf");
    doc.Close();
}
catch (Exception err)
{
    Response.Write("error when saving presentation file: " + err.ToString() + "<br/><br/><br/>");
}

但是当我尝试使用代码转换.ppt文件时,它会返回以下错误:

Syncfusion.Compression.Zip.ZipException: Zip exception.Can't locate end of central directory record. Possible wrong file format or archive is corrupt. at Syncfusion.Compression.Zip.ZipArchive.Open(Stream stream, Boolean closeStream) at Syncfusion.Presentation.FileDataHolder.Open(Stream stream) at Syncfusion.Presentation.Presentation.SetArchieveItems(Stream stream) at Syncfusion.Presentation.Presentation.ParseDocument(Stream fileStream) at Syncfusion.Presentation.Presentation.OpenAsStream(Stream stream) at Syncfusion.Presentation.Presentation.Open(String fileName) at PUBLIC_ConvertOfficeToPdfNetOffice.Page_Load(Object sender, EventArgs e) in d:\ConvertOfficeToPdfNetOffice.aspx.cs:line 30

我尝试过许多不同的PPT文件,但它总会返回相同的错误。

1 个答案:

答案 0 :(得分:1)

Syncfusion Essential Presentation库仅支持操作PPTX文件,以及在尝试加载PPT文件时出现此错误的原因。我们应该使错误信息更清楚,我们将进行此更改。

我们将来还会记录支持PPT文件的功能请求。