简体   繁体   English

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

[英]How do I convert a PowerPoint file to PDF using Aspose 6.4?

I am using aspose.slides.dll v6.4.0 to convert .pptx files to .pdf . 我正在使用aspose.slides.dll v6.4.0将.pptx文件转换为.pdf

My Code: 我的代码:

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;
}

But when the method is called, the following exception is shown and file is not converted: 但是,当调用该方法时,将显示以下异常,并且不会转换文件:

Attempt by security transparent method 'ns3.Class115.smethod_6(System.Drawing.Imaging.BitmapData, Boolean)' to access security critical method 'System.Runtime.InteropServices.Marshal.Copy(IntPtr, Byte[], Int32, Int32)' failed. 尝试通过安全透明方法'ns3.Class115.smethod_6(System.Drawing.Imaging.BitmapData,Boolean)'访问安全关键方法'System.Runtime.InteropServices.Marshal.Copy(IntPtr,Byte [],Int32,Int32)失败了

Assembly 'Aspose.Slides, Version=6.4.0.0, Culture=neutral, PublicKeyToken=null' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. 程序集“ Aspose.Slides,版本= 6.4.0.0,文化=中性,PublicKeyToken =空”标记有AllowPartiallyTrustedCallersAttribute,并使用2级安全透明性模型。 Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception. 级别2透明导致默认情况下AllowPartiallyTrustedCallers程序集中的所有方法变为安全透明,这可能是导致此异常的原因。

I tried to search for details about this exception, but could find nothing relevant to it. 我试图搜索有关此异常的详细信息,但找不到与之相关的任何内容。 How can I resolve this issue? 我该如何解决这个问题?

Your code snippet seems fine and also you are using Aspose.Slides for .NET 6.4.0. 您的代码段似乎还不错,并且您正在使用Aspose.Slides for .NET 6.4.0。 I would suggest you to please try using Aspose.Slides for .NET 6.6.0 which is at the moment the latest available version. 我建议您尝试使用适用于.NET 6.6.0的Aspose.Slides,它是目前最新的可用版本。 I am hopeful that the new version will work. 我希望新版本能正常工作。 Even if there is an issue then please share the sample presentation with us on Aspose.Slides forum. 即使有问题,也请在Aspose.Slides论坛上与我们分享示例演示。 We will be obliged to help you. 我们将有义务为您提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM