I'm using Migradoc to print a series of PDF pages. I also have a RichTextBox from the Extended WPF Toolkit. The text is currently using the rtf encoding and is bound to a string property.
I have already seen this answer: https://stackoverflow.com/a/13986397/978622.
It appears to convert the generated XPS to an entire PDF page. I'd like to use the textbox content within a page.
How can I print the formatted text from the textbox with Migradoc? I've
I'm willing to consider using any rich textbox that allows binding & serialization of the data if it makes printing with Migradoc easier.
Related
I am trying to format a hyperlink in a Rich Text Box using the Rich Text Format. I can get basic formatting working thanks to this answer, for example making text bold. However I cannot get the RTF formatted hyperlink to work. I found an example of making an RTF link here. However, when I try to put this in the Rich Text Box as seen below, it causes my application to crash. Any suggestions as to what i'm missing here?
string my_hyperlink_text = #"{\field{\*\fldinst HYPERLINK \"http://www.google.com/\"}{\fldrslt Google}}"
if (rtbControl is RichTextBox & rtbControl.Name == "name_of_control") // Making sure the control is a RichTextBox
{
RichTextBox rtb = rtbControl as RichTextBox;
rtb.Rtf = my_hyperlink_text;
}
An easy way for getting rtfs to work is to write your text in Microsoft word, copy & paste it to Wordpad and the saving it as a RTF from there.
The detour with MS Word is needed, because WordPad does not support entering links in the UI, although it handles them correctly when they come from other sources, like the clipboard. Also, MS Word creates massively bloated rtf.
The rtf file you create this way can then be opened in any text editor and can be used as a string constant in your program.
In your case, I suppose that the prefix and maybe the color table are missing and are causing the problem.
By the way: Wordpad is not much more than a wrapper around the Windows rtf control, i.e. the same control that you are using in your code.
I am converting our current PDF export using ITextSharp over to Migradoc. We currently render Rich Text to ITextSharp from a string stored in the database - for example:
<p><strong style=\"color: rgb(230, 0, 0);\"><u>test</u></strong></p>
ITextSharp is able to pick out the elements of this and render appropriately using (I think) Cell.AddElement(ElementListItem).
Ideally I am looking for something identical to this for MigraDoc but any help on RTF in MigraDoc would be greatly appreciated.
MigraDoc does not parse HTML.
You can use the AddFormattedText method of the Paragraph class to mix various rich formats within one paragraph, but parsing the HTML is up to you.
See also:
http://pdfsharp.net/wiki/HelloMigraDoc-sample.ashx
How can I show rtf strings in a RichTextBlock (or any other UI text element)? There's no rtf property I could use (different from .net I think). And if I bind the string to the normal text property I only get the rtf code itself.
So is there a way to do this? Otherwise I'd display the string as HTML in a WebView element. But I'd prefer a RichTextBlock.
Use a RichEditBox instead of RichTextBlock. You can inject RTF with RichEditBox.Document.SetText() method. RichTextBlock isn't an RTF control and doesn't understand RTF. The RichEditBox is the only in-box control which supports RTF. If you don't want to use that then you would need to parse the RTF yourself and create the block elements for the RichTextBlock.
I am displaying text in a rich textbox and i want it to show the html formatting on the text. Is there a way to make a rich textbox display html.
If you push the button on the following link you will see how my out put displays, i would like it done in a rich textbox.
http://neil.fraser.name/software/diff_match_patch/svn/trunk/demos/demo_diff.html
Is there a way to build a rich textbox that can display html???
RTF encoding is different from HTML.
If not, then you need to write your own HTML to RTF converter or find something similar.
Writing Your Own RTF Converter. This guy gives a great breakdown of how the program works along with details of the conversion.
An Extended richtextbox control, Check this out. It may solve your solution
I have a problem ActiveReports 3.0 (VB.NET) with RichTextBox. When I print an RTF text which attribute: "\page" that it must make a BreakPage and need to print more than one page. But the report does not understand this attribute "\page" (BreakPage) and print it on a page.
Alternatively I thought to split the rtf file after the item "\page" and save to the database in more records, RTF file fragments where each row will be displayed in RichTextBox in ActiveReport. The problem is that the RTF file header will only be in first record, but other records will not have headers which will not allow them open in RTB control.
How can I split a RTF or resolve problem with ActiveReports?
Thanks in advance!
Unfortunately, the ActiveReports RichEdit control does not support page breaks.
Maybe you can make the header just a separate static RTF that you add to a group header? I'd have to see your report and what you're trying to accomplish to do more.
Scott Willeke
GrapeCity inc.