Recent

Author Topic: How would you display an .rtf file?  (Read 2236 times)

1HuntnMan

  • Full Member
  • ***
  • Posts: 185
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
How would you display an .rtf file?
« on: December 31, 2023, 10:29:12 pm »
Would you load it into a TMemo? Or TOpenDialog? Just want to present a how-to/document to use my app.

dbannon

  • Hero Member
  • *****
  • Posts: 2792
    • tomboy-ng, a rewrite of the classic Tomboy
Re: How would you display an .rtf file?
« Reply #1 on: January 01, 2024, 12:22:54 am »
KMemo (in KControls) native format is RTF, it has a KMemo1.LoadfromRTF() (or similar) method.

However, as RTF is such a complicated format, no guarantee it will know about every RTF tag in there. I have found it pretty good.

https://wiki.freepascal.org/KControls/KMemo_notes

https://github.com/kryslt/KControls/

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

1HuntnMan

  • Full Member
  • ***
  • Posts: 185
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: How would you display an .rtf file?
« Reply #2 on: January 03, 2024, 04:46:51 pm »
Okay DBannon,
   Back to this today and thanks for the links. Can I verify how to install this into my Laz IDE, I'm a beginner?
   I found the Laz pkg on GetHub via your link to KControls and found the kcontrolslaz.lpk.  To load it into my Laz IDE would I just create an empty file with NotePad++ and load and save the contents of kcontrolslaz.lpk into it and save? Then in Lazarus go to Package - Install/Uninstall and then Import List?

AL

  • Sr. Member
  • ****
  • Posts: 264
Re: How would you display an .rtf file?
« Reply #3 on: January 03, 2024, 04:56:08 pm »
Make it a PDF  and use OpenDocument
Laz 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: How would you display an .rtf file?
« Reply #4 on: January 03, 2024, 05:04:14 pm »
Make it a PDF  and use OpenDocument
Ok, and how do you do that through code (without a rtf viewer)?

@1HuntnMan
You can install KControl or RichMemo via OPM (Online Package Manager).
Use Package > Online Package Manager

Curt Carpenter

  • Sr. Member
  • ****
  • Posts: 402
Re: How would you display an .rtf file?
« Reply #5 on: January 03, 2024, 05:26:42 pm »
To install KControls, use Online Package Manager:  Package>Online Package Manager then check and install KControls.

You can also use Richmemo also installed from the online package manager, but it seems to work better with Windows than with Linux if that matters for you.  I used it in a project last year and it took some effort, but was pleased with the result in the end.
« Last Edit: January 03, 2024, 05:33:31 pm by Curt Carpenter »

dbannon

  • Hero Member
  • *****
  • Posts: 2792
    • tomboy-ng, a rewrite of the classic Tomboy
Re: How would you display an .rtf file?
« Reply #6 on: January 03, 2024, 10:59:26 pm »
Okay DBannon,
   Back to this today and thanks for the links. Can I verify how to install this into my Laz IDE, I'm a beginner?
   I found the Laz pkg on GetHub via your link to KControls and found the kcontrolslaz.lpk.  To load it into my Laz IDE would I just create an empty file with NotePad++ and load and save the contents of kcontrolslaz.lpk into it and save? Then in Lazarus go to Package - Install/Uninstall and then Import List?

As Curt said, the OPM should work fine. TK has made some minor fixes since the OPM snapshot but I doubt you will see the difference. I tend to download a zip, unzip into a directory and then look in that dir with Lazarus -> Packages -> Open package file. ...... Install

That will get you an extra tab, far right, on the components bar. One of them is KMemo, put a kmemo onto a form. KMemo.loadfromRTF(AFileName);  I'd suggest that if your RTF file has RTF things that KMemo cannot handle, you might be in trouble !

Re discussion about PDF, I have a rather lame but function KMemo to PDF convertor unit in my project. If thats the way you are heading, its yours as long as you feed back the bugfixes ....

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2055
  • Fifty shades of code.
    • Delphi & FreePascal
Re: How would you display an .rtf file?
« Reply #7 on: January 03, 2024, 11:53:59 pm »
On windows you can check if "rtf"-extension is associated with something, if so, validate if "something" exists, if so, run "something" with "rtf" inside a job
else, use what others suggested.
(That way a user has an viewer opened where he is used to)
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Thaddy

  • Hero Member
  • *****
  • Posts: 14369
  • Sensorship about opinions does not belong here.
Re: How would you display an .rtf file?
« Reply #8 on: January 04, 2024, 08:34:26 am »
you can use fpdoc to generate documentation in several different formats like html, chm, LaTex, Man or pdf. It is used for the FreePascal docs.
If I needed documentation, I use makeskel, edit that and subsequently use fpdoc to generate html and display it in ThtmlViewer, CEF or one of the pdf viewer components. MakeSkel generates a skeleton in XML  for any unit and has entries for all the identifiers in a unit.
See the documentation for fpdoc.

Once you are done, you can also generate the same docs in other supported formats. These FreePascal standard tools are often overlooked.
They are excellent and well structured.
Note that fpdoc can also be used for end-user documentation instead of the code centered docs that I described above, so also for how-to' s , And it is very easy to use,
I recommend it and prefer it above any of the previous suggestions.
Better than working with rtf format...
« Last Edit: January 04, 2024, 09:06:22 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018