How to code for attributes etc

General TRichView support forum. Please post your questions here
Post Reply
larshgf
Posts: 20
Joined: Fri Jan 20, 2017 9:35 am

How to code for attributes etc

Post by larshgf »

How do I code for bold, italic, underline, subscript and superscript + changing size and font.?
I need this information for a Delphi program where data is entered in editfields - and as these data are entered they are shown in a component (richeidtview or what you call the TRichView for this) in the correct layout.

If I Invest in TRichView is it then possible to ezxport the rtf-file in other formats (like pdf, Word etc)?

Best Regards
Lars - DK
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: How to code for attributes etc

Post by Sergey Tkachenko »

You have two options for implementing commands.

1) Using RichViewActions.
Create TActionList component, add TRichView actions to it (such as TrvActionBold or TrvActionSuperscript).
Create toolbar buttons and/or menu items. Assign actions from TActionList to their Actions property.
This is all, you do not need to write any code.
(well, in FormCreate, call RVA_LocalizeForm(Self) (where the parameter is a form or datamodule containing actions)
In addition to actions, there are font and font size combo boxes that work without writing code as well.

2) Implementing these commands yourself.
The key method is ApplyStyleConversion (and OnStyleConversion event).
The example is in Demos\DelphiUnicode\Editors\Editor 2\
It shows how to implement changing font attributes: bold, italic, underline, text color, font, font name, font size.
It does not show how to implement subscript/superscript, but it's very simple to add them.
I can do it, if you need.
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: How to code for attributes etc

Post by Sergey Tkachenko »

TRichView can export documents to RTF, DocX, HTML.
TRichView does not have methods for PDF saving, but it can do it using thirdparty tools, including:
- LLPDFLib (open source): http://www.trichview.com/forums/viewtop ... f=3&t=2511
- Synopse PDF engine (open source): http://www.trichview.com/forums/viewtop ... f=3&t=7304
- eDocEngine (commercial, example is included in eDocEngine)
medstar
Posts: 4
Joined: Fri Dec 16, 2011 10:23 am

Re: How to code for attributes etc

Post by medstar »

Hi Sergey!

I'd really like to see some code for changing the font without RichViewActions. I'd look for myself, but we have an older version of RichView and the download links to the samples does not work any more.
Can you post the links here or is this sensible information? If not, how would one implement a [Bold] button to just change the font style for the yet to by typed text?

Cheers
Stefan
Sergey Tkachenko
Site Admin
Posts: 17253
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: How to code for attributes etc

Post by Sergey Tkachenko »

See the demo in TRichView\Demos\DelphiUnicode\Editors\Editor2\
It shows how to implement basic operations for editing text and paragraph attributes.

Demo projects for older versions of TRichView can be found in
http://www.trichview.com/rvfiles/archive/

For example, for customers who ordered in 2010, the files are in
http://www.trichview.com/rvfiles/archive/v13/
(the files are for the last TRichView version available for customers who ordered in 2010)
Post Reply