Home End User
New Blog Posts: Merging Reports - Part 1 and Part 2

Report from text file:How can I resize fonts...

edited December 2005 in End User
Hi,
I've a DOS application that puts a text file into a directory waiting to be
printed.
My RB application intercept this file and show it in preview before print it
to a printer (laser, dot-matrix or bubble-jet printer).
The file to be printed is token "as it is" so I've no report templates
created. From a text pipeline the report app. do the preview directly.

But the font size must be resized to fit in page the text file.

Also, I must print this file N lines per page (66,72 and so on) by choice.

I've tryied to calculate (in the FirstPass event) the printable area
(horizontal and vertical) with:

pw:=ppreport1.PrinterSetup.PageDef.spPrintableWidth
ph:=ppreport1.PrinterSetup.PageDef.spPrintableHeigth

and the size of actual font with

cw:=ppreport1.Printer.Canvas.TextWidth('H')
ch:=ppreport1.Printer.Canvas.TextHeigth('I')

and multiplying cw by the max line length of the file and ch by the
lines-per-page

wsize:=cw*MaxLineLen
hsize:=ch*HowManyRows

if wsize>cw then
begin
if > 4 then

end

but it seems that they have different unit of measure, because the final
size of the font is too small (I stop the cycle at a size of 5 and this is
the final size).

Also, I see that the wsize is too big respect to cw.

Can you help me ?

Many thanks
Robert

Comments

  • edited December 2005
    Obviously, the font size must be resized to fit in page the text file
    Automatically before the preview.
    Thanks
    Robert
    "Robert Effe" ha scritto nel messaggio
  • edited December 2005
    Peraphs it's the wrong newsgroup?

    "Robert Effe" ha scritto nel messaggio
  • edited December 2005
    Hi Robert,

    Yes, when using the printer canvas, you are calculating the text width in
    printer pixels where as the PageDef.spPrintableWidth is in screen pixels.
    You can do this conversion your self or there are a couple utilities inside
    the ppUtils.pas unit that allow you to make this conversion. Take a look
    at...

    ppFromMMThousandths
    ppToMMThousandths
    ppToScreenPixels
    ppFromScreenPixels

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2005
    How I do to use scroll (mouse) in TppViewer ???
  • edited December 2005

    Try impelenting the OnMouseWheel event for the Form that contains the Viewer
    component.

    Example:

    procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState;
    WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    var
    lScrollBar: TControlScrollBar;
    begin

    lScrollbar := myViewer.ScrollBox.VertScrollBar;
    lScrollBar.Position := lScrollBar.Position - (WheelDelta div 5);

    end;




    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.