http://mc-computing.com/languages/delphi/Printing.html
http://www.massmind.org/Techref/language/delphi/swag/DELPHI0091.html
http://www.delphigroups.info/2/b5/135338.html
https://stackoverflow.com/questions/3864060/printer-print-size
https://groups.google.com/forum/#!topic/borland.public.delphi.ide/XoxgHS96yv4
http://box.cs.istu.ru/public/docs/other/_New/Books/Lang/Delphi/Delphi%20Developer's%20Guide/Ebooks/d5dg/chapter10.pdf
https://community.embarcadero.com/article/technical-articles/162-programming/12185-changing-the-papersize-of-a-print-job
https://www.tek-tips.com/viewthread.cfm?qid=193081
//----------------------------
I want to print data on a pre-printed paper. it's length is 4.25". so I coded like this
Printer.GetPrinter(Adevice,Adriver,Aport,DeviceHandle);
PixelsInInchX:=GetDeviceCaps(Printer.Handle,LOGPIXELSX);
PixelsInInchY:=GetDeviceCaps(Printer.Handle, LOGPIXELSY);
DevMode:=globallock(DeviceHandle);
with DevMode^ do
begin
dmFields := DM_PAPERSIZE or DM_DEFAULTSOURCE or
DM_PAPERWIDTH or DM_PAPERLENGTH;
dmpapersize:=DMPAPER_USER;
dmPaperWidth :=(PixelsInInchX*8.5);
dmPaperLength:=(PixelsInInchY*4.25); //}1101;
end;
printer.SetPrinter(Adevice,Adriver,Aport,DeviceHandle);
But when I run the program the paper length is 612(dmpaperLength returns 612). So I just try to put values and I got my paper size when I put dmPaperLength with 1100 or 1101. The big problem is I want the value between these two values as 1100.5, but I can't put that value because dmPaperLength is an integer type.
It is a pre-printed paper so I must have that size and I want to use that paper in dotmatrix printer.after I print in one page if I don't give my length as correct value the next page data will not be in proper place.
Any body have any idea??
http://www.massmind.org/Techref/language/delphi/swag/DELPHI0091.html
http://www.delphigroups.info/2/b5/135338.html
https://stackoverflow.com/questions/3864060/printer-print-size
https://groups.google.com/forum/#!topic/borland.public.delphi.ide/XoxgHS96yv4
http://box.cs.istu.ru/public/docs/other/_New/Books/Lang/Delphi/Delphi%20Developer's%20Guide/Ebooks/d5dg/chapter10.pdf
https://community.embarcadero.com/article/technical-articles/162-programming/12185-changing-the-papersize-of-a-print-job
https://www.tek-tips.com/viewthread.cfm?qid=193081
procedure SetPrinterSettings(FPrinter: TPrinter); var FDevice: PChar; FDriver: PChar; FPort: PChar; DeviceMode: THandle; DevMode: PDeviceMode; begin {to get a current printer settings} FPrinter.GetPrinter(FDevice, FDriver, FPort, DeviceMode); {lock a printer device} DevMode := GlobalLock(DeviceMode); {set a paper size as A4-Transverse} if ((DevMode^.dmFields and DM_PAPERSIZE) = DM_PAPERSIZE) then begin DevMode^.dmFields := DevMode^.dmFields or DM_PAPERSIZE; DevMode^.dmPaperSize := DMPAPER_A4_TRANSVERSE; end; {set a paper source as Tractor bin} if ((DevMode^.dmFields and DM_DEFAULTSOURCE) = DM_DEFAULTSOURCE) then begin DevMode^.dmFields := DevMode^.dmFields or DM_DEFAULTSOURCE; DevMode^.dmDefaultSource := DMBIN_TRACTOR; end; {set a Landscape orientation} if ((DevMode^.dmFields and DM_ORIENTATION) = DM_ORIENTATION) then begin DevMode^.dmFields := DevMode^.dmFields or DM_ORIENTATION; DevMode^.dmOrientation := DMORIENT_LANDSCAPE; end; {set a printer settings} FPrinter.SetPrinter(FDevice, FDriver, FPort, DeviceMode); {unlock a device} GlobalUnlock(DeviceMode); end;
//-----------------------------------
procedure TForm1.Button1Click(Sender: TObject);
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
{Set to legal}
pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
pDMode^.dmPaperSize := DMPAPER_LEGAL;
{Set to custom size}
pDMode^.dmFields := pDMode^.dmFields or
DM_PAPERSIZE or
DM_PAPERWIDTH or
DM_PAPERLENGTH;
pDMode^.dmPaperSize := DMPAPER_USER;
pDMode^.dmPaperWidth := 100 {SomeValueInTenthsOfAMillimeter};
pDMode^.dmPaperLength := 100 {SomeValueInTenthsOfAMillimeter};
{Set the bin to use}
pDMode^.dmFields := pDMode^.dmFields or DMBIN_MANUAL;
pDMode^.dmDefaultSource := DMBIN_MANUAL;
GlobalUnlock(hDMode);
end;
end;
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.BeginDoc;
Printer.Canvas.TextOut(100,100, 'Test 1');
Printer.EndDoc;
end;
//----------------------------
I want to print data on a pre-printed paper. it's length is 4.25". so I coded like this
Printer.GetPrinter(Adevice,Adriver,Aport,DeviceHandle);
PixelsInInchX:=GetDeviceCaps(Printer.Handle,LOGPIXELSX);
PixelsInInchY:=GetDeviceCaps(Printer.Handle, LOGPIXELSY);
DevMode:=globallock(DeviceHandle);
with DevMode^ do
begin
dmFields := DM_PAPERSIZE or DM_DEFAULTSOURCE or
DM_PAPERWIDTH or DM_PAPERLENGTH;
dmpapersize:=DMPAPER_USER;
dmPaperWidth :=(PixelsInInchX*8.5);
dmPaperLength:=(PixelsInInchY*4.25); //}1101;
end;
printer.SetPrinter(Adevice,Adriver,Aport,DeviceHandle);
But when I run the program the paper length is 612(dmpaperLength returns 612). So I just try to put values and I got my paper size when I put dmPaperLength with 1100 or 1101. The big problem is I want the value between these two values as 1100.5, but I can't put that value because dmPaperLength is an integer type.
It is a pre-printed paper so I must have that size and I want to use that paper in dotmatrix printer.after I print in one page if I don't give my length as correct value the next page data will not be in proper place.
Any body have any idea??
No comments:
Post a Comment
Komentar=