Print Preview Text Size

General TRichView support forum. Please post your questions here
Post Reply
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Print Preview Text Size

Post by standay »

Hi Sergey,

In my main rve I am now using DocumentPixelsPerInch and no longer setting overall font size(s) as a "zoom." I would like to maintain the approximate overall text size or "zoom" when printing. I've tried the following ("memo" is my rve, rvs is its RVStyle):

Code: Select all

    memo.DocumentPixelsPerInch := rve.DocumentPixelsPerInch;
    rvs.UnitsPixelsPerInch := rve.DocumentPixelsPerInch;
    rvs.TextStyles[0].Size := 48;
Of those, only rvs.TextStyles[0].Size changes the print preview text. Is there a way to do this to make the printout text size or dpi consistent with my main rveDocumentPixelsPerInch setting?

I set this up this way for now. I added 2 buttons to my print preview form, one to make the font larger, one smaller.

Code: Select all

procedure TFormPrintPreview.SRDCvsFontLargerMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  i, i2: integer;
begin

  if Button = mbRight then exit;

  for i := 0 to RVPrint1.rv.Style.TextStyles.Count-1 do
    RVPrint1.rv.Style.TextStyles[i].Size := RVPrint1.rv.Style.TextStyles[i].Size + 2;

  for i := 0 to RVPrint1.rv.Style.ListStyles.Count - 1 do
  begin
    for i2 := 0 to RVPrint1.rv.Style.ListStyles[i].Levels.Count-1 do
      RVPrint1.rv.Style.ListStyles[i].Levels[i2].Font.Size :=
        RVPrint1.rv.Style.ListStyles[i].Levels[i2].Font.Size + 2;
  end;

  RVPrint1.FormatPages( rvdoALL );

  RVPrintPreview1.Repaint ;

end;
This actually works OK, although I can't quite get the preview to redraw accurately but the printout is OK so that's not a showstopper. But, as always, if you have a better way I'd love to know!

Thanks Sergey.

Stan
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Print Preview Text Size

Post by Sergey Tkachenko »

When displaying on the screen, text size is calculated as
FontSize * rv.DocumentPixelsPerInch / rv.Style.UnitsPixelsPerInch.

When printing, text size is calculated as
FontSize * "printer pixels per inch" / rv.Style.UnitsPixelsPerInch.
You cannot change "printer pixels per inch", it is read from the device. But you can change UnitsPixelsPerInch.
Post Reply