Many thanks for a great component - it's just what I need for a small project I'm working on at the moment which has to generate printed material from both a plastic card printer and an ordinary A4 laser.
One thing which I can't understand - how do you get accurately the pixels per inch (PPI) of the selected printer? For example, this -
- Code: Select all
// PrintPreview is a TPrintPreview object.
PrintPreview.Printer.PrinterIndex := PrintPreview.Printer.Printers.IndexOf('Brother HL-2070N series');
ShowMessage(IntToStr(PrintPreview.Canvas.Font.PixelsPerInch));
- returns 96 PPI, whereas the real resolution of the printer is 1200 DPI. In addition, if I do this:
- Code: Select all
PrintPreview.Canvas.Font.Size := 9;
LineLength := PrintPreview.Canvas.TextWidth('a');
ShowMessage(IntToStr(LineLength));
- I get 83, which at 96 PPI would make a 9-point letter 'a' nearly an inch wide!! So obviously I'm not understanding the relationship between pixels and DPI, or else I'm doing something plain wrong, and I'd appreciate any help you can give me.
The reason for this is that I'm trying to write a procedure which will break wrap long lines of text correctly on the page, so I need to be able to calculate lengths accurately.
Many thanks,
Ray O'Donnell.