默认只能打印显示的数据
参照这个改一下,生成IMAGE然后打印
uses richedit;
procedure TForm1.Button1Click(Sender: TObject);
var
Range : TFormatRange;
LastChar, MaxLen, LogX, LogY: Integer;
begin
FillChar(Range, SizeOf(TFormatRange), 0);
with Image1, Range do
begin
LogX := GetDeviceCaps(Canvas.Handle, LOGPIXELSX);
LogY := GetDeviceCaps(Canvas.Handle, LOGPIXELSY);
hdc := Canvas.Handle;
hdcTarget := hdc;
rc.right := Image1.ClientWidth * 1440 div LogX;
rc.bottom := Image1.ClientHeight * 1440 div LogY;
rcPage := rc;
LastChar := 0;
MaxLen := GetTextLen;
chrg.cpMax := -1;
repeat
chrg.cpMin := LastChar;
LastChar := SendMessage(RichEdit1.Handle, EM_FORMATRANGE, 1,
Longint(@Range));
until (LastChar >= MaxLen) or (LastChar = -1);
end;
SendMessage(RichEdit1.Handle, EM_FORMATRANGE, 0, 0);
Image1.Refresh;
end;