Use HTML Tags in field text

Hi everyone. I was just wondering if there is a way to use html tags in text to change its formatting when sent to the report.

I am printing a rather complex report and want to allow the user to bold text for instance. I was trying to do something like this:

text text text bold text bold text italic textmore bold textmore text.

Is there a way to do this?

The text I'm sending to the report could have very different formatting, so I was hoping to handle this on the fly based on the text value provided...

Thanks for your help.

Comments

  • edited 4:51PM
    use richtext object and try this library: https://www.sautinsoft.com/products/html-to...tnet-csharp.php
  • edited 4:51PM
    ipong wrote: »

    Thank you! I will take a look at that over the weekend. I really appreciate your help!
  • edited 4:51PM
    textobject has a property called 'htmltags', set it to true.

    or

    if you're not satisfied, use demo version of sautinsoft.htmltortf
    SautinSoft.HtmlToRtf htmlToRtf = new SautinSoft.HtmlToRtf();
    string trial = htmlToRtf.ConvertString("This is a [b]bold text[/b]");
    int i = trial.IndexOf("\\par\n_");
    string result = trial.Substring(0, i);
    
    // in fastreport richtextobject
    Rich1.Text = result;
    
  • edited 4:51PM
    ipong wrote: »
    textobject has a property called 'htmltags', set it to true.

    or

    if you're not satisfied, use demo version of sautinsoft.htmltortf
    SautinSoft.HtmlToRtf htmlToRtf = new SautinSoft.HtmlToRtf();
    string trial = htmlToRtf.ConvertString("This is a [b]bold text[/b]");
    int i = trial.IndexOf("\\par\n_");
    string result = trial.Substring(0, i);
    
    // in fastreport richtextobject
    Rich1.Text = result;
    

    Thank you for your help. I decided to try using the RichTextBox Control in Fast Reports and sending the rtf text to Fast Reports with my other data. Instead of showing the formatted text in the RichTextBox Control, it shows the actual ascii information in text form...

    The text in my RichTextBox Control looks like this: {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}
    \viewkind4\uc1\pard\f0\fs16 This is \b\fs16 bold\b0\fs16 text and this is\i\fs16 italic \i0\fs16 text\par
    }


    I don't see a property to turn RTF on or off...

    And the RichTextBox that I'm typing my sample text in is formatting properly and loading previously formatted text properly.

    I tried typing my text into the RichTextBox Control in Fast Reports and formatting it manually and this did work, though I can't seem to find a way to see the actual ascii (I was hoping to use this to trouble shoot).

    Thank you again for your help.
  • edited 4:51PM
    Never mind, I figured it out.

    While you use the Text property for the Text Boxes, you use the Data Column property for the RichTextBox objects!

    What a stupid mistake!

    Thank you so much for your help!
  • PolomintPolomint Australia
    edited 4:51PM
    m_lyons wrote: »
    What a stupid mistake!
    Making a mistake once and learning from it, is never stupid.

    And sharing your discovery with others, so they may avoid the trap you were caught by, is an act that should be rewarded! >

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.