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

Rendering a url

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.

5 Replies

AJ Ajish Syncfusion Team June 5, 2006 11:31 AM UTC

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.


SK skumar June 5, 2006 07:41 PM UTC

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.


SK skumar June 5, 2006 07:53 PM UTC

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.


AJ Ajish Syncfusion Team June 6, 2006 07:17 AM UTC

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. > >>


AD Administrator Syncfusion Team June 6, 2006 08:39 PM UTC

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.

Loader.
Live Chat Icon For mobile
Up arrow icon