关于打印时缩小比例的问题 (200分)

  • 主题发起人 主题发起人 zh.ys
  • 开始时间 开始时间
Z

zh.ys

Unregistered / Unconfirmed
GUEST, unregistred user!
在我的程序中画里一个表格,在表格的不同位置上用不同的字体写上了不少字,
原先是在A3纸上输出,后想在A4上也输出出来,想用DEVMODE中的dmScale来解决,
但是在打印机上输出的时候,A4纸上打印时没有缩小比例打印,不知道为什么?
部分程序如下:
procedure TA3A4Form.Button2Click(Sender: TObject);
var
ADevice,ADriver,APort:string;
ADeviceMode:THandle;
DevMode:PDeviceMode;
begin
try
SetLength(ADevice,255);
SetLength(ADriver,255);
SetLength(APort,255);
if ADeviceMode=0 then
begin
Printer.PrinterIndex:=Printer.PrinterIndex;
Printer.GetPrinter(Pchar(ADevice),PChar(ADriver),Pchar(APort),ADeviceMode);
end;
if ADeviceMode<>0 then
begin
DevMode:=GlobalLock(ADeviceMode);
try
if A3A4Form.RadioButton1.Checked then
begin
DevMode^.dmFields:=DevMode^.dmFields or DM_PaperSize;
DevMode^.dmPaperSize:=DMPAPER_A3;
end;
if A3A4Form.RadioButton2.Checked then
begin

DevMode^.dmFields:=DevMode^.dmFields or DM_PaperSize;
DevMode^.dmPaperSize:=DMPAPER_A4;
DevMode^.dmFields:=DevMode^.dmFields or DM_SCALE;
DevMode^.dmScale:=70;
end;
finally
Printer.SetPrinter(Pchar(ADevice),PChar(ADriver),Pchar(APort),ADeviceMode);
GlobalUnlock(ADeviceMode);
end;
end;
finally
end;
//----------------------------------------------------------
Printer.PrinterIndex := Printer.PrinterIndex;
//-------------------------------------------------------------------------------
close;
end;

=====================================================================
procedure TForm1.N11Click(Sender: TObject);
begin
PreviewScale:=1;
//------------------------------------------------------------------------------------
Printer.Orientation:=poLandScape;
// PrinterSetupDialog1.Execute;
if MessageDlg('确定要打印吗?',mtConfirmation,[mbYes,mbNo],0) = mrYes then
begin
A3A4Form.showmodal;

try
Printer.begin
Doc;
try
with Printerdo
begin
Canvas.Pen.Width:=2;
Canvas.Pen.Color := clblack;
Canvas.Pen.Mode := pmCopy;
Canvas.Pen.Style :=psSolid;
Canvas.Rectangle(Form1.x1 div PreviewScale,Form1.y1 div PreviewScale,Form1.x23 div PreviewScale,Form1.y36 div PreviewScale);
//--------------------------------------------------------------------------------
Canvas.Font.PixelsPerInch:=Printer.Canvas.Font.PixelsPerInch;
//--------------------------------------------------------------------------------
canvas.Pen.Width:=1;
canvas.Pen.Color:= clblack;
canvas.Pen.Mode:= pmCopy;
canvas.Pen.Style:= pssolid;
//横线----------------------------------------------------------------------------

canvas.MoveTo(Form1.x1 div PreviewScale,form1.y2 div PreviewScale);
canvas.LineTo(Form1.x23 div PreviewScale,form1.y2 div PreviewScale);
....
 
怎么没人回答,问题我没有说清楚吗?很急!!!!!请大侠们多多指教!!!!
 
高人在哪里????????????????????????
 
关注此问题,我试过用Panel打印,改变dmPaperLength,和dmPaperWidth不能改变打印的宽度
我用Panel的ScaleBy方法来缩放字体的大小,结果打印的宽度和高度也变了,而且与打印机的
分辨率有关系,无法满足客户的要求,最后,我好用QuickReport解决。
var
DMode:PDevMode;
h:THandle;
Device,Drive,Port:PChar;
OldLeft:Integer;
begin
if (BalanceDayQuery.FieldByName('BalanceDaySumId').AsInteger=203010) then
begin
MessageDlg('预结单据不能打印!',mtWarning,[mbOK],0);
Exit;
end;
with Printerdo
begin
Device:=StrAlloc(255);
Drive:=StrAlloc(255);
Port:=StrAlloc(255);
GetPrinter(Device,Drive,Port,h);
DMode:=LocalLock(h);
DMode.dmPaperSize:=256;
//DMode.dmPaperLength:=950;
DMode.dmPaperLength:=1050;
//wzx Change
DMode.dmPaperWidth:=2500;
LocalUnLock(h);
SetPrinter(Device,Drive,Port,h);
StrDispose(Device);
StrDispose(Drive);
StrDispose(Port);
begin
Doc;
OldLeft:=Left;
//Left:=2000;
Left:=10000;
try
MainPanel.ScaleBy(250,100);
//MainPanel.PaintTo(Handle,100,20);
MainPanel.PaintTo(Handle,200,100);
MainPanel.ScaleBy(100,250);
finally
Left:=OldLeft;
end;
EndDoc;
end;
 
后退
顶部