Salve, ho un serio problema con la stampa di un semplice documento in Delphi.
Dopo aver dichiarato Printers in Uses, il codice da me utilizzato è il seguente:
codice:
procedure TfrmOrdine.btnStampaClick(Sender: TObject);
var
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port : array[0..255] of char;
hDMode : THandle;
PDMode : PDEVMODE;
begin
If Application.MessageBox('Si vuole stampare il documento?', 'Conferma operazione di stampa', MB_YESNO) = 7 Then
begin
Exit;
end;
with Printer do begin
PrinterIndex := PrinterIndex;
GetPrinter(Device, Driver, Port, hDMode);
if hDMode <> 0 then begin
pDMode := GlobalLock(hDMode);
if pDMode <> nil then begin
pDMode.dmFields := pDMode.dmFields or dm_Color;
pDMode.dmColor := DMCOLOR_COLOR;
GlobalUnlock(hDMode);
end;
end;
PrinterIndex := PrinterIndex;
Orientation := poPortrait;
BeginDoc;
Screen.Cursor := crHourGlass;
Canvas.Font.Color := clBlack;
Canvas.Font.Name := 'Verdana';
Canvas.Font.Size := 14;
// Caratteri non in grassetto
Canvas.Font.Style := Canvas.Font.Style - [fsBold];
// Caratteri non sottolineati
Canvas.Font.Style := Canvas.Font.Style - [fsUnderline];
SetTextAlign(printer.canvas.handle, TA_LEFT);
Canvas.TextOut(150, 100, '____________________________________________________________' );
Canvas.TextOut(1000, 400, 'TITOLO DOCUMENTO');
Canvas.TextOut(150, 550, '____________________________________________________________' );
Canvas.Font.Size := 10;
Canvas.TextOut(350, 850, 'Primo rigo' );
Canvas.TextOut(150, 1050, 'Secondo rigo' );
EndDoc;
Screen.Cursor := crDefault;
end;
end;
Il problema è che su alcune macchine (o stampanti) la spaziatura dell'interlinea fra la riga 1 e la riga 2 è tripla rispetto a ciò che si ottiene su altri PC. Devo forse dichiarare l'unità di misura prima di mandare in stampa il documento? Se sì, in che modo si fa?
Grazie in anticipo.