View Issue Details

IDProjectCategoryView StatusLast Update
0023339LazarusPrinterpublic2014-01-08 18:34
ReporterAnton Kavalenka Assigned ToJesus Reyes  
Status closedResolutionfixed 
Product Version1.1 (SVN) 
Target Version1.2.0Fixed in Version1.3 (SVN) 
Summary0023339: Carbon: Printer resolution is 72 dpi - high resolution graphics is not possible
DescriptionSame problem was already fixed for CUPS printing.
TPrinter.get(X|Y)Res have to return actual printer resolution.

LCL device contexts work in pixels. So the printer context size should be PageSize (in inch) * PixelsPerInch
TagsNo tags attached.
Fixed in Revision43141
Attached Files


Anton Kavalenka

2012-11-18 17:20

reporter   ~0063887

Btw the conditional define -dNativePrint is ON by default in package source.
This forces 72-dpi Carbon printing.

Thomas Frey

2013-09-25 08:58

reporter   ~0070307

I suggest the following workaround in carbonprinters.h: define the default dpi to be 600 instead of 72 (or 1200 replace the 600s in the diff with 1200 for that).
CGContextScaleCTM is called anyways to fix the coordinate system. It can also take a scale factor that is then applied to the resolution of the actual printer.

So the change would be the following (pasting the complete changed methods even though the diff is in total 3 lines.):

procedure TCarbonPrinterContext.Reset;
  inherited Reset;
  if CGContext <> nil then
    // flip and offset CTM from lower to upper left corner
    CGContextTranslateCTM(CGContext, 0, GetSize.Y);
    CGContextScaleCTM(CGContext, 72/600.0, -72/600.0);

function TCarbonPrinter.GetXDPI: Integer;
  Result := 600;

function TCarbonPrinter.GetYDPI: Integer;
  Result := 600;

Jesus Reyes

2013-10-07 07:38

developer   ~0070598

For the moment, I have fixed the problem that prevented printing at higher resolutions even when user selected some value in Print Dialog, that should fix this bug.

Printing by *default* at higher resolution other than 72 without interactively using the Print Dialog presents the problem of knowing what is the *default printer resolution*. In my mac, for the couple of printers I have registered, 300 dpi is the default resolution, as far as I could find in the Print Dialog. However, there is no documented function in Carbon to retrieve that value, or at least, I was not able to find it.

Returning 300 (or 600 or 1200) dpi as default for any printer doesn't feel right, it should be some printer supported resolution, and if it is the printer default resolution it would be even better.

Anton Kavalenka

2013-10-08 21:06

reporter   ~0070677

Strange, my MacOSX printer still reports 72 dpi (1200 dpi hp1320 on Linux CUPS)
Vector drawing still "ladder-looking".

All PS output in any way done in inches (floating point). The bigger canvas resolution in virtual "pixels" - the better PS output. IMO it can be fixed at 1200. Let the printer make real translation.

Jesus Reyes

2013-10-08 21:16

developer   ~0070678

Did you make sure you selected the desired resolution in Print Dialog -> Print Settings? Note, is not enough the if the resolution is checked, you have to manually select it even if it's already selected.

if you use the Lazarus/components/printers/samples/dialogs project to print a sample, using the "print with dialog" button, after printing what reports in the printer info grid?

Anton Kavalenka

2013-10-08 21:44

reporter   ~0070680

I just made simple test with a button, a printdialog and a label

Anton Kavalenka

2013-10-08 21:44

reporter (208,248 bytes)

Jesus Reyes

2013-10-08 21:56

developer   ~0070682

Seems to have nothing to do with problem?

what revision are you using?

Anton Kavalenka

2013-10-08 22:04

reporter   ~0070683


Jesus Reyes

2013-10-08 22:08

developer   ~0070684

Revision is ok, however your test does nothing to do with problem, seems trayicon related or something.

Anton Kavalenka

2013-10-11 19:28

reporter   ~0070750

Last edited: 2013-10-11 19:49

View 4 revisions

Maybe we are not understanding each other.
function TCarbonPrinter.GetOutputResolution: PMResolution;
  res: OSStatus;
  res := PMPrinterGetPrinterResolutionCount(GetCurrentPrinter, cnt);
  if res=noErr then
  writeln('error geting rescnt');

  res := PMPrinterGetOutputResolution(GetCurrentPrinter, PrintSettings, Result{%H-});
  if res<>noErr then begin
    writeln('Error gettin res');

On my system it reports rescnt=1 (printer has 1 resolution) and then falls in branch res<>noErr and reports 72 dpi

may printsettings contain something unacceptable for OS?

Anton Kavalenka

2013-10-11 19:28


Anton Kavalenka

2013-10-11 20:03

reporter   ~0070752

Last edited: 2013-10-11 20:04

View 3 revisions

And this is still not changed like in suggestion of Thomas Frey
procedure TCarbonPrinterContext.Reset;
  inherited Reset;
  if CGContext <> nil then
    // flip and offset CTM from lower to upper left corner
    CGContextTranslateCTM(CGContext, 0, GetSize.Y);
    CGContextScaleCTM(CGContext, 1, -1);

Jesus Reyes

2013-10-11 20:57

developer   ~0070756

Last edited: 2013-10-11 21:04

View 2 revisions

Yes, there is a communication problem, I asked:
"Did you make sure you selected the desired resolution in Print Dialog -> Print Settings?"

you have not answered yes or not.

This note is VERY important:
"Note, is not enough the if the resolution is checked, you have to manually select it even if it's already selected."

However you have not confirmed that you manually selected the resolution. Without this, it simply won't work. I say it because I tried it.

You have not tried the example supplied with Lazarus (or I missed the comment :)) which reports the selected resolution ONCE it has printed something with MANUALLY selecting the resolution.

If you only show the dialog and print and don't select the resolution, it won't work. Even if the printer only supports one resolution. I cannot stress enough how important is this. In short, you printer won't automatically use it's default resolution, if you do not INTERACTIVELY or MANUALLY select it.

The sample you supplied, does nothing but create confusion, you said nothing about it (I may be wrong, though, so I asked explanation).

The image you attached do not show the "Print Settings" pane where it should list the only resolution you said the printer support. And I don't know what the "Last Used settings" preset contains, it could effectively invalidate the selected resolution.

We can discuss how to solve making the printer to use, by default, it's only supported resolution, there is one mechanism for that, but it won't work if using the dialog manually selecting the resolution it self do not work.

You said "may printsettings contain something unacceptable for OS?" PMPrinterGetOutputResolution will only work if the user has manually selected the desired resolution at the moment the user clicked the "Print" button in print dialog because it's the only moment a missing key is added to print settings.

Anton Kavalenka

2013-10-11 21:48


Anton Kavalenka

2013-10-11 21:52

reporter   ~0070759

ok, I'm lost with "user-friendly-os-full-o-wow-effects"
Where should i select resolution -
Printer setup dialog rises exception (see last picture).

Jesus Reyes

2013-10-11 22:10

developer   ~0070760

That's because TPrinterSetupDialog is not supported in Mac Os X. If you have an updated lazarus, the sample has a "Print with Dialog" button, just click it. In the Print Dialog select "Print Settings" and change the resolution.

Again, see note 0070678.

Vincent Snijders

2013-11-09 21:55

manager   ~0071233

PMPrinterGetOutputResolution does not seem to exist in Mac OS X 10.3 for powerpc.

Anton Kavalenka

2013-12-17 19:17

reporter   ~0071937

Thank you.

Recently I fought my printer. What I learned - Generic PS printer does not report anything about resolution. I've managed to install HP drivers.

See the PDF.

Issue can be closed now.

Anton Kavalenka

2013-12-17 19:18


uc-test.pdf (85,311 bytes)

Jesus Reyes

2014-01-08 10:36

developer   ~0072302

I don't know the reason why sometimes even if the printer supports a number of resolutions the mac dialogs do not show a control to select one. It seems if the ppd describe just a default resolution and not a range of resolutions, the printer dialogs will not show the value of default resolution and assume a default 72 dpi :(.

I don't know if this is a defect on ppd file or problem on mac printer dialogs interpreting such ppd file. A solution for this could be adding a property to set a desired resolution, it's not done because printers usually do not print at an arbitrary resolution... But this is for another report....

Issue History

Date Modified Username Field Change
2012-11-17 10:26 Anton Kavalenka New Issue
2012-11-17 10:26 Anton Kavalenka Widgetset => Carbon
2012-11-18 17:20 Anton Kavalenka Note Added: 0063887
2013-09-25 08:58 Thomas Frey Note Added: 0070307
2013-09-26 14:27 Jesus Reyes Assigned To => Jesus Reyes
2013-09-26 14:27 Jesus Reyes Status new => assigned
2013-10-07 07:38 Jesus Reyes Fixed in Revision => 43141
2013-10-07 07:38 Jesus Reyes LazTarget => 1.2
2013-10-07 07:38 Jesus Reyes Note Added: 0070598
2013-10-07 07:38 Jesus Reyes Status assigned => resolved
2013-10-07 07:38 Jesus Reyes Fixed in Version => 1.3 (SVN)
2013-10-07 07:38 Jesus Reyes Resolution open => fixed
2013-10-07 07:38 Jesus Reyes Target Version => 1.2.0
2013-10-08 21:06 Anton Kavalenka Note Added: 0070677
2013-10-08 21:16 Jesus Reyes Note Added: 0070678
2013-10-08 21:41 Anton Kavalenka Status resolved => assigned
2013-10-08 21:41 Anton Kavalenka Resolution fixed => reopened
2013-10-08 21:44 Anton Kavalenka Note Added: 0070680
2013-10-08 21:44 Anton Kavalenka File Added:
2013-10-08 21:56 Jesus Reyes Note Added: 0070682
2013-10-08 22:04 Anton Kavalenka Note Added: 0070683
2013-10-08 22:08 Jesus Reyes Note Added: 0070684
2013-10-09 07:37 Jesus Reyes Status assigned => feedback
2013-10-11 19:28 Anton Kavalenka Note Added: 0070750
2013-10-11 19:28 Anton Kavalenka Status feedback => assigned
2013-10-11 19:28 Anton Kavalenka File Added: Экранны здымак з 2013-10-11 19:57:33.png
2013-10-11 19:49 Anton Kavalenka Note Edited: 0070750 View Revisions
2013-10-11 19:49 Anton Kavalenka Note Edited: 0070750 View Revisions
2013-10-11 19:49 Anton Kavalenka Note Edited: 0070750 View Revisions
2013-10-11 20:03 Anton Kavalenka Note Added: 0070752
2013-10-11 20:03 Anton Kavalenka Note Edited: 0070752 View Revisions
2013-10-11 20:04 Anton Kavalenka Note Edited: 0070752 View Revisions
2013-10-11 20:57 Jesus Reyes Note Added: 0070756
2013-10-11 21:04 Jesus Reyes Note Edited: 0070756 View Revisions
2013-10-11 21:48 Anton Kavalenka File Added: Экранны здымак з 2013-10-11 22:48:11.png
2013-10-11 21:52 Anton Kavalenka Note Added: 0070759
2013-10-11 22:10 Jesus Reyes Note Added: 0070760
2013-11-09 21:55 Vincent Snijders Note Added: 0071233
2013-12-17 19:17 Anton Kavalenka Note Added: 0071937
2013-12-17 19:18 Anton Kavalenka File Added: uc-test.pdf
2014-01-08 10:36 Jesus Reyes Note Added: 0072302
2014-01-08 10:36 Jesus Reyes Status assigned => resolved
2014-01-08 10:36 Jesus Reyes Resolution reopened => fixed
2014-01-08 18:34 Anton Kavalenka Status resolved => closed