Objeto Printer

Delphi

05/02/2003

Alguem sabe como controlar o tamanho do papel usando o objeto TPrinter?


Julio Pontes

Julio Pontes

Curtidas 0

Respostas

Magoo

Magoo

05/02/2003

Uses Windows, . . . Printers;

procedure MudaTamPapel(PaperSize, Comp, Alt: integer);
var
ADevice, ADriver, APort: array[0..255] of char;
DeviceMode: THandle;
M: PDevMode;
s: string;
begin
S := Printer.Printers[Printer.PrinterIndex];
Printer.GetPrinter(ADevice, ADriver, APort, DeviceMode);
M := GlobalLock(DeviceMode);
try
if M <> nil then
begin
M^.dmFields := DM_PAPERSIZE;
if PaperSize = DMPAPER_USER then
M^.dmFields := M^.dmFields or DM_PAPERLENGTH or DM_PAPERWIDTH;
M^.dmPaperLength := Alt;
M^.dmPaperWidth := Comp;
M^.dmPaperSize := PaperSize;
Printer.SetPrinter(ADevice, ADriver, APort, DeviceMode);
end;
finally
GlobalUnlock(DeviceMode);
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
//-->> DEFINE O TAMANHO DO PAPEL
//----------------------- (COMP 25,00 cm - ALTURA 14,00 cm)
MudaTamPapel(DMPAPER_USER,2500,1400);
// Aqui você chama a Impressão . . . . . . . . .
//-->> VOLTA TAMANHO NORMAL
MudaTamPapel(DMPAPER_LETTER, 0, 0);
end;


GOSTEI 0
POSTAR