Getting images from an RTF file
-
Hi, I need to collect the images from an RTF file as image objects that I can work on individually. Any ideas? I tried loading the RTF file in the RTFTextBox in WinForms. The images show up correctly, but I still haven't figured out a way of accessing them directly. Hope someone can help. Thanks! Sarab
-
Hi, I need to collect the images from an RTF file as image objects that I can work on individually. Any ideas? I tried loading the RTF file in the RTFTextBox in WinForms. The images show up correctly, but I still haven't figured out a way of accessing them directly. Hope someone can help. Thanks! Sarab
That won't be easy. You will need to read RTF specification. Here is an article that does the opposite you want: inserts images in richtextbox so it might help to understand basic concepts: Insert Plain Text and Images into RichTextBox at Runtime[^]
Giorgi Dalakishvili #region signature my articles My blog[^] #endregion
-
That won't be easy. You will need to read RTF specification. Here is an article that does the opposite you want: inserts images in richtextbox so it might help to understand basic concepts: Insert Plain Text and Images into RichTextBox at Runtime[^]
Giorgi Dalakishvili #region signature my articles My blog[^] #endregion
-
Hi, I need to collect the images from an RTF file as image objects that I can work on individually. Any ideas? I tried loading the RTF file in the RTFTextBox in WinForms. The images show up correctly, but I still haven't figured out a way of accessing them directly. Hope someone can help. Thanks! Sarab
The RTF specification is available here[^] if that's any help. I think you're gonna have to parse the rtf and reconstruct the image from the data that's embedded.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Expect everything to be hard and then enjoy the things that come easy. (code-frog) -
Hi, I need to collect the images from an RTF file as image objects that I can work on individually. Any ideas? I tried loading the RTF file in the RTFTextBox in WinForms. The images show up correctly, but I still haven't figured out a way of accessing them directly. Hope someone can help. Thanks! Sarab
-
Hi, I need to collect the images from an RTF file as image objects that I can work on individually. Any ideas? I tried loading the RTF file in the RTFTextBox in WinForms. The images show up correctly, but I still haven't figured out a way of accessing them directly. Hope someone can help. Thanks! Sarab
Hi, Thanks to everyone for your ideas! I managed to get the images. Here's how: Images in RTF are as hexadecimal strings (as noted from the specifications). So all that needed to be done was: 1. Convert the hexadecimal to a byte array: http://www.koders.com/csharp/fid8BD422682325288B294A97714AC061D115F0307D.aspx[^]) 2. Then make an image out of this array: byte[] bData; // The byte array MemoryStream memStream = new MemoryStream(bData, 0, bData.Length); Image iMage = Image.FromStream(memStream); Et voila! Sarab