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.
Unfortunately, activation email could not send to your email. Please try again.

Rendering a url

Thread ID:

Created:

Updated:

Platform:

Replies:

44825 Jun 5,2006 03:26 AM Jun 6,2006 04:39 PM Windows Forms 5
loading
Tags: PDF
skumar
Asked On June 5, 2006 03:26 AM

I seem to remember seeing the the ability to render html pages (given a url) into pdf documents is now supported. However, I can''t seem to find where/how? Can someone help me please? Thanks. Shiv.

Ajish [Syncfusion]
Replied On June 5, 2006 07:31 AM

Hi Shiv, In Essential PDF WebPages and HTML pages can be imported to PDF with the help of HtmlConverter.Base.dll. The HTMLConverter uses the MSHTML rendering library to render HTML documents. The MSHTML library is the that is engine used to drive the Internet Explorer. Here is code for converting URL to PDF // Covert HTML/URL’s to PDF. HtmlConverter htmlDoc= new HtmlConverter(); Image docImg = htmlDoc.ConvertToImage( URL, ImageType.Metafile); doc.LastPage.Graphics.DrawImage( PointF.Empty, docImg, dest, properties ); This conversion takes place in the following steps, 1) Convert the URL/HTML document to an image 2) Insert the image into the pdf document. The Image can be Metafile or Bitmap. Converting to Metafile leaves the contents in the document searchable. Here is a sample for your reference: HTMLToPDF.zip Please take a look at this sample and let me know if have any other questions. Thanks, Ajish. >I seem to remember seeing the the ability to render html pages (given a url) into pdf documents is now supported. However, I can''t seem to find where/how? > >Can someone help me please? > >Thanks. >Shiv.

skumar
Replied On June 5, 2006 03:41 PM

Ajish, Does this work from an ASP.NET application? I get an error saying the activex control needs to be in a single threaded appartment. > >Hi Shiv, > >In Essential PDF WebPages and HTML pages can be imported to PDF with the help of HtmlConverter.Base.dll. The HTMLConverter uses the MSHTML rendering library to render HTML documents. The MSHTML library is the that is engine used to drive the Internet Explorer. > >Here is code for converting URL to PDF > > >// Covert HTML/URL’s to PDF. > >HtmlConverter htmlDoc= new HtmlConverter(); >Image docImg = htmlDoc.ConvertToImage( URL, ImageType.Metafile); >doc.LastPage.Graphics.DrawImage( PointF.Empty, docImg, dest, properties ); > > > >This conversion takes place in the following steps, > >1) Convert the URL/HTML document to an image >2) Insert the image into the pdf document. > >The Image can be Metafile or Bitmap. Converting to Metafile leaves the contents in the document searchable. > >Here is a sample for your reference: HTMLToPDF.zip > >Please take a look at this sample and let me know if have any other questions. > >Thanks, >Ajish. > > >>I seem to remember seeing the the ability to render html pages (given a url) into pdf documents is now supported. However, I can''t seem to find where/how? >> >>Can someone help me please? >> >>Thanks. >>Shiv.

skumar
Replied On June 5, 2006 03:53 PM

Ajish, I get the following error using the code you sent me. I''ve using VS.NET 2005 The following error occurred while determining how to marshal the parameters of member ''GetDropTarget'' of type ''Syncfusion.HtmlConverter.IDocHostUIHandler'': System.Runtime.InteropServices.MarshalDirectiveException: Cannot marshal ''return value'': Invalid managed/unmanaged type combination (Int/UInt must be paired with SysInt or SysUInt). This is most likely due to an incompatible MarshalAs attribute on one of the parameters.

Ajish [Syncfusion]
Replied On June 6, 2006 03:17 AM

Hi shiv, Yes, It does work under asp.net environment.Add to the @Page directive AspCompat="true" attribute to the page where we want to perform html to pdf convertion this would resolve the problem that you face. Here is a Asp.net sample which would convert a URLToPDF:< a rel='nofollow' href="http://www.syncfusion.com/Support/user/uploads/WebPageToPDF_74496497.zip">WebPageToPDF.zip Please take a look at the sample and let me know if you have any other questions. Thanks, Ajish. >Ajish, > >Does this work from an ASP.NET application? > >I get an error saying the activex control needs to be in a single threaded appartment. > >>

Administrator [Syncfusion]
Replied On June 6, 2006 04:39 PM

Ajish, I''ll try the ASP.Net sample. However, maybe I was not clear. I get the error (MarshalAs error) in the WinForms sample you sent me. Thanks for the ASP.NET sample.

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.

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.

;