如何使用Aspose 6.4将PowerPoint文件转换为PDF?

时间:2012-10-03 08:19:32

标签: c# asp.net aspose

我正在使用aspose.slides.dll v6.4.0将.pptx文件转换为.pdf

我的代码:

public static MemoryStream pptx2Pdf(byte[] FileRead)
{
    MemoryStream ResultStream = new MemoryStream();
    Aspose.Slides.Pptx.PresentationEx pres = new Aspose.Slides.Pptx.PresentationEx(new MemoryStream(FileRead));
    pres.Save(ResultStream, Aspose.Slides.Export.SaveFormat.Pdf);
    return ResultStream;
}

但是当调用该方法时,会显示以下异常并且不转换文件:

  

尝试使用安全透明方法'ns3.Class115.smethod_6(System.Drawing.Imaging.BitmapData,Boolean)'来访问安全关键方法'System.Runtime.InteropServices.Marshal.Copy(IntPtr,Byte [],Int32, Int32)'失败了。

     

程序集'Aspose.Slides,Version = 6.4.0.0,Culture = neutral,PublicKeyToken = null'标有AllowPartiallyTrustedCallersAttribute,并使用2级安全透明模型。 2级透明度导致AllowPartiallyTrustedCallers程序集中的所有方法默认情况下变为透明,这可能是导致此异常的原因。

我试图搜索有关此异常的详细信息,但可能找不到任何与之相关的内容。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

您的代码段似乎很好,而且您正在使用Aspose.Slides for .NET 6.4.0。我建议你尝试使用Aspose.Slides for .NET 6.6.0,这是目前最新版本。我希望新版本能够运作。即使有问题,请在Aspose.Slides论坛上与我们分享示例演示文稿。我们将不得不帮助您。