Page 1 of 1

How to code for attributes etc

Posted: Wed Feb 01, 2017 10:59 am
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

Re: How to code for attributes etc

Posted: Wed Feb 01, 2017 7:51 pm
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.

Re: How to code for attributes etc

Posted: Wed Feb 01, 2017 7:54 pm
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)

Re: How to code for attributes etc

Posted: Mon Feb 27, 2017 1:57 pm
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

Re: How to code for attributes etc

Posted: Mon Feb 27, 2017 6:38 pm
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)