Render images in HtmlTextBox

9 posts, 0 answers
  1. Stefan
    Stefan avatar
    1 posts
    Member since:
    Jun 2013

    Posted 08 Jul 2013 Link to this post

    Hi!

    I'm a developer using C# and ASP.net. Let me first of all say that I know that HtmlTextBox does not currently support the <img> tag. 
    However, as I (and many others) have discovered, images are more or less essential when you want to generate good looking reports.

    What I want to do is use RadEditor to create html pages in the admin part of the application, complete with formatting and images. This is fairly straghtforward and already done. In the viewing part of the application, a user can browse different pages and print/export to pdf.
    At this stage I need to use Telerik Reporting to combine the html content with data and render the page/s as pdf exactly as it appears in the browser, plus some header and footer stuff.

    My question is twofold:
    1. Is there ANY way to accomplish this?
    2. Do you really consider images to fall outside the scope of report generation when it comes to html content? If not, can you PLEASE implement image (and possibly table) handling in pdf?

    Kind regards,
    Stefan
  2. Peter
    Admin
    Peter avatar
    1611 posts

    Posted 11 Jul 2013 Link to this post

    Hello Stefan,

    We do understand that tables and images are essential part of the reports. Thus we do provide the PictureBox and Table item. However there are some limitations when working with HTML, which I will explain here.

    Telerik Reporting (TR) is a server solution, which is intended to process and render data, rather than text (be it plain text or richly-formatted text). TR supports several export formats (one of which HTML), but they are all geared towards exporting tabular data  and charts, rather than richly-formatted text.

    This works in the following way: the reporting engine serves the report content in a predefined format to show it under the specific platform; for example, if you are using TR in a ASP.NET application, it uses a stream to serve HTML to the browser. It is important to note here that the report rendering happens before the content is served to the browser, i.e. the browser has nothing to do with the report rendering. The browser just shows the HTML, which has already been prepared by the report rendering.
     
    If TR is to serve all HTML tags and CSS attributes (be them produced by Microsoft Word, RadEditor for ASP.NET, or RadRichTextBox for Silverlight), we will need to develop a HTML engine which to render this HTML before it hits the client. In other words, we will need to develop a fully functional browser which to process this HTML and CSS and either send it to the client report viewer, or export it to one of the supported formats. Developing a fully functional browser is neither easy nor viable (IE's HTML engine is roughly 10MB, whereas FF's is about 8MB; this is a lot of code). Even Microsoft does not do this in their SQL Reporting Services product.

    This is the reason why TR renders a small subset of HTML tags and CSS attributes, all of which have been written by our developers to support the most common text formatting options

    We have attached a sample project that illustrates the only possible approach we know of (workaround did not seem like the correct word here): utilizing the WebBrowser control to render HTML to a bitmap. We use an user defined function that does the trick, and a picture box item which displays the generated image (PNG). We're aware that this approach has several shortcomings and is far from perfect, but it seems to work in most cases and in all export formats (which support PictureBox items). One thing to note is that you should set the HTML as value for the browser.DocumentText property, in the example we've used URL from the RadEditor examples to quickly illustrate the approach.

    Thank you for the understanding.

    Regards,
    Peter
    Telerik

    Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

  3. DevCraft banner
  4. Xavier
    Xavier avatar
    1 posts
    Member since:
    Jan 2014

    Posted 16 Jul 2014 in reply to Peter Link to this post

    Hello folks,

    It's been a couple of years since this reply was posted; is there any chance that you guys might implement this in the near future?


    Sincerely,

    Xavier.
  5. Nasko
    Admin
    Nasko avatar
    909 posts

    Posted 21 Jul 2014 Link to this post

    Hello Xavier,

    Currently, we do not have any plans to support images in the HtmlTextBox item due to the limitations which my colleague described earlier in this thread.
    However, you can still use images throughout your reports via the PictureBox report item or the workaround suggested in this thread.

    Regards,
    Nasko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Shane
    Shane avatar
    3 posts
    Member since:
    Jan 2011

    Posted 21 Jul 2014 in reply to Nasko Link to this post

    This functionality has been requested numerous times and continues to be a popular request among users of TR.

    In fact, there is a current feature request for this functionality in 'Under Review' status:

    Support table and image tags in the htmltextbox
    http://feedback.telerik.com/Project/162/Feedback/Details/126133-support-table-and-image-tags-in-the-htmltextbox


    Our company would love to continue to use the full Telerik suite for all development and reporting needs, but we may have to look elsewhere to address this important need. Competing products, such as ActiveReports, purport to support the table and img tags in their RichTextBox controls. Does Telerik have any plans to ever support this functionality?
  7. Nasko
    Admin
    Nasko avatar
    909 posts

    Posted 24 Jul 2014 Link to this post

    Hello Shane,

    In order to support images, tables and other HTML tags, we will need to develop our own HTML layout engine similar to the ones used in the real web browsers. This may prove to be quite resource intensive and long term task. Having in mind that currently there is a solution for this issue (the WebBrowser control can be used to render HTML to a bitmap and display it in the report), we have to put our efforts and resources in other features which are critical or more related to data analysis.

    Let us know if for some reason the WebBrowser to bitmap approach does not work in your scenario, so we can advise accordingly.

    Regards,
    Nasko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  8. raju
    raju avatar
    2 posts
    Member since:
    Nov 2014

    Posted 08 May 2015 in reply to Peter Link to this post

    Do you have a recent example of this attached project? I couldn't get this working with Q12015 and VS 2013. 
  9. Nasko
    Admin
    Nasko avatar
    909 posts

    Posted 11 May 2015 Link to this post

    Hello raju,

    Please find attached the updated HtmlToBitmap sample project using the Q1 2015 SP1 version of Telerik Reporting.

    Regards,
    Nasko
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  10. raju
    raju avatar
    2 posts
    Member since:
    Nov 2014

    Posted 11 May 2015 in reply to Nasko Link to this post

    Thanks Nasko
Back to Top
DevCraft banner