Hi;
I want to know how to change page size to A5 format at run time
thank you.
Page format
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
While ScaleRichView can automatically set paper size when printing, TRichView uses the paper format specified for the printer.
So, if you want to print on A5 paper, you need to set this format to the printer before printing.
This code shows how to do it:
Call
After that, you can print using TRVPrint component: call AssignSource, FormatPages, Print methods.
So, if you want to print on A5 paper, you need to set this format to the printer before printing.
This code shows how to do it:
Code: Select all
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;
Code: Select all
SetPaperSize(DMPAPER_A5)