Lazarus

Programming => Operating Systems => macOS / Mac OS X => Topic started by: mdkass on September 14, 2011, 01:52:03 pm

Title: Can't print with more than 72 DPI resolution!
Post by: mdkass on September 14, 2011, 01:52:03 pm
After getting the printer device and begining the printing functions I always get xdpi and ydpi equal to 72!
My printer can print with 600 dpi

can any expert help me please?
Title: Re: Can't print with more than 72 DPI resolution!
Post by: Shebuka on September 14, 2011, 02:15:42 pm
After getting the printer device and begining the printing functions I always get xdpi and ydpi equal to 72!
My printer can print with 600 dpi

can any expert help me please?
I don't understand the question... Show a test project with description of what you need to achieve.
Title: Re: Can't print with more than 72 DPI resolution!
Post by: mdkass on September 15, 2011, 12:43:15 pm
Code: [Select]
if PrintDialogSetup.Execute then //here the user can choose his printer.
begin
   Printer.BeginDoc;
   //Printer.xdpi,Printer.ydpi are always equal to 72 and this gives low quality prints
   // some printing code here
   Printer.EndDoc;
end;
I'm sure that my printer can print with 600 dpi and its driver is installed correctly.
Title: Re: Can't print with more than 72 DPI resolution!
Post by: alanphys on January 03, 2012, 11:15:25 am
If you are printing under linux it generally returns 72 dpi as documents are first converted to PostScript and then printed.

I said in a previous post that this is always the case, but I have just tried this on an HP Laserjet 1200 with Lazarus 09.31 and Printer.XDPI is reporting the resolution as 1200 which is the max resolution of the printer. Problem is the normal printing mode is 600 dpi. I could have sworn that previously this printer was reporting 72 dpi. Obviously something must have changed. Sigh... pull hair out.):

OK, my apologies, 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.
Title: Re: Can't print with more than 72 DPI resolution!
Post by: murray on September 07, 2012, 01:22:40 pm
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;
Title: Re: Can't print with more than 72 DPI resolution!
Post by: zeljko on September 23, 2012, 08:46:46 am
That's because printer dpi is hardcoded for carbon (not implemented)
Look in components/printers/carbon/carbonprinters.inc

function TCarbonPrinter.GetXDPI: Integer;
begin
  Result := 72;
end;

function TCarbonPrinter.GetYDPI: Integer;
begin
  Result := 72;
end;
TinyPortal © 2005-2018