We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HTML to PDF Issue

Hello,

I am currently evaluating the aspose complete suite in order to determine if its worth purchasing and i am not able to get even the example to work for the conversion between html to pdf. I used the following code in the example (https://docs.aspose.com/display/pdfnet/Convert+HTML+to+PDF+Format):

// HTML string
String html = “this is a link to a web site like http://www.aspose.com/">this.";
// instantiate HtmlLoadOptions object and set desrired properties.
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
htmlLoadOptions.PageInfo.Margin.Bottom = 10;
htmlLoadOptions.PageInfo.Margin.Top = 20;
//Load HTML string
Document doc = new Document(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(html)), htmlLoadOptions);
//Save PDF file
doc.Save(“output.pdf”);

And this is the error that i am getting:

System.IO.FileLoadException: 'Could not load file or assembly ‘zx_b2ba20ee57f341fdaebf981fa29e650c, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))'

ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

I’ve searched the forum and wasn’t able to find any similar posts. I am currently using the latest version in nuget which is Aspose.Pdf 17.5.0.0 and currently developing in .net 4.6.1. Help would be greatly appreciated.

Hi,


Thank you for contacting support. We have tested your code with the latest version 17.5.0.0 of Aspose.Pdf for .NET API and the .NET Framework 4.6.1. It works fine in our environment and does not show the above mentioned error. We have attached an output PDF to this reply. Kindly provide more details of your environment, e.g. Operating System (version and edition), .NET application type, local language settings and some other handy information which could help us to replicate this error in our environment. Your response is awaited.

I figured out the issue. If you have a .net framework 4.6.1 class library and a unit test project where the class library is in reference and you execute the following code in the class library from your unit test project, you will get the error above. However if you execute the class library from a console app… you won’t get any issues.

Here is the exemple that should give you the error:

---------------------------------------------------

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ClassLibrary2;

namespace UnitTestProject1
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var test = new Class1();
test.Execute();
}
}
}

-----------------------------------------------

using Aspose.Pdf;
using System;
using System.IO;

namespace ClassLibrary2
{
public class Class1
{

public void Execute()
{
// HTML string
String html = “this is a link to a web site like <a href=“http://www.aspose.com/”>this.”;
// instantiate HtmlLoadOptions object and set desrired properties.
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
htmlLoadOptions.PageInfo.Margin.Bottom = 10;
htmlLoadOptions.PageInfo.Margin.Top = 20;
//Load HTML string
Document doc = new Document(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(html)), htmlLoadOptions);
//Save PDF file
doc.Save(“output.pdf”);
}
}
}


Hi,


Thank you for the details. We have executed a class library project code from the unit test project, but it still does not reproduce the error in our environment. Please prepare a small project and make sure that it reproduces this error in your environment, and then share a project Zip with us. We will investigate and share our findings with you.