Hello
I’m using the aspose pdf library mostly to convert pdf to xps/png, or the opposite. It works very well, we (my company) have paid a licence (for 1 developer) back in 2016 and thus are limited to the version 17.4.0 that came out around a year after our purchase.
The problem we currently have is when we try to convert xps files that contain images with transparency.
When creating a new Aspose.Pdf.Document by providing it the path to an xps file:
LoadOptions options = new XpsLoadOptions();
using (var document = new Document(xpsFilePath, options)) // exception at this line
{
// do stuff
}
We are having this error (which I got in french but tried to translate in english) :
App_DispatcherUnhandledException System.MethodAccessException: Failed attempt of accessing the secured transparency method 'Aspose.Pal.PalBitmap.ParseRgb(System.Drawing.Imaging.BitmapData, Boolean)' to the secured critical method 'System.Runtime.InteropServices.Marshal.Copy(IntPtr, Byte[], Int32, Int32)'. The assembly 'Aspose.Foundation, Version=17.4.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56' is marked with AllowPartiallyTrustedCallersAttribute, and uses the transparency model of security level 2. If transparency of level 2 is used, all the methods of the AllowPartiallyTrustedCallers assemblies makes transparent secured by default, which may be the cause of this exception. at Aspose.Pal.PalBitmap.ParseRgb(BitmapData bitmapData, Boolean isAllowTransparencyToColorHack) at Aspose.Pal.PalBitmap.GetPixels(Boolean isConvertTo1Bpp, Boolean isAllowTransparencyToColorHack) at ♣ .☻(DrBrush ☻, Page ♥, DrMatrix ♣) at ♣ .☻(DrBrush ☻, Page ♥, DrMatrix ♣) at ♣ .☻(DrBrush ☻, Boolean ♥, Page ♣, DrMatrix) at .VisitPathStart(ApsPath ☻) at Aspose.Rendering.ApsPath.Accept(ApsDocumentVisitor visitor) at Aspose.Rendering.ApsCompositeNode.Accept(ApsDocumentVisitor visitor) at Aspose.Rendering.ApsCanvas.Accept(ApsDocumentVisitor visitor) at Aspose.Rendering.ApsCompositeNode.Accept(ApsDocumentVisitor visitor) at Aspose.Rendering.ApsCanvas.Accept(ApsDocumentVisitor visitor) at Aspose.Rendering.ApsCompositeNode.Accept(ApsDocumentVisitor visitor) at Aspose.Rendering.ApsCanvas.Accept(ApsDocumentVisitor visitor) at Aspose.Rendering.ApsCompositeNode.Accept(ApsDocumentVisitor visitor) at Aspose.Rendering.ApsPage.Accept(ApsDocumentVisitor visitor) at ♠ .☻(List`1 ☻, Document ♥, LoadOptions ♣, Boolean) at ☼?? .☻(Stream ☻, Document ♥, XpsLoadOptions ♣, Boolean) at Aspose.Pdf.Document.☻(Stream ☻, LoadOptions ♥) at Aspose.Pdf.Document..ctor(String filename, LoadOptions options)
Currently we are getting around this error by removing the transparency of the image prior to the xps conversion to a pdf file.
My question is, do you know if this issue can be prevented while keeping the transparency of the image ? Is this maybe a known issue that have been fixed in a future version of Aspose.Pdf ?
Thank you for your time,
Gilles