2X faster development
The ultimate ASP.NET Web Forms UI toolkit to boost your development speed.
In the HTML to PDF conversion process, the HTMLConverter throws an exception with the message "ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment." The HTMLConverter internally makes use of the MSHTML.dll that can run only in the STA mode. Running the application in the MTA mode leads to this exception. This can be fixed by any of the following ways:
[C#] private void ConvertToPDF() { //Convert PDF here using IE based converter }
|
2X faster development
The ultimate ASP.NET Web Forms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.
In what context should that code be used? You can't put that code outside of a method like you appear to have done ..?
David - You can use the Thread code in your desired method, where you need the conversion part. I will refresh this article for better clarification.
>>>>>>>>>>>>>>>
public void HTMLConverter()
{
Thread t = new Thread(ConvertToPDF);
t.SetApartmentState(ApartmentState.STA);
t.Start();
t.Join();
}
private void ConvertToPDF() { //Convert PDF here }
>>>>>>>>>>>>>>>
However, if you are trying HTML to PDF converter for the first time, I suggest you to try using our WebKit based HTML to PDF converter.
https://www.syncfusion.com/products/file-formats/pdf/html-to-pdf