This is a migrated thread and some comments may be shown as answers.

Formatting Issue in Telerik Reporting

12 Answers 475 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rodger
Top achievements
Rank 1
Rodger asked on 06 Mar 2008, 07:13 PM
Hi,

I am sure I am missing something simple!!.

In my we application I am using RadEditor to great effect, everything works fine. The text generated is saved in an SQL database (varchar) type field. When the data is reloaded bach into RadEditor everything is exactly as you would expect, it works perfectly.
My problem comes when I want to use Telerik Reporting to report on my data. The report loads the text literally including all the tags for formatting etc. It does not come back in the formatted fashion as it does in the editor.
Please advise where I am going wrong.

Thanks in advance.


Andy.

12 Answers, 1 is accepted

Sort by
0
Hrisi
Telerik team
answered on 07 Mar 2008, 02:28 PM
Hi Andy,

We do understand your needs and we agree that it is important to render HTML content inside PDF, Excel document, or on the printer. The reason for lacking this functionality is that implementing a HTML rendering engine is not a trivial task. There are only a few applications that can do this properly - the browsers we use daily. Anyway, we are researching the best possible way to implement HTML rendering and I can assure you that this functionality will appear at one point or another, being a very common request (see the forum thread).

Attached you may find a sample project that illustrates a possible workaround: utilizing the WebBrowser control to render HTML to a bitmap. In it, we used an user defined function that does the trick, and a picture box item which displays the generated image (PNG). I know 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).

I sincerely hope that the attached workaround will help you achieve your goal.

Sincerely yours,
Hrisi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Rodger
Top achievements
Rank 1
answered on 10 Mar 2008, 12:15 PM
Thanks for your reply. I will give this a try.

Do you have a VB version of the example project please?

Regards,

Andy.
0
Rodger
Top achievements
Rank 1
answered on 10 Mar 2008, 02:57 PM
Hi,

The other question is, where is the HTML2BitMap() function??

Regards,


Andy.
0
Accepted
Hrisi
Telerik team
answered on 11 Mar 2008, 02:37 PM
Hi Andy,

Attached you can find a WinForms VB solution which is the same as C# version. The HTML2BitMap function is the shared member of the Report1 class. More for the UserFunctions you can find in the Reporting documentation.

Best wishes,
Hrisi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Rodger
Top achievements
Rank 1
answered on 12 Mar 2008, 07:55 PM
This solution has worked well. There does seem to be a slight degradation in print quality in the picture box part of my reports, but it is acceptable. I look forward to a release that will take care of HTML without the work around.

Once again excellent support, thanks.

Regards,

Andy.
0
JustinWong
Top achievements
Rank 1
answered on 18 Apr 2008, 12:29 AM
Hi Hrisi and Andy:

Would you be kind enough to show me how to use this user function in a web application where the report is dynamically generate?  I'm not very experienced with user function as is, and I'm new to Telerik report.  In the example project Hrisi attached, the report (Report1.vb) already existing and the user function is already coded into the file.

What if I want to start from scratch? In other words, create a report from code, add a picture box to it, and then use the HTML2BitMap user function to convert some html code string into a bit map file?

I'm lost as to how to achieve this.  If I could see a vb example, I'd be forever grateful.

Thanks so much!

Justin
0
Svetoslav
Telerik team
answered on 18 Apr 2008, 07:24 AM
Hello Justin,

Everything you need is in the attached report. Please note that the Report Designer (like the Windows Forms Form designer for example) saves you from explicitly writing any initialization code and do this for you. The code that resides in the InitializeComponent() method is generated by the designer and this is exactly where you will find all the code that creates and initializes the report.
There are two possible ways to set the data that one report item displays - through the binding expressions as in the attached report and through the binding events.
When using expression, you may create your own user functions to extend the built-in expressions, while when using the binding events you have all the power of the programming language you use.

For more information on the expressions please take a look at this article: Using Expressions.
For more information on the events please see Understanding Events and Using Report Item Events.

Regards,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
JK
Top achievements
Rank 1
answered on 29 May 2008, 10:26 AM
Hi,

Love the solution, I have two questions:
  1. I have 2 html fields that I need to print out, the first works fine, but the second comes up with the following error within the print output: "#ERROR# The expression contains undefined function call HTML2BitMap()".

     
    I created another procedure called "HTML2BitMap1" just incase it was something to do with sharing the command between 2 html fields, this didnt work.  Any Ideas? 

    SOLVED: My bad, it was because the feild was NULL :o(

  2. I have a workaround but the sizing of the width and height is in CM but the print out needs it pixels.  So the line in the code which says "data["w"] = (int)me.Width.Value;" brings back the CM version of the size NOT the pixel size, therefore you end up with the text much shorter (i.e. it word wraps instead of utilising all the space of the picturebox).
     
    Any thoughts, as my solution was to to hard code the pixels into it "data["w"] = (int)660;"?

I would really appreciate your thoughts on point one as this has put me in a bit of a stall.  Thanks in advance,

JK

0
Steve
Telerik team
answered on 30 May 2008, 09:53 AM
Hi JK,

We are glad that you were able to solve the first problem you've encountered.
As for the second issue, take a look at the Telerik.Reporting.Drawing.Unit members described here and more specifically FromPixels method.

Let us know if further help is needed.

Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
JK
Top achievements
Rank 1
answered on 05 Jun 2008, 12:00 PM
Hi Steve,
one final point, the image which is rendered is in the default font of times new roman.  Can this be adjusted?  I tried this but didnt work...

= HTML2BitMap("<SPAN FONT-SIZE: 8pt; font-family: 'Trebuchet MS'>" + Fields.Description + "</SPAN>",ReportItem)

Any suggestions?

Thanks,

JK
0
Hrisi
Telerik team
answered on 06 Jun 2008, 11:27 AM
Hello JK,

Are you missing the style attribute of the SPAN tag?

You can try this:
= HTML2BitMap("<SPAN style=\"FONT-SIZE: 8pt; font-family: 'Trebuchet MS'\">" + Fields.Description + "</SPAN>",ReportItem)

Let us know if you experience any other problems.

Regards,
Hrisi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
JK
Top achievements
Rank 1
answered on 06 Jun 2008, 12:24 PM
Hi Hrisi,

It didnt work it comes up saying "#ERROR# Missing opertator before FONT operand."

The problem definatley is to do with using a font which required quotes to define it.  Any other ideas?

Thanks
Tags
General Discussions
Asked by
Rodger
Top achievements
Rank 1
Answers by
Hrisi
Telerik team
Rodger
Top achievements
Rank 1
JustinWong
Top achievements
Rank 1
Svetoslav
Telerik team
JK
Top achievements
Rank 1
Steve
Telerik team
Share this question
or