Active4 years, 3 months ago
RichTextBox operates on FlowDocument objects. Note: Pasting HTML content into a RichTextBox might result in unexpected behavior because.
i'am making a programm where i want my RichTextBox content (text+images) to be saved as an image (jpg/png). I tried to use this solution but i get only black filled image from
I also tried to create FormattedText from my rtb control, printing it works fine, but its not possible to insert images in there. Maybe it is possible to print FlowDocument somehow?
Blachshma15.3k44 gold badges4242 silver badges6161 bronze badges
AutumnKnightAutumnKnight
2 Answers
You could use something like the following method to create a bitmap from a FlowDocument:
and then use it like shown below to save a RichTextBox's Document to an image file.
ClemensClemens94.5k88 gold badges100100 silver badges197197 bronze badges
You can spend HOURS chasing around trying to figure out why the width is wrong when in reality its trying to paginate in columns. Set the document's columnwidth to the full width of your output bitmap.
Clint StLaurentClint StLaurent
Not the answer you're looking for? Browse other questions tagged c#wpfimageprintingrichtextbox or ask your own question.
Active6 years, 9 months ago
I would like to use RichTextDocument / Flow document as content of tooltip to get more formatting features in tooltip. But some strange results happen:
- If use RichTextBox inside tooltip
- If use Flow document directly inside tooltip
Could you please suggest correct way? How to disable that BIG preview window? Maybe flow document usage is not the best way? I realize that I can just add StackPanel and fill with TextBlocks, but it's instresting now what's wrong with FlowDocument? :)
trickbz
trickbztrickbz57011 gold badge55 silver badges2424 bronze badges
1 Answer
The default
LPLLPLDataTemplate
for FlowDocument
contains a FlowDocumentReader
that is used to display the document. If you don't want to dynamically choose between FlowDocumentPageViewer
and FlowDocumentScrollViewer
you can use them directly.14.9k66 gold badges3636 silver badges7575 bronze badges