How to set the PixelsPerInch property of a TPrinter (Views: 31)
Problem/Question/Abstract: How to set the PixelsPerInch property of a TPrinter Answer: When changing printers, be aware that fontsizes may not always scale properly. To ensure proper scaling, set the PixelsPerInch property of the font after changing the printer index property. Be sure not to make the change until you have started the print job. Here are two examples: uses Printers; var MyFile: TextFile; begin Printer.PrinterIndex := 2; AssignPrn(MyFile); Rewrite(MyFile); Printer.Canvas.Font.Name := 'Courier New'; Printer.Canvas.Font.Style := [fsBold]; Printer.Canvas.Font.PixelsPerInch := GetDeviceCaps(Printer.Canvas.Handle, LOGPIXELSY); Writeln(MyFile, 'Print this text'); System.CloseFile(MyFile); end; uses Printers; begin Printer.PrinterIndex := 2; Printer.BeginDoc; Printer.Canvas.Font.Name := 'Courier New'; Printer.Canvas.Font.Style := [fsBold]; Printer.Canvas.Font.PixelsPerInch := GetDeviceCaps(Printer.Canvas.Handle, LOGPIXELSY); Printer.Canvas.Textout(10, 10, 'Print this text'); Printer.EndDoc; end; |