We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Problem when converting html to pdf in Sharepoint env.

Hello,

I got the problem when using HtmlConverter to convert html to pdf. It throws exception: "ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment ...".

I also did the same as following instruction http://www.syncfusion.com/support/forums/pdf-aspnet/90473/html-to-pdf-conversion- (another guy have the same problem as), but application page of sharepoint do not understand AspCompat="true" attribute.

Maybe HtmlConverter object from System.Windows.Form cannot be understood by Sharepoint?

Any suggestion?

Regards,
Dat

5 Replies

JQ Jean-Claude Quenaon November 24, 2009 03:18 PM UTC

You have to run the code to convert in a new process (STA mode).


TN Tuan Ngo November 25, 2009 07:22 AM UTC

The issue is solved.

Thank you,


DG Divya G Syncfusion Team November 26, 2009 04:34 AM UTC

Hi Dat,

Glad to know that your problem has been solved.

Please let me know if you have any other queries.

Regards,
Divya.G


BM Ben Martin December 21, 2020 12:01 PM UTC

  1. When using the Internet Explorer based HTML to PDF option (the default in pre 8.3 releases, from 8.3 onwards the Print CSS media type is enabled by default), the PDF Converter does not go through Internet Explorer's print processing engine, so any print specific CSS entries are not used. If you have control over the page that is being converted then you can add some logic inside the page that looks at a query string parameter ( e.g. ?pdfconversion=true). Based on this parameter being present you can then emit different CSS / HTML that improves the formatting, e.g. a different page width. In SharePoint this can be achieved by modifying the master page or inserting a hidden 'content editor web part'.
     

  2. PDF Conversion starts the moment a page 'finishes loading'. This generally works well, but some modern web pages rely on JavaScript to render part (or all) of the page. There is no way for our software to detect when the JavaScript has finished executing, as a result the converted PDF may only show partial information. As a workaround consider specifying a 'ConversionDelay' in our configuration file. Start with a high value (e.g. 30000 = 30 seconds) and if that works lower it to a more reasonable figure, often it just requires a value of 1000 (1 second)

  I hope this helps!
Ben Martin


GK Gowthamraj Kumar Syncfusion Team December 22, 2020 03:50 PM UTC

Hi Ben, 
 
Thank you for contacting Syncfusion support. 
 
IE rendering engine internally make use of Microsoft’s MSHTML for converting the HTML files to vector images, from that images we will render the content to PDF document. We do not have support for media type in IE rendering engine. We have suggested you to try our latest Blink/WebKit rendering engines for converting HTML to PDF. Please refer below links for more information, 
 
In WebKit/Blink, we have support for windows status to loading the resources. The windows status can be used instead of addition delay. In additional delay, the amount of time required for loading the resources is unpredictable. This behavior can be avoiding by using windows status. Please find the below link for more information, 
 
Please let us know if you need any further assistance with this. 
 
Regards, 
Gowthamraj K 


Loader.
Live Chat Icon For mobile
Up arrow icon