trichview.com

trichview.support




Re: How to set paper size?


Return to index


Author

Message

Sergey Tkachenko

Posted: 06/04/2003 19:00:27


RichView uses application-global printing settings.


Procedures below allow set/get paper size.

Constants for paper sizes are in Windows.pas, DMPAPER_***

For example,

  DMPAPER_A4      = 9;

  DMPAPER_A3      = 8;


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;


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;


New version of RichViewActions - http://www.trichview.com/resources/actions/

has page setup dialog.







Powered by ABC Amber Outlook Express Converter