Recent

Author Topic: [SOLVED - Sort of!] Printing RichMemo  (Read 2541 times)

Badger

  • Full Member
  • ***
  • Posts: 158
[SOLVED - Sort of!] Printing RichMemo
« on: November 07, 2019, 06:12:49 am »
I am finding it very hard to get info on printing RichMemos.  Firstly, the RichMemo Wiki page shows limitations for printing on different platforms.  Am I to understand that the printing capability is only available on Windows?  If that's the case I will have to use an straight memo.

If I can print on Macs, can someone please help.
I have two RichMemos and an image on a panel that represents a small card.  The image is movable and re-sizable and the RichMemos accommodate this by changing size.  I then need to print the 'card' (approx size for size). I tried the PaintTo method but the outcome was ridiculously small and the text on the  RichMemo was missing.  I obviously need to do it properly but I can't find any documentation on how to print the two RichMemos with the image.  The only ref I can find is https://forum.lazarus.freepascal.org/index.php?topic=33723.0 - Print method don't work  « on: August 17, 2016, 12:43:21 am »  However, this does not seem to use beginDoc and EndDoc which seem to be necessary to StrechDraw the image so I'm at a bit of a loss as to the exact process.
« Last Edit: December 19, 2019, 01:32:19 pm by Badger »
Badger
(A bad tempered, grumpy animal that sleeps most of the winter!)

If at first you don't succeed - you're running about average!

I'm using Windows 10 Lazarus v3.6  FPC 3.2.2   Win 32/64

Badger

  • Full Member
  • ***
  • Posts: 158
Re: Printing RichMemo
« Reply #1 on: December 19, 2019, 12:49:30 pm »
Well, I seem to have baffled the experts so I went ahead tried to solve the problem myself.

I have come up with a fairly flexible procedure for printing a RichMemo.  The top and left margins can be set and the memo can be scaled to any size needed.  Most importantly, the procedure can be called from within BeginDoc / EndDoc commands so you can add images and graphics to the page or even multiple Memos on the same page.

I'm no expert so the coding is cheep and nasty and probably has some bugs but it works fairly well.

The main limitations are that it doesn't trap breaking spaces and hyphens but that wouldn't be hard to add (I don't need that degree of sophistication) and it only traps a single blank space at the end of a wrapped line (for right and centre justified paras). Again not hard to fix but didn't want to waste any more time on the project).

The attached files give a demo of the procedure.

Comments welcome.  Don't be too critical. :D


Badger
(A bad tempered, grumpy animal that sleeps most of the winter!)

If at first you don't succeed - you're running about average!

I'm using Windows 10 Lazarus v3.6  FPC 3.2.2   Win 32/64

AgriMensor

  • Jr. Member
  • **
  • Posts: 56
Re: [SOLVED - Sort of!] Printing RichMemo
« Reply #2 on: November 16, 2025, 06:27:08 pm »
Hi Badger!

Quote
I have two RichMemos and an image on a panel that represents a small card.  The image is movable and re-sizable and the RichMemos accommodate this by changing size.  I then need to print the 'card' (approx size for size). I tried the PaintTo method but the outcome was ridiculously small and the text on the  RichMemo was missing.

I know nothing about Mac environments, I'm afraid, but under Windows I experienced similar frustrations as you in trying to resolve text resizing (which I eventually managed to accomplish) and missing RichMemo text (which I didn't). Not to even mention lack of relevant documentation and sample routines.

After 2+ weeks of trying, I eventually stumbled over your contribution of nearly 7 years ago and I do sincerely hope that you are able to pick up this message after such a long time!

Your character-by-character printing approach, although laborious, solved the problem and I'm delighted that it has done so - I am probably too lazy to have ever tried this of my own volition, even if I had thought of it in the first place! Thank you!

I'd very much like to include you in my Credits list when the program is released if you feel OK with letting me know your name; I couldn't find it in your Profile.

Once again, many thanks.

 

TinyPortal © 2005-2018