Is there a way to detect if there is formatting or not (i.e. Rich) anywhere in a RichTextBox?
I'd like to write RichTextBox.Rtf is there is, and RichTextBox.Text if there isn't.
I came across a post that suggested checking the SelectionFont after selecting all text, but I have no idea how to accomplish that, or if it would work.
Thanks!
You can check the rtf property of the richtextbox: richtextbox1.rtfto see the rich text code. Even with no additional formatting, there will be some rich text formatting. For example, here's what you get with a richtextbox containing only "text":
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}
\viewkind4\uc1\pard\f0\fs16 test\par
}
You can check to see if there are any additional formatting tags, and if not, it should be plain text. You can also access the plain text (without formatting) with richtextbox1.text.
Related
I would like to write a VBA macro that highlights all paragraphs that have any kind of formatting applied, causing those paragraphs to not match their style.
Then I want to highlight in a different color all text with altered font applied. This would allow me to see all the horrible mangling someone else did to a document, since many Word users ignore styles. I can probably muddle through most of the VBA required, but I have not found a snippet for specifically selecting directly formatted objects.
What have you tried?
Pressing Ctrl+A, Ctrl+Q, Ctrl+Spacebar will return all text to the paragraph and font settings prescribed by the corresponding Styles. If you then save that document with a new filename and use Word's document comparison tools, that will show you all the formatting differences between the two.
Do note, though, that the process removes formatting applies by character Styles, too.
Simple as - and no code required. That said, see also:
https://answers.microsoft.com/en-us/msoffice/forum/all/print-applied-document-formatting-not-real-styles/e291f11e-7e07-47d8-be7f-22677cdb4ac0
I'm sure this is just a google search away, but I can't find the right search terms to find what I'm looking for.
I've created a DataPackage that has both HTML annd plain text content. I've used this in my copy and my sharing code and it works fine. I now want to create RTF output as some apps don't seem to accept HTML clipboard content.
I'm looking for a good guide to making RTF text that can be added to the DataPackage. I just need simple formatting including changing the font family, font size, font weight and adding newlines. The data comes from a list of objects taht I want to serialise as RTF, not from a text control on the screen.
WordPad outputs fairly clean RTF and some other text editors do as well. If that's not enough, you can download the RTF Specification 1.9.1 although like any specification that's probably overkill for what you're doing.
You can also use the SaveToStream method on the Document property of a RichEditBox from a Metro style app to share out as well.
Is there a good way to force pasting as text inside Rich Text Fields inside Sitecore? I know there's a "Paste as Text" button in the Rich Text Editor itself, but content authors are almost definitely going to just hit Ctrl+V or Right-Click->Paste to put the text in, and if that content came from Word, all hell breaks loose with the markup. The workaround we have so far is to paste into notepad and then to copy that text and paste it into the Rich Text Field, but that solution is inelegant and I hate it.
Thank you for your time.
Take a look at the setting
<property name="StripFormattingOnPaste">None</property>
Located in the file /sitecore/shell/radcontrols/editor/ConfigFile.xml
Last time I had a requirement similar to yours, I went in there and made the change and it worked fine. Should still work, unless they changed something :-)
I have a form that uses Richtexteditor of Flex3 to write in their reply. The reply is then posted to a textarea, where all of the formatting is lost! I have embedded the font since I was doing some tweeening on the text boxes.
I need to find out how keep the formatting intact in the textarea from richtexteditor!
has anybody an idea?
Make sure that you set the htmlText property on the TextArea, not just text.
I have this RichTextbox in my vb.net form and I would like to when a user click a button, for example to embold the selected text, how would I do this.
Also, I do NOT want to use the standard vb.net expressions such as RichTextBox1.SelectedText.Font.Bold = True. I want to do something like RichTextbox1.SelectedRTF="[bold]" & RichTextBox1.SelectedRTF & "[/bold]" or whatever RTF looks like.
Can I just add the RTF options random places or can a RichTextBox return an error if the text is in wrong format. I'm mostly looking for info on how to work with RTF without using the standard vb expressions. Thank you very much for any help provided
It just doesn't work this way, it is not an HTML editor. Hacking RTF directly is technically possible through the Rtf property but very hard to get right. RTF is not exactly a friendly format. Start reading here, try not to panic at the quality of that first page. Well, go ahead.