首先可以把你的QR升级到3.0以上的版本,这样用自定义纸张大小才有用。
也可以自己用API函数定义纸张大小,如下
只要传入你要的纸张长度和宽度就可以了)
procedure SetCustomPaper(paperlength:integer;paperwidth:integer);
var
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port : array[0..255] of char;
hDMode : THandle;
PDMode : PDEVMODE;
begin
//Printer.PrinterIndex := Printer.PrinterIndex;
{Printer.GetPrinter(Device, Driver, Port, hDMode);
if hDMode <> 0 then
begin
pDMode := GlobalLock(hDMode);
if pDMode <> nil then
begin
pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
pDMode^.dmPaperSize := DMPAPER_LEGAL;
pDMode^.dmFields := pDMode^.dmFields or
DM_PAPERSIZE or
DM_PAPERWIDTH or
DM_PAPERLENGTH;
pDMode^.dmPaperSize := DMPAPER_USER;
pDMode^.dmPaperWidth := 2794;//2160 ;
pDMode^.dmPaperLength := 1420;//380 ;
ResetDC(Printer.Handle,pDMode^);
GlobalUnlock(hDMode);
end;
end;
}
// Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device,Driver,Port,hDMode);
if (paperlength >= 0) and (paperwidth >= 0) then
begin
if hDMode <> 0 then
begin
pDMode := GlobalLock(hDMode);
if pDMode <> nil then
begin
pDMode^.dmPaperSize := 256;
pDMode^.dmPaperLength := paperlength;
pDMode^.dmPaperWidth := paperwidth;
pDMode^.dmFields := pDMode^.dmFields or DM_PAPERSIZE;
pDMode^.dmFields := pDMode^.dmFields or DM_PAPERLENGTH;
pDMode^.dmFields := pDMode^.dmFields or DM_PAPERWIDTH;
ResetDC(Printer.Handle,pDMode^);
GlobalUnlock(hDMode);
end;
end;
end;
end;