xp下特种打印的问题! ( 积分: 200 )

  • 主题发起人 主题发起人 the_lover
  • 开始时间 开始时间
T

the_lover

Unregistered / Unconfirmed
GUEST, unregistred user!
我的程序用quickrep打印的,我将其pagesize设成Custom 然后自己写了他的高度和宽度,
在98下他打印就打印我设成高度的页面然后就不走纸了,这也是我想要的结果,但是在XP下他在打印完我设定的内容后还走纸走了很久,估计是一张A4纸的高度,那位高手可以告诉我XP下这种特种票据的打印应该怎么做?
 
电脑上设置自定义纸张,并作为打印机默认纸张,软件中不用设置纸张大小。
 
你可以这样测试,如果单一纸张类型,可能可以解决。另外,我遇到过因为驱动的原因造成的。测试看看。
 
<>98,XP,2000下添加自定义纸张并修改打印机为该类型(设置是临时性的)
uses printers,WinSpool;
{$R *.dfm}
procedure UpdatePrint(Awidth,Aheight:integer;papername:String);//宽度(单位:0.01mm),高度,纸张名称
function Win95SetForm(PDevMode: PDeviceMode): Boolean;
begin
Printer.PrinterIndex := Printer.PrinterIndex;
PDevMode.dmFields := PDevMode.dmFields or DM_PAPERSIZE;
PDevMode.dmPaperSize := 256;
PDevMode.dmFields := PDevMode.dmFields or DM_PAPERWIDTH;
PDevMode.dmPaperWidth := AWidth;
PDevMode.dmFields := PDevMode.dmFields or DM_PAPERLENGTH;
PDevMode.dmPaperLength := AHeight;
Printer.PrinterIndex := Printer.PrinterIndex;
Result := True;
end;

function WinNTSetForm(PDevMode: PDeviceMode;
Device: PChar;
Port: PChar): Boolean;
var
hPrinter: THandle;
pForm: Pointer;
cbNeeded: DWORD;
cReturned: DWORD;
FormInfo1: TFormInfo1;
begin
Result := False;
if OpenPrinter(Device, hPrinter, nil) then
begin
pForm := nil;
EnumForms(hPrinter, 1, pForm, 0, cbNeeded, cReturned);
GetMem(pForm, cbNeeded);
//取pForm的大小并分配内存
try
if EnumForms(hPrinter, 1, pForm, cbNeeded, cbNeeded, cReturned) then
begin
if DeleteForm(hPrinter, PChar(papername)) then
Dec(cReturned);
//删除旧的Form
with FormInfo1do
begin
Flags := 0;
pName := PChar(papername);
Size.cx := AWidth * 100;
Size.cy := AHeight * 100;
with ImageAbleAreado
begin
Left := 0;
Top := 0;
Right := Size.cx;
Bottom := Size.cy;
end;
end;
if AddForm(hPrinter, 1, @FormInfo1) then
begin
Printer.PrinterIndex := Printer.PrinterIndex;
PDevMode.dmFields := PDevMode.dmFields or DM_PAPERSIZE;
PDevMode.dmPaperSize := cReturned + 1;
Printer.PrinterIndex := Printer.PrinterIndex;
Result := True;
end;
end;
finally
FreeMem(pForm);
end;
end;
end;
var
Device, Driver, Port: array[0..127] of char;
hDevMode: THandle;
PDevMode: PDeviceMode;
begin
Printer.GetPrinter(Device, Driver, Port, hDevMode);
if hDevMode <> 0 then
begin
PDevMode := GlobalLock(hDevMode);
try
if (Win32Platform = VER_PLATFORM_WIN32s) or
(Win32Platform = VER_PLATFORM_WIN32_WINDOWS) then
Win95SetForm(PDevMode)
else
if Win32Platform = VER_PLATFORM_WIN32_NT then
WinNTSetForm(PDevMode, Device, Port);
finally
GlobalUnlock(hDevMode);
end;
end
end;
 
在xp的打印机设置这个窗口的空白处点右键,选择服务器属性,添加打印纸,然后在你的默认打印机这里设置成你刚刚设定出来的纸张就可以了。。
我测试成功。
 
多人接受答案了。
 
后退
顶部