> I have a report that prints out directly from a memo component. The
> information is actually split into fields and i want to align them without
> using qreports or reportsmith or anything. Is there a way to do this or a
> control that will enable be to bump out some data in this way.
> Any help would be most appreciated.

Here's a simple app printing all of the fonts on the system directly to the
default printer without any reporting tools. It's just a quick hack to get a
fonts list but it does it's own pagination (vertically only) and does a simple
indent... I think you could also get other information from the printer to
calculate in other metrics than pixels...

NB There has been no testing other than a run (which produced a nice list
  of fonts)... It has no resource protection so if your default printer is incorrect
  or a problem occurs during print, things get ugly...

You could certainly remodel it to print column-based reports without a great
deal of code...

procedure PrintFonts;
var
  I,J,Y,HH,TH,PC :Integer;
  FH,FD :TFont;
  SL,SL2 :TStringlist;
const
  Gap = 10;
  TestText :array[0..1] of String = (
    'ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz',
    '01234567890 !@#$%^&*() -_=+\|[{]};:''",<.>/? `~');
begin
  printer.PrinterIndex := -1;
  Sl := TStringlist.Create;
  SL2 := TStringList.Create;
  SL2.Sorted := True;
  SL.Assign(Printer.Fonts);
  SL.Sorted := True;
  FH := TFont.Create;
  FH.Name := 'arial';
  FH.Size := 8;
  FH.Style := [fsUnderline];

  FD := TFont.Create;
  Y := 0;
  Printer.Title := 'Installed Font Listing';
  Printer.BeginDoc;
  Printer.Canvas.Font.Assign(FH);
  HH := Printer.Canvas.TextHeight('|');
  PC := 1;
  for I := 0 to SL.Count-1 do begin
    with FD do begin
      Name := SL[I];
      Size := 10;
      Style := [];
    end;
    if SL2.IndexOf(FD.Name)<0 then begin
      SL2.Add(FD.Name);
      Printer.Canvas.Font.Assign(FD);
      TH := Printer.Canvas.TextHeight('|');
      if (Y+HH+Gap+((TH+Gap)*Length(TestText)))>=Printer.PageHeight then begin
        Y := 0;
        Printer.NewPage;
        inc(PC);
      end;
      Printer.Canvas.Font.Assign(FH);
      Printer.Canvas.TextOut(0,Y,FD.Name);
      Printer.Canvas.Font.Assign(FD);
      for J := 0 to High(TestText) do
        Printer.Canvas.TextOut(50,Y+Gap+HH+(J*(TH+Gap)),TestText[J]);
      inc(Y,HH+Gap+((TH+Gap)*Length(TestText)));
    end;
  end;
  if MessageDlg(format(
    '%5d Installed Fonts'+#13+
    '%5d Prepared Fonts (Non-proportionals and non-truetypes removed)'+#13+
    '%5d Pages prepared'+#13+#13+
    'Okay to print?'
    ,[SL.Count,SL2.Count,PC]),mtinformation,[mbOK,mbCancel],0)=mrOK then
    Printer.EndDoc
  else
    Printer.Abort;
  FH.Free;
  FD.Free;
  SL.Free;
  SL2.Free;
end;

--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to