سؤال

I'm currently building an application that generates a separate letter for each user in the dataset. The letter contents are managed through a vb.net application and their RTF format saved to a database. When the letter is created, all the content is pulled from the database to form the letter using vb.net logic.

Once compiled it was sent as a parameter to Crystal. This worked great, setting the field text interpretation to RTF allowed proper RTF viewing. The client has decided that they would instead like to make changes to the logic (if statements that compile the text) within Crystal.

So what I did was create a blank dataset with a bunch of columns and filled those columns with the RTF (Ordered by ID so the values will never change unless a paragraph is deleted and there is no option for this). This would allow me to build an RTF string by going {table.1} + {table.2} etc...

This is where the problem is. When building an RTF string in a Formula (Using + or &) it only displays the first RTF entry. If I switch the formula to no interpretation, I can see the RTF for the entries written out with all their content so I know it’s there. I also manually combined the RTF in the formula field and had the same issue.


StringVar output;

output := output & "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}\viewkind4\uc1\pard\lang1033\f0\fs23 this is a first test }"; output := output & "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}\viewkind4\uc1\pard\lang1033\f0\fs23 this is a second test \par\par}";


Output

At this point I am unsure if there is a way around this other than moving all the text to separate Formula fields within crystal itself and then combine. This would mean if they wanted to change text it would have to be done within crystal. I would rather not go this route so I’m looking for opinions and suggestions.

هل كانت مفيدة؟

المحلول

Crystal does support RTF however it needs to be fully formed within the first occurance of an RTF entry. In my question it shows two separate COMPLETE RTF entries. As the entries all have the RTF ID tags this will not be possible. The same issue would occur if you copied the above text into a text editor and saved it as RTF. You would only get the first line. This doesnt explain why it works as a parameter and not a formula but its likely how each are evaluated and the later (parameter could loose support in the future).

To Properly pass RTF to crystal you will need to two Rich text box objects. One being a temp box and the other being the builder box and only selecting the formatted text, not the entire RTF content. An example of this can be found at:

http://moneybaron.org/2011/08/23/vb-net-merge-rtf-documents/

Aside from some hacks such as removing the closing brace from the RTF string or rebuilding the RTF table are also avaliable however removing the brace could lead to an unsupported configuration and rebuilding can get messy really quick.

Hope this helps!!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top