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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

HTMLConverter

Thread ID:

Created:

Updated:

Platform:

Replies:

44964 Jun 7,2006 09:36 PM UTC May 4,2010 12:06 PM UTC ASP.NET Web Forms (Classic) 16
loading
Tags: PDF
Administrator [Syncfusion]
Asked On June 7, 2006 09:36 PM UTC

I found this sample and was wondering why this can''t take an HTML string, why does it have to be a web page? // Create a new instance of HTMLConvertor. HtmlConverter html = new HtmlConverter(); // Convert html page to Image. Image bmp = html.ConvertToImage( txtUrl.Text, ImageType.Metafile);

Ajish [Syncfusion]
Replied On June 8, 2006 11:10 AM UTC

Hi, HTMLConvertor can only be used to convert WebPages and HTML pages to PDF it is done with the help of HtmlConverter.Base.dll. The HTMLConverter uses the MSHTML rendering library to render HTML documents.To import HTMLstrings into PDFDocument use Essentail HTMLUI which would convert HTML document/Strings to a image. This image can be easily imported to PDF document. Here is a sample fo your reference: HTMLToDoc.zip Please take a look at the sample and let me know if you any other questions. Thanks, Ajish.

Administrator [Syncfusion]
Replied On June 8, 2006 11:12 PM UTC

When I use your sample the first time it works great and is exactly what I am looking for. The second time I run it, I get the following error. Class already exists Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ComponentModel.Win32Exception: Class already exists Source Error: Line 75: { Line 76: this.htmluiControl1 = new Syncfusion.Windows.Forms.HTMLUI.HTMLUIControl(); Line 77: this.htmluiControl1.LoadFromString((string)Session["HTML"]); Line 78: Bitmap bmpImg = CreateBitmap(); Line 79: PDFDocument pdfDoc=new PDFDocument(); Source File: c:\inetpub\wwwroot\htmltodoc\htmltodoc.aspx.cs Line: 77 Stack Trace: [Win32Exception (0x80004005): Class already exists] System.Windows.Forms.WindowClass.RegisterClass() System.Windows.Forms.WindowClass..ctor(String className, Int32 classStyle) System.Windows.Forms.WindowClass.Create(String className, Int32 classStyle) System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) System.Windows.Forms.Control.CreateHandle() System.Windows.Forms.Control.get_Handle() System.Windows.Forms.Control.CreateHandle() System.Windows.Forms.Control.get_Handle() Syncfusion.Windows.Forms.HTMLUI.HTMLUIControl.EndUpdate() Syncfusion.Windows.Forms.HTMLUI.HTMLUIControl.OnLoadError(Object sender, LoadErrorEventArgs args) [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess) +0 System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess) +308 System.Delegate.DynamicInvokeImpl(Object[] args) System.MulticastDelegate.DynamicInvokeImpl(Object[] args) System.Delegate.DynamicInvoke(Object[] args) Syncfusion.Windows.Forms.HTMLUI.HTMLUIControl.InvokeDelegate(Delegate del, Object[] parameters) Syncfusion.Windows.Forms.HTMLUI.HTMLUIControl.LoadThread() Syncfusion.Windows.Forms.HTMLUI.HTMLUIControl.ParseDocument(InputHTML document) Syncfusion.Windows.Forms.HTMLUI.HTMLUIControl.LoadFromString(String html) EssentialDocIOSamples.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\htmltodoc\htmltodoc.aspx.cs:77 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1277 -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

Ajish [Syncfusion]
Replied On June 9, 2006 02:49 PM UTC

Hi, Sorry for the delay in getting back to you. We are looking into this issue I will send you an update regarding this as soon as possible. Thanks, Ajish.

Administrator [Syncfusion]
Replied On June 19, 2006 02:04 PM UTC

Is there any updates to report on this issue? I am still receiving an error. Thanks. >Hi, > >Sorry for the delay in getting back to you. We are looking into this issue I will send you an update regarding this as soon as possible. > >Thanks, >Ajish. > > > >

Ajish [Syncfusion]
Replied On June 22, 2006 08:42 AM UTC

Hi, Sorry for the delay in getting back to you. Can you please take a look at the modified sample and let me if the problem still exists. Sample:HTMLToDoc.zip Thanks, Ajish.

Gilberto Beltrao
Replied On August 9, 2006 06:13 PM UTC

Hi,

How can I have the reader to read an URL instead of a file as shown in you example? i.e.:

System.IO.StreamReader reader = new System.IO.StreamReader( Server.MapPath(@"http://www.mysite.com/default.aspx"));

I want to convert the rendered page into html. Is it possible and how?

TIA!

Gilberto Beltrao
Replied On August 9, 2006 06:16 PM UTC


I meant, convert the rendered page (html) into pdf.

Juba

>Hi,

How can I have the reader to read an URL instead of a file as shown in you example? i.e.:

System.IO.StreamReader reader = new System.IO.StreamReader( Server.MapPath(@"http://www.mysite.com/default.aspx"));

I want to convert the rendered page into html. Is it possible and how?

TIA!

Dhivya K [Syncfusion]
Replied On August 11, 2006 06:07 AM UTC

Hi Juba,

Thank you for your interest in Essential PDF. Yes, it is possible to convert the rendered Html page into PDF using HtmlConverter.

Here is a sample for your reference.
ConvertToPDF.zip

Please let me know if you have any other questions.

Thanks,
Dhivya.K

Administrator [Syncfusion]
Replied On November 14, 2006 03:55 PM UTC

Hi Dhivya,

I downloaded your example but keep on getting the following error when running it :

-----(translated from french)-----
Impossible to load the following file or assembly 'AxSHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89' or one of its dependencies. Specified file cannot be found.
------

I did check that the provided dll are in the bin directory (AxInterop.SHDocVw.dll, Interop.SHDocVw.dll, Microsoft.mshtml.dll).

I'm running Asp.net 2.0
Do you have any idea ?

Regards,
Arnaud

>Hi Juba,

Thank you for your interest in Essential PDF. Yes, it is possible to convert the rendered Html page into PDF using HtmlConverter.

Here is a sample for your reference.
ConvertToPDF.zip

Please let me know if you have any other questions.

Thanks,
Dhivya.K

Administrator [Syncfusion]
Replied On November 15, 2006 01:08 PM UTC

Hi Arno,

Thank you for your interest in Essential PDF. I was able to reproduce the issue you have mentioned.

The problem arrives because it is referring the old assemblies. Could you please delete those dlls from bin directory and then add the reference to these two dlls [AxSHDocVw.dll, SHDocVw.dll] which are found at following path , Otherwise you can use the following sample.

C:\Program Files\Syncfusion\Essential Studio\4.3.0.30\Windows\Pdf.Windows\Samples\Data\Interop Assemblies

Try running following sample after adding reference to those dlls and let me know if the problem still exist.

Here is the sample for your reference.
 ConvertToPDF_bfd9ccdf.zip 


Please take a look at this and let me know if you have any other question.

Regards,
Prakash.R


Bruno Gomes
Replied On November 30, 2006 12:39 PM UTC

Hi,

I am trying to use htmlconverter class but when my code gets to html = New HtmlConverter it gives the folowing error:

"Could not instantiate ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' because the current thread is not in a single-threaded apartment."

I'm developing in .net framework 1.1 and visual studio 2003. Can anyone helps me?

Administrator [Syncfusion]
Replied On November 30, 2006 10:51 PM UTC

Hi BGomes,

HtmlConverter will work in Asp .net too. The problem arrives because it might be referring old assemblies. Could you please do the following steps it will make your program working.

1] Delete these two dll ["AxInterop.dll and SHDocVw.dll" ] from the bin directory and then add from the following path.
C:\Program Files\Syncfusion\Essential Studio\4.3.0.30\Windows\Pdf.Windows\Samples\Data\Interop Assemblies

2] Add to the @Page directive AspCompat="true" attribute to the page where we want to perform html to pdf convertion.

Here is the sample for reference.
HTML_TO_PDF_CS_2005.zip


Regards,
Prakash.


Howard Shlom
Replied On April 27, 2010 08:54 PM UTC

I am trying to use HtmlConverter dll library. I have an error message:
"ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment."
on following line:

Dim html As HtmlConverter = New HtmlConverter()

I am using .net framework 3.5 and visual studio 2008, Syncfusion 8.2.0.18.

Does this mean that Syncfusion is still using Com ActiveX?
I can't find any Syncfusion Interop Assemblies folders anywhere.

Can anyone help please?

Angappan G [Syncfusion]
Replied On April 28, 2010 09:56 AM UTC

Hi Howard,

Thank you for your interest in Essential Studio.

Please make the following change in your web project.

Required Modification:

Include the attribute AspCompat='true' in the @Page directive.

Here is the code snippet

[Aspx]
<%@ Page Language='VB' AutoEventWireup='false' AspCompat='true' %>


Please try this and let us know if you have any queries.

Regards,
Angappan.

Howard Shlom
Replied On April 28, 2010 06:29 PM UTC

Angappan

Thank you for your reply.

We did try those attributes.

In the following code,
if we do Not have AspCompat="true", we get an error in the first line.
If we Do have AspCompat="true", the browser just hangs (nothing happens)!

Tahnks again.
Howard


Dim html As HtmlConverter = New HtmlConverter()
html.AutoDetectPageBreak = False
html.EnableJavaScript = False
html.EnableHyperlinks = False

Dim htmlText As String = String.Empty

htmlText = getHTML()

Dim page As New PdfPage
Dim doc As New PdfDocument
Dim pageWidth As Single = 532.29F
Dim pageHeight As Single = 712.3F

Dim format As PdfMetafileLayoutFormat = New PdfMetafileLayoutFormat()
format.Break = PdfLayoutBreakType.FitPage
format.Layout = PdfLayoutType.Paginate
format.SplitTextLines = False
format.SplitImages = False

Dim result As System.Drawing.Image = Nothing
Dim mf As PdfMetafile = Nothing

result = html.FromString(htmlText, ImageType.Metafile, CInt(Fix(680)), CInt(Fix(810)), AspectRatio.KeepWidth)

Angappan G [Syncfusion]
Replied On May 4, 2010 12:06 PM UTC

Hi Howard,

Thank you for your interest in Essential Studio.

We are unable to reproduce the issue on our side.Please refer the sample for more details.If you are able to reproduce the issue then report us with the sample and the html file in which you are facing the issue.This will help us a lot in investigating the issue.

Sample Link:
http://files.syncfusion.com/samples/PDF.Windows/HTMLtoPDF_67447.zip

Please try this and let us know if you have any queries.

Regards,
Angappan.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;