////////////////////////////
//武汉探索电脑工作室//
//http://tansuo.51.net//
////////////////////////////
//增加规格自定义纸张
//PaperName:自定义纸张名称
//PaperWidth:纸张的宽度,以0.1mm为单位
//PaperLength:纸张的高度,以0.1mm为单位
PRocedureTDM.AddCustomPaper(constPaperName:string;PaperWidth,PaperLength:integer);
var
PrintDevice,PrintDriver,PrintPort:array[0..255]ofChar;
hDMode:THandle;
hPrinter:THandle;
FormInfo:TFormInfo1;
begin
Printer.GetPrinter(PrintDevice,PrintDriver,PrintPort,hDMode);
OpenPrinter(PrintDevice,hPrinter,nil);
ifhPrinter=0then
raiseException.Create('联接打印机失败!');
withFormInfodo
begin
Flags:=FORM_USER;
pName:=PChar(PaperName);
Size.cx:=PaperWidth*100;
Size.cy:=PaperLength*100;
ImageableArea.Left:=0;
ImageableArea.Top:=0;
ImageableArea.Right:=PaperWidth*100;
ImageableArea.Bottom:=PaperLength*100;
end;
//修改纸型,如果没有就新增
ifnotSetForm(hPrinter,PChar(PaperName),1,@FormInfo)then
AddForm(hPrinter,1,@FormInfo);
ClosePrinter(hPrinter);
end;
//删除自定义规格纸张
//PaperName:自定义纸张名称
procedureTDM.DeleteCustomPaper(constPaperName:string);
var
PrintDevice,PrintDriver,PrintPort:array[0..255]ofChar;
hDMode:THandle;
hPrinter:THandle;
begin
Printer.GetPrinter(PrintDevice,PrintDriver,PrintPort,hDMode);
OpenPrinter(PrintDevice,hPrinter,nil);
ifhPrinter=0then
raiseException.Create('联接打印机失败!');
DeleteForm(hPrinter,PChar(PaperName));
ClosePrinter(hPrinter);
end;