trichview.com

trichview.support




Re: RichViewEdit and paper size


Return to index


Author

Message

Sergey Tkachenko

Posted: 02/24/2005 23:25:01


uses Printers;


procedure SetPaperSize(PaperSize: Integer);

  var ADevice, ADriver, APort: array[0..79] of Char;

      ADeviceMode: THandle;

      DevMode: PDeviceMode;

  begin

    Printer.GetPrinter(ADevice,ADriver,APort,ADeviceMode);

    if ADeviceMode<>0 then begin

      DevMode := PDeviceMode(GlobalLock(ADeviceMode))

      end

    else

      raise Exception.Create('Error initializing printer');

    DevMode.dmFields := DevMode.dmFields or DM_PAPERSIZE;

    DevMode.dmPaperSize := PaperSize;

    GlobalUnlock(ADeviceMode);

    Printer.SetPrinter(ADevice,ADriver,APort,ADeviceMode);

  end;


You can find a list of available paper sizes in Windows API Help (Delphi

menu: Help | Windows SDK).

Search DEVMODE in the help index, then search for DMPAPER_*** constants.


For example,  SetPaperSize(DMPAPER_A4)


Do not forget to call RVPrint.FormatPages after any change in paper sizes.


You can get the current printer's paper size:


function GetPaperSize: Integer;

var ADevice, ADriver, APort: array[0..79] of Char;

    ADeviceMode: THandle;

    DevMode: PDeviceMode;

begin

  Printer.GetPrinter(ADevice,ADriver,APort,ADeviceMode);

  if ADeviceMode<>0 then begin

    DevMode := PDeviceMode(GlobalLock(ADeviceMode))

    end

  else

    raise Exception.Create('Error initializing printer');

  Result := DevMode.dmPaperSize;

end;


You can see how to get a list of available paper sizes and their names in

the RichViewActions source code (in page setup form)


> Hello,

>

> Thanks in advance.

> Is it possible to set printer paper size to RichViewEdit size or Vise

versa

> Example set RichViewEdit1 size to A4 or A3 or legal size.

>

> I know paper size set by printer, I would like to limit users input to

> printer paper size.

>

>

> Thanks

>

>

>





Powered by ABC Amber Outlook Express Converter