I recently purchased Trichview.
For 2 weeks, I could not till now view a docx file stored in Application folder in my android device.
I need a simple and example code of how to do that.
TRichView very primitive example for newbie
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: TRichView very primitive example for newbie
If DocX file (let its name is 'example.docx') is deployed to assets\internal, you can load it as:
This example assumes that you placed RichViewEdit1: TRichViewEdit and RVStyle1: TRVStyle on the form, and assigned RichViewEdit1.Style = RVStyle1.
Code: Select all
uses System.IOUtils;
var
FileName: String;
begin
FileName := IncludeTrailingPathDelimiter(System.IOUtils.TPath.GetDocumentsPath) + 'example.docx';
RichViewEdit1.Clear;
RichViewEdit1.LoadDocX(FileName);
RichViewEdit1.Format;
end;
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: TRichView very primitive example for newbie
Also, you can check demo projects in <TRichView Dir>\Demos\Delphi.FMX\ folder.
For example, "Editors\Editor 2\" demo.
Editor demos allow opening files (including DocX files) from common location of Android device.
The procedure is slightly more difficult than opening application-local files: a file choosing dialog returns not a file name, but file URL.
Details of file choosing on Android and iOS are described here: https://www.trichview.com/forums/viewtopic.php?t=11960
(this topic is in the protected section of this forum, I opened access for your account).
For example, "Editors\Editor 2\" demo.
Editor demos allow opening files (including DocX files) from common location of Android device.
The procedure is slightly more difficult than opening application-local files: a file choosing dialog returns not a file name, but file URL.
Details of file choosing on Android and iOS are described here: https://www.trichview.com/forums/viewtopic.php?t=11960
(this topic is in the protected section of this forum, I opened access for your account).
Re: TRichView very primitive example for newbie
Thank you.Sergey Tkachenko wrote: ↑Thu Oct 12, 2023 8:56 pm Also, you can check demo projects in <TRichView Dir>\Demos\Delphi.FMX\ folder.
For example, "Editors\Editor 2\" demo.
Editor demos allow opening files (including DocX files) from common location of Android device.
The procedure is slightly more difficult than opening application-local files: a file choosing dialog returns not a file name, but file URL.
Details of file choosing on Android and iOS are described here: https://www.trichview.com/forums/viewtopic.php?t=11960
(this topic is in the protected section of this forum, I opened access for your account).
It warked. The problem now it did not display right2left arabic unicode correctly, though I selected unicode in the rvstyle.
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: TRichView very primitive example for newbie
"Unicode" property of text styles is an obsolete property, it does nothing, all text is always Unicode.
1) Probably, to display your file properly, you should define the main text direction in the document.
Assign RichViewEdit1.BiDiMode = rvbdRightToLeft to set RTL direction, or rvbdLeftToRight to set LTR direction.
Do it before loading DocX. Some bi-di properties are not loaded from DocX is BiDiMode = rvbdUnspecified.
2) To make sure that all DocX properties are loaded. Right click RichViewEdit1 at design time, choose "Settings" in the popup menu.
To load all DocX text and paragraph properties, the setting on the first page must be "Allow adding styles dynamically" or "Allow adding styles dynamically + StyleTemplates".
1) Probably, to display your file properly, you should define the main text direction in the document.
Assign RichViewEdit1.BiDiMode = rvbdRightToLeft to set RTL direction, or rvbdLeftToRight to set LTR direction.
Do it before loading DocX. Some bi-di properties are not loaded from DocX is BiDiMode = rvbdUnspecified.
2) To make sure that all DocX properties are loaded. Right click RichViewEdit1 at design time, choose "Settings" in the popup menu.
To load all DocX text and paragraph properties, the setting on the first page must be "Allow adding styles dynamically" or "Allow adding styles dynamically + StyleTemplates".