0

I am trying to allow the user to select an appropriate paper size for their printer within my own print settings dialog. Does anyone know a workable solution - preferably cross platform but otherwise OSX.

If I use a TPageSetupDialog then when executed it produces an error in the PASever window of Invalidpmobject although the dialog shows but doesn't seem to affect the current printers paper size. There doesn't seem to be any proerties to see what the user selected either.

I need to set the paper size without actually printing as the user needs to be able to adjust things with the new paper size first.

David Peters
  • 220
  • 1
  • 10

1 Answers1

0

I finally figured out the problem so here is the solution for anyone else with the problem:

Use TPageSetupDialog but you must set valid pagewidth and pageheight values for the current printer before calling it - otherwise you get an error reported in PAServer window and the printer selection box will be set to "any printer" instead of the current printer name.

Unfortunately you cannot derive the paper size directly from the printer pagewidth and resolution because it reports printable area not paper size. So I set a default of A4 whenever the user chooses another printer. I guess you could set the nearest standard paper size to the calculated value from printer.pagewidth/printer.activeprinter.activedpi.x if you want to take care of printers that do not support A4.

The other point to note is that the default page sizes in the TPageSetupDialog component are wrong. Set the units to mm and use width 210000 and height 297000 (note 10 times bigger than the default values) for A4 size that most printers should support.

David Peters
  • 220
  • 1
  • 10