Page 1 of 1

PrintPreview GetPrinterOptions

PostPosted: December 13th, 2007, 7:28 pm
by e.schmidtlein
Hi,
I need in my program the PageSize. With 'GetPrinterOptions', the size is correct if the form is in 'Papertype'. If not, the papersize is like 'pA4'.
In 'GetPrinterOptions' I expand the code to

Code: Select all
if (dmFields and DM_PAPERSIZE) = DM_PAPERSIZE then
begin
  SetPaperTypeByID(dmPaperSize);

  if IsCustomPaper then
  begin
    KZ_DrPaper := true;
    DPI.X := GetDeviceCaps(Printer.Handle,LOGPIXELSX);
    DPI.Y := GetDeviceCaps(Printer.Handle,LOGPIXELSY);
    X := GetDeviceCaps(Printer.Handle,PhysicalWidth);
    Y := GetDeviceCaps(Printer.Handle,PhysicalHeight);
    X := ConvertUnits(X,DPI.X,mmPixel,Units);
    Y := ConvertUnits(Y,DPI.Y,mmPixel,Units);
    if Orientation = poPortrait then
      SetPaperSize(X,Y)
    else
      SetPaperSize(Y,X);
  end;
end
else
  SetPaperType(pCustom);
if not KZ_DrPaper then
  if IsCustomPaper then

Now the PageSize is correct. But have you a better way for this problem?
Thanks
e.schmidtlein

PostPosted: December 14th, 2007, 5:02 am
by Kambiz
No, I don't have.
I'll update PrintPreview with your code.

Thank you.