D
dadabox
Unregistered / Unconfirmed
GUEST, unregistred user!
小弟很急呀﹐請各位大俠出手相救﹗﹗﹗﹗﹗(分數不夠可以再加﹐先放100分﹗﹗)
我在QuickRep中設定好了紙張大小﹐Page.PaperSize設為custom﹐但打出來分頁還是有問題。
紙張大小設定為高89mm,寬85mm,左右邊距18mm,上下邊距3mm,每頁紙中有3張標簽﹐高26mm,
寬58mm。用QuickRep打印﹐換頁時往下跑許多﹐根本沒有按我設定的大小換﹐而用printer﹐
自己來定位﹐自己用newpage換頁﹐則沒有問題。但我想用quickrep﹐不想自己寫。哪位能
告訴我怎么做﹐不要說什么不要用quickrep﹐這是廢話。我現在沒法子改了﹐只好用他﹐什
么都寫完了﹐只有控制打印就行了。還有一點﹐我想每次打印前都復一下位﹐讓紙自己走紙
到指定位置﹐免得人工手動調誤差大﹐怎么樣﹖要發什么指令﹖如果程序做不到﹐告訴我怎
么手動調打印機也行。
打印機﹕EPSON LQ-2180,軟件環境:Win200+D6﹔
用下面的方法可以調整紙張大小﹐但用在QuickRep還是沒用﹐下面問題處有注解。
var
RateX, RateY: Integer;
function InitPrinter: Boolean;
begin
Result := Printer.Printers.Count > 0;
RateX := MulDiv(GetDeviceCaps(Printer.Handle, LOGPIXELSX), 1000, 254);
RateY := MulDiv(GetDeviceCaps(Printer.Handle, LOGPIXELSY), 1000, 254);
end;
procedure SetPaperSize(X, Y: Integer);
var
Device, Driver, Port: PChar;
HDMode: THandle;
PDMode: PDevMode;
begin
Device := StrAlloc(cchDeviceName);
Driver := StrAlloc(MAX_PATH);
Port := StrAlloc(32);
try
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device, Driver, Port, HDMode);
if HDMode <> 0 then
begin
PDMode := GlobalLock(HDMode);
if PDMode <> nil then
begin
with PDMode^do
begin
dmPaperSize := 256;
dmPaperWidth := X;
dmPaperLength := Y;
dmFields := dmFields or DM_PAPERSIZE or DM_PAPERWIDTH or DM_PAPERLENGTH;
GlobalUnlock(HDMode);
end;
Printer.PrinterIndex := Printer.PrinterIndex;
end;
end;
finally
StrDispose(Device);
StrDispose(Driver);
StrDispose(Port);
end;
end;
function TransformX(X: Integer): Integer;
begin
Result := MulDiv(X, RateX, 1000);
end;
function TransformY(Y: Integer): Integer;
begin
Result := MulDiv(Y, RateY, 1000);
end;
procedure TransformPoint(Point: TPoint);
begin
Point.x := TransformX(Point.x);
Point.y := TransformY(Point.y);
end;
procedure TransformRect(Rect: TRect);
begin
Rect.Left := TransformX(Rect.Left);
Rect.Right := TransformX(Rect.Right);
Rect.Top := TransformY(Rect.Top);
Rect.Bottom := TransformY(Rect.Bottom);
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
if not InitPrinter then
Application.MessageBox('', '', mb_IconError + mb_OK)
else
begin
SetPaperSize(890, 850);
Form1.QuickRep1.Preview;//用QuickRep打﹐在預覽中似乎正常﹐但在換紙時還是往下跑了許多
{ with printerdo
//用printer的方法﹐自己來定義﹐自己newpage就沒問題﹐能精確控制。
begin
begin
doc;
Canvas.TextOut(10,10,'Test');
NewPage;
Canvas.TextOut(10,10,'Test');
EndDoc;}
end;
end;
我在QuickRep中設定好了紙張大小﹐Page.PaperSize設為custom﹐但打出來分頁還是有問題。
紙張大小設定為高89mm,寬85mm,左右邊距18mm,上下邊距3mm,每頁紙中有3張標簽﹐高26mm,
寬58mm。用QuickRep打印﹐換頁時往下跑許多﹐根本沒有按我設定的大小換﹐而用printer﹐
自己來定位﹐自己用newpage換頁﹐則沒有問題。但我想用quickrep﹐不想自己寫。哪位能
告訴我怎么做﹐不要說什么不要用quickrep﹐這是廢話。我現在沒法子改了﹐只好用他﹐什
么都寫完了﹐只有控制打印就行了。還有一點﹐我想每次打印前都復一下位﹐讓紙自己走紙
到指定位置﹐免得人工手動調誤差大﹐怎么樣﹖要發什么指令﹖如果程序做不到﹐告訴我怎
么手動調打印機也行。
打印機﹕EPSON LQ-2180,軟件環境:Win200+D6﹔
用下面的方法可以調整紙張大小﹐但用在QuickRep還是沒用﹐下面問題處有注解。
var
RateX, RateY: Integer;
function InitPrinter: Boolean;
begin
Result := Printer.Printers.Count > 0;
RateX := MulDiv(GetDeviceCaps(Printer.Handle, LOGPIXELSX), 1000, 254);
RateY := MulDiv(GetDeviceCaps(Printer.Handle, LOGPIXELSY), 1000, 254);
end;
procedure SetPaperSize(X, Y: Integer);
var
Device, Driver, Port: PChar;
HDMode: THandle;
PDMode: PDevMode;
begin
Device := StrAlloc(cchDeviceName);
Driver := StrAlloc(MAX_PATH);
Port := StrAlloc(32);
try
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device, Driver, Port, HDMode);
if HDMode <> 0 then
begin
PDMode := GlobalLock(HDMode);
if PDMode <> nil then
begin
with PDMode^do
begin
dmPaperSize := 256;
dmPaperWidth := X;
dmPaperLength := Y;
dmFields := dmFields or DM_PAPERSIZE or DM_PAPERWIDTH or DM_PAPERLENGTH;
GlobalUnlock(HDMode);
end;
Printer.PrinterIndex := Printer.PrinterIndex;
end;
end;
finally
StrDispose(Device);
StrDispose(Driver);
StrDispose(Port);
end;
end;
function TransformX(X: Integer): Integer;
begin
Result := MulDiv(X, RateX, 1000);
end;
function TransformY(Y: Integer): Integer;
begin
Result := MulDiv(Y, RateY, 1000);
end;
procedure TransformPoint(Point: TPoint);
begin
Point.x := TransformX(Point.x);
Point.y := TransformY(Point.y);
end;
procedure TransformRect(Rect: TRect);
begin
Rect.Left := TransformX(Rect.Left);
Rect.Right := TransformX(Rect.Right);
Rect.Top := TransformY(Rect.Top);
Rect.Bottom := TransformY(Rect.Bottom);
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
if not InitPrinter then
Application.MessageBox('', '', mb_IconError + mb_OK)
else
begin
SetPaperSize(890, 850);
Form1.QuickRep1.Preview;//用QuickRep打﹐在預覽中似乎正常﹐但在換紙時還是往下跑了許多
{ with printerdo
//用printer的方法﹐自己來定義﹐自己newpage就沒問題﹐能精確控制。
begin
begin
doc;
Canvas.TextOut(10,10,'Test');
NewPage;
Canvas.TextOut(10,10,'Test');
EndDoc;}
end;
end;