I am working with 9.1 Documents. Using the RTF sample, and the Sample Gallery with modified code to get an RTF string into a MemoryStream. That accomplishes most of what I need. But it appears that text tagged with the RTF hidden text code (e.g. {"\v eg}") is not suppressed from the report. The RTF Namespace Character properties do not include hidden. Is there a way to get hidden text suppressed, or is this a needed enhancement? I suppose in the interim, I could preprocess my text string to remove the hidden text before putting it into the memory stream. But it would be nice for the reader to at least handle the hidden text code and set a character property so I could choose to hide or show hidden text (as Word allows). With a hidden property, the OnChar handler in the RTFExample.vb could determine to not call AddContent if the character had the hidden property.
I also do not believe that the RTFReader class is dealing with the RTF spacing codes \sbN, \saN, \slN, Is that true?
For what its worth, I used the following regex to strip out the hidden text:
Dim re As System.Text.RegularExpressions.Regex = _ New System.Text.RegularExpressions.Regex("\{\\v \S*\}")Dim s As String = re.Replace(RtfTextWithHiddenCodes, "")
Hi Roy,
To be perfectly honest, I'm not an RTF export. But if RTF supports a Hidden tag and the PDF engine is not honoring it, then that sounds like a bug that could easily be fixed within the engine.
Can you provide us with a small sample project demonstrating the issue so we can check it out?
Mike, Sorry for the delay in responding as I had already introduced a work-around to filter the hidfden text out of the document before passing it to the RTFConverter. I have attached a sample that you folks can use to evaluate handling an RTF file that has hidden text. As an aside, hidden text is specified by "\v"; thus, you will see the file has substrings such as "{\v g0}". No need to provide a sample program; simply use this file in the Document sample. I changed the sample code to the following:
container = section.AddContainer("Container2") 'stream = New FileStream("Resources/Converters.rtf", FileMode.Open, FileAccess.Read) Dim sr As StreamReader = New StreamReader("Resources/Alda.rtf") Dim s As String = sr.readtoend() Dim re As system.text.RegularExpressions.regex = New System.Text.RegularExpressions.Regex("\{\\v \S*\}") s = re.Replace(s, "") Dim ascii As System.Text.Encoding = System.Text.Encoding.GetEncoding(1252) Dim bCount As Integer = ascii.GetByteCount(s) Dim bytes As Byte() Array.resize(bytes, bCount) Dim iCount As Integer = ascii.GetBytes(s, 0, bCount, bytes, 0) Dim ms As New memorystream() ms.write(bytes, 0, bytes.length) ms.seek(0, SeekOrigin.Begin) Dim rtfLoader As RTFExample = New RTFExample() rtfLoader.Load(container, ms) ms.Close()
If you comment out the regex replacement to eliminate the filter, you will see that the PDF output keeps the hidden text.
You can load the document iun Microsoft Word and choose to show or hide hidden text; the default is hide. Our use of hidden text is to provide sections of the document that can be parsed programmatically. In another posting, I provided the workaround code which was a regex filter.
Thanks. I have forwarded this thread over to Infragistics Developer Support so they can check it out.