Richtextbox in activereport 17

Posted by: devcode.ou on 17 April 2023, 4:41 am EST

  • Posted 17 April 2023, 4:41 am EST - Updated 17 April 2023, 4:46 am EST

    Hi, i have a strange problem with activereport17 richtextbox component,

    Im using sectionreport and xml source.

    Basically in design preview its working correctly, but a runtime the ritchtextbox is blank.

    I attach 2 pictures, 1 in design mode, 1 at runtime,

    for show better the situation i have on the left a richtextbox and on the right a textbox, both linked at the same field.

    As you can see at runtime i cannot see the rtf text in the richthexbox.

    (i had any problem with the old version 8)

    Any idea ?

  • Posted 18 April 2023, 4:06 pm EST

    Hi Beniamino,

    Please note, The RichTextBox control supports loading an RTF file at design time with both CrossPlatform and GDI compatibility modes of a report. However, the RichTextBox control does not support the RTF file at run-time when the report’s CompatibilityMode is set to CrossPlatform. If your use case is to modify the RichTextBox control at run time (i.e. through Report Script or Code) then I would suggest you to use HTML file instead.

    For more information on this, please refer to the following page of our documentation: RichTextBox

    If you are loading the RTF file at design time only and still facing this issue, then I would suggest you to share a sample application reproducing this behavior or edit the attached sample application such that it reproduces this behavior and send it back to us so we can test this issue at our end and get back to you accordingly.

    Regards,

    AkshayRichTextBoxSample.zip

  • Posted 18 April 2023, 5:58 pm EST - Updated 18 April 2023, 6:00 pm EST

    Hi,

    sorry i did not understand your example, it seems to me empty.

    However, the report is GDI, i have the rtf text in the xml file and connected through the DataField property (i worked in this way for 15 years with the old versions).

    • i have the rpx file on the software directory
    • i load the .rpx file

    var xtr=new System.Xml.XmlTextReader(path_report);
    rep.LoadLayout(xtr);

    • i change the path of the xml source file
    report.DataSource=new GrapeCity.ActiveReports.Data.XMLDataSource(NEWPATH, recordSetPattern);
    • i run the report
    rep.Run();

    In this scenario it should work? or i have to create a rtf file and load in the script section?

    Thank you

  • Posted 19 April 2023, 11:15 pm EST

    Hi Beniamino,

    We tried to replicate this issue by following the exact steps you mentioned: created an RPX report, loaded it in a SectionReport object, and assigned XML DataSource with RTF strings at runtime.

    However, we are able to preview the report as expected.

    Although, please note the RTF content does not get rendered and a blank space appears in our preview if any one of these conditions is true:

    • The report’s ‘CompatabilityMode’ property is set to ‘CrossPlatform’ and not ‘GDI’.
    • The used record set pattern is incorrect and hence no RTF value gets returned (and no error gets thrown).
    • The DataField has a value of a field name that does not exist.

    We have attached our sample for your reference.

    However, if the issue persists please try sharing a stripped-down sample of your report or modify our attached report such that it replicates the issue so we can replicate the issue on our end and further investigate the same.

    Regards,

    Anand

    RTFReport.zip

  • Posted 20 April 2023, 7:29 am EST

    Hi, i saw that your project is framework 4.8, but i have the problem with .NET

    I migrated your project in .NET6 and the richtextbox does not show anything

    so the problem is in the .net version

  • Posted 20 April 2023, 10:04 pm EST

    Hi Beniamino,

    In .Net 6, the report is forced to render in CrossPlatform mode which seems to be the reason why you are facing this issue. I would suggest you to use HTML strings to render rich text instead.

  • Posted 20 April 2023, 10:16 pm EST

    Hi, how do you suggest to do it, preserving the same rtf layout?

    Considering im printing a invoice text created with a specific layout and saved in a database.

    Can you give me a sample that convert the .rft text in html preserving exactly the same layout, and finally uning it in richtextbox loading from a xml file.

    Thank you

  • Posted 23 April 2023, 8:58 pm EST

    Hi Beniamino,

    Unfortunately, it is not possible to convert RTF to HTML through code using ActiveReports. Instead, you’ll need to modify your RTF to HTML manually in this case.

    However, you can use the Standalone designer with a RichTextBox in design time, in which you can right-click the RTB and use the LoadFile option to load your RTF file and it will convert the RTF content to HTML when loading it in the RichTextBox.

    You can now use this HTML and replace it with your RTF in your database.

    See attached video for reference.

    Regards,

    Anand

    Video: https://drive.google.com/file/d/1_b39Z6pRZkstt-O0GNlm_biqch2n_G4t/view?usp=share_link

  • Posted 23 April 2023, 9:07 pm EST

    hi,

    sorry but this is not a solution.

    I have my application with many rtf text saved in the database,

    because the rtf is the standard for text document (not html)

    I bought your new component and what before was working now it does not.

    Now i have to ask you, do you will fix this “huge mulfunction” and how long? otherwise after more than 15 years i will be forced to find different solution for reports.

    Sorry but this is a huge problem, i cannot understand why and also how you can ask to use html instead of rtf.

    thank you

  • Posted 24 April 2023, 10:05 pm EST

    Hi Beniamino,

    >> Now i have to ask you, do you will fix this “huge mulfunction” and how long? otherwise after more than 15 years i will be forced to find different solution for reports.

    Apologies for inconvenience, but as of know Rich Text(.RTF) is not supported at run time in CrossPlatform compatibility mode. I would suggest you to convert the RTF to HTML at runtime by creating a parser for the same so you can convert the returned RTF to HTML at run-time. For this please refer to the following pages of the StackOverFlow Forum: Convert Rtf to HTML

    I also found another NuGet Package that can be used to convert RTF to HTML. You can test this out here: Convert RTF to HTML in C#

    Once again please accept our sincere apologies for the same. I have issued an enhancement request for adding this feature in ActiveReports as soon as possible. [AR-30771]

    Regards,

    Akshay

  • Posted 24 April 2023, 10:16 pm EST - Updated 24 April 2023, 11:07 pm EST

    Hi, i will try this tools but i have my doubts that it can assure me 100% about the layout.

    However i understand when you say “Rich Text(.RTF) is not supported at run time in CrossPlatform compatibility mode”, but my project is compiled for windows only, so i think that you must manage this very common situation.

    Could you attach an example with richtextbox loading rtf > html text through xml file (NET6)

    thank you

    BS

  • Posted 25 April 2023, 9:01 pm EST

    Hi Beniamino,

    I have attached a sample application. I am using RtfPipe NuGet package to convert RTF text to HTML.

    To use the RtfPipe assembly in Xml-based Section Reports I am using the AddScriptReference method of the section report class. If I were to use Code-based section reports I could have directly referred to the namescape in the report script. Once I was able to refer to the RtfPipe assembly I simply converted the RichTextBox’s Rtf property to HTML and assigned the RtichTextBox’s Html property through script.

    Regards,

    Akshay DynamicRTFtoHTML.zip

  • Posted 26 April 2023, 5:56 am EST

    Hi,

    thank you for your example, could you give me the same in .NET version instead of framework .

    In my case the configuration is also more simple,

    I will use RtfPipe in my code, so in the xml field ther’s already the html code.

    Why i cannot see the Html and RTF properties in the report a design time ?

    Thank you

  • Posted 27 April 2023, 6:44 am EST - Updated 27 April 2023, 6:50 am EST

    Hello Beniamino,

    The code would be very similar in .Net 7 as this is a very simplified sample. I have attached a .Net Sample along with.

    >> Why i cannot see the Html and RTF properties in the report a design time ?

    The properties are not showing in the Properties Tab as it is ideal to use Load Files option if RTF/HTML file is used at Design-time, See attached screenshot. As loading the file will automatically save the file in the Report Resources in a ‘renderable format’ which is HTML. As the RTF to HTML conversion is not 100% WYSIWYG we do not provide a runtime conversion feature as of now though, this feature is currently under discussion.

    Regards,

    Akshay

    RTFToHTML.zip

  • Posted 27 April 2023, 7:10 pm EST

    Thank you,

    i will use your advice for find a momentary solution, its very important.

    In any case i repeat my doubts, the conversion in not 100% sure and

    • you should do the the same conversion as rtfpipe (maybe with an alert for the conversion not 100% sure)
    • at least when the project is compiled for windows only the richtextbox should continue to work as usual.

    Thank you for your patience, the support system is the top as always.

  • Posted 27 April 2023, 8:59 pm EST

    Hi Beniamino,

    I am glad to know I was able to resolve your query.

    The suggestions you have mentioned in the previous reply, I will share those with the development team although I have a couple points on why are we not doing this currently:

    • you should do the the same conversion as rtfpipe (maybe with an alert for the conversion not 100% sure)

    The Rtf Pipe is not a perfectly solution. We are currently leaning more towards developing our own RTF Renderer for Section Reports in CrossPlatform Rendering Mode. As I mentioned previously, the RTF to HTML render is not 100% WYSIWYG which why we don’t automatically convert RTF to HTML at runtime but since the RTF to HTML libraries are readily available we have that option for the users until we do create the RTF rendering available in CrossPlatform Rendering mode.

    • at least when the project is compiled for windows only the richtextbox should continue to work as usual.

    I am not really sure on this one, if this would have any implication, I will discuss on this with the development team and will get back to you once I have any information on the same.

    And thank you for your feedback, We are thrilled to hear that you were happy with the service you received from our team.

    Regards,

    Akshay

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels