Convert html to PDF exception message

Hi,

I'm having an issue when trying to convert an html file located in an local folder (the page's files is in same folder) to PDF. Here's the code I'm using:


var basePath = Path.GetDirectoryName(sourceFilePath);
if ((basePath != null) && (basePath.EndsWith("\\") == false)) basePath += "\\";
var htmlOptions = new Aspose.Pdf.HtmlLoadOptions(basePath);
var document = new Aspose.Pdf.Document(sourceFilePath, htmlOptions);
document.Save(destinationFilePath);

Where sourceFilePath is the full path to the html file and destinationFilePath is the full path of the PDF file to be saved.

When creating the document I get the following exception message:
Attempt by security transparent method 'Aspose.Pal.PalBitmap.ParseRgb(System.Drawing.Imaging.BitmapData, Boolean)' to access security critical method 'System.Runtime.InteropServices.Marshal.Copy(IntPtr, Byte[], Int32, Int32)' failed.

Assembly 'Aspose.Foundation, Version=17.4.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model. Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.


The web page I used was saved from:
https://en.wikipedia.org/wiki/Grand_Canyon


Please help.

Regards,

Hugo.

Hi Hugo,


Thank you for contacting support. Kindly send us the complete details of your test case, including input HTML document and the version number of Aspose.Pdf for .NET API. We are unable to find any problem when using one of our sample HTML files. Please also let us know which Aspose.Pdf for .NET API you are using because these details will help us to replicate this error in our working environment. Your response is awaited.

Hi,


I’m trying to convert an html/htm file located in a local folder to pdf.

The version I’m using is 17.4.0.0

Thanks.

Hi Hugo,


Thank you for sending an HTML file. We managed to replicate the said error and have logged under the ticket ID PDFNET-42742 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates. We are sorry for the inconvenience caused.