Click here to Skip to main content
15,883,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,
loading .rtf file is easy by Richtextbox.loadfile();
But now I want to load just one specific page to my form! For example load page 5 of my .rtf file to Richtextbox1 !
how could i do it !?
i'll appreciate any help.
Posted

Not supported. Formatting of some RTF tags is global acrossed the entire document. You cannot load just "page 5" without losing some of the formatting.

You either load the entire document or nothing at all.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 3-Mar-12 18:03pm    
Agree, my 5. There is more to it: what's a page, is not well-defined. Also suggested some alternative -- in my answer.
--SA
Mohamad77 7-Mar-12 15:13pm    
thanks for help,
i'll try another way to create my Viewer!
and again i'll appreciate any idea about it ! :)
In addition to the correct answer by Dave:

You could load the whole thing and then select and cut out unwanted part of it. However, the notion of page is not defined. Pages are created on the fly when you print the document. They are not really part of document. To best of my knowledge, even a forced page break is not defined in the RTF format. Your criteria of the selection of the document part simply makes no certain well-defined sense. You can select some part of document according to its structure: a paragraph, a set of paragraphs under certain title or something like that.

Generally, RTF format provides too poor means of defining document structure. I would avoid it by all means.

You could switch to HTML instead. There is a wonderful CodeProject article offering rendering of a HTML document in Forms:
A Professional HTML Renderer You Will Use[^].

—SA
 
Share this answer
 
Comments
Mohamad77 7-Mar-12 15:14pm    
thanks alot buddy :)
Best Regards
Sergey Alexandrovich Kryukov 7-Mar-12 15:24pm    
My pleasure.
Good luck, call again.
--SA
Red Chocolate 1-Nov-12 5:42am    
hi all i need to load a rtf file to richtextbox in wpf with c# as codebehind but LoadFile method is not coming. Getting error as LoadFile is not defined pls help
Sergey Alexandrovich Kryukov 1-Nov-12 14:48pm    
With RTF, this should be quite possible. This is what RichTextBox supports. You need to ask a different question, create a shortest possible but complete code sample, make sure it reproduces the problem, indicate in source code where the problem is (exception information, whatever) and post it with your question. OK?
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900