Linux is now giving the correct dpi in printer pixels same as Windows, see bug tracker 13356. I don't know about Mac OS X though.
Sorry for cutting in here, but I think this issue is still alive and present on Mac OS X. To test this, I have written a small app which has a button and a TPrintDialog on a form. The OnClick of the button code is below (excuse the badly factored code, but it's a knock-up). I have run this on MacOS and saved the print to PDF, and on Windows used pdfcreator to save the PDF. To cross-check, I have also verified that the output looks the same when printed to the same, real printer (a LaserJet 1320), so these PDFs reflect actual printout.
As I see it, there are actually three differences to be concerned about (margins/printable area, text size, line thickness), but this topic is only about line thickness, which seems to be caused by the 72dpi setting (having read bug 13356). It would appear that this has been fixed in linux, but those changes have not been ported to macos.
I can't believe that I'm the only one seeing this, so it makes me wonder if I'm approaching the printing from the wrong angle. Is there another technique for getting consistent behaviour from the same codebase across all platforms, or is this still a bug?
Thanks,
Murray.
procedure TForm1.Button1Click(Sender: TObject);
var
lh : integer;
begin
if not PrintDialog1.Execute then exit;
with printer do
begin
BeginDoc;
lh := Canvas.TextHeight('X');
Canvas.Rectangle(0,0,PageWidth-1, PageHeight-1);
Canvas.Polyline([point(0,0),point(PageWidth-1, PageHeight-1)]);
Canvas.Polyline([point(0,PageHeight-1),point(PageWidth-1, 0)]);
Canvas.TextOut(XDPI, YDPI+lh, 'PageWidth='+IntToStr(PageWidth));
Canvas.TextOut(XDPI, YDPI+lh*2, 'PageHeight='+IntToStr(PageHeight));
Canvas.TextOut(XDPI, YDPI+lh*3, 'XDPI='+IntToStr(XDPI));
Canvas.TextOut(XDPI, YDPI+lh*4, 'YDPI='+IntToStr(YDPI));
Canvas.TextOut(XDPI, YDPI+lh*6, 'Canvas.PageWidth='+IntToStr(TPrinterCanvas(Canvas).PageWidth));
Canvas.TextOut(XDPI, YDPI+lh*7, 'Canvas.PageHeight='+IntToStr(TPrinterCanvas(Canvas).PageHeight));
Canvas.TextOut(XDPI, YDPI+lh*9 ,'Canvas.PaperWidth='+IntToStr(TPrinterCanvas(Canvas).PaperWidth));
Canvas.TextOut(XDPI, YDPI+lh*10,'Canvas.PaperHeight='+IntToStr(TPrinterCanvas(Canvas).PaperHeight));
Canvas.TextOut(XDPI, YDPI+lh*11,'Canvas.TopMargin='+IntToStr(TPrinterCanvas(Canvas).TopMargin));
Canvas.TextOut(XDPI, YDPI+lh*12,'Canvas.BottomMargin='+IntToStr(TPrinterCanvas(Canvas).BottomMargin));
Canvas.TextOut(XDPI, YDPI+lh*13,'Canvas.LeftMargin='+IntToStr(TPrinterCanvas(Canvas).LeftMargin));
Canvas.TextOut(XDPI, YDPI+lh*14,'Canvas.RightMargin='+IntToStr(TPrinterCanvas(Canvas).RightMargin));
EndDoc;
end
end;