我有一台PVC卡打印机,可以同时在卡的两面打印。 看看这个问题:Delphi double-side printer
我设法启用了打印机的双面打印模式。现在的问题是,作为卡片正面的第一页打印得很好,但是作为第二页的背面是黑白打印的,质量很低。类似于单色位图的东西。
这是我的程序的输出,使用MS XPS文档打印机打印。 你可以看到这里没有问题,但是当我选择PVC打印机时,我在打印背面时遇到了问题。
左页是卡的正面,打印正常,但右页是卡的背面,黑白打印,质量很差。
var
i, j: integer;
ppix,ppiy,mmx,mmy: integer;
XForm: TXForm;
Device, Driver, Port: array[0..80] of Char;
DevMode: THandle;
pDevmode: PDeviceMode;
insert_comm: wideString;
begin
with PrintDialog1 do
if Execute then
begin
with printer do
begin
GetPrinter(Device, Driver, Port, DevMode);
if Devmode <> 0 then begin
// lock it to get pointer to DEVMODE record
pDevMode := GlobalLock(Devmode);
if pDevmode <> nil then
try
with pDevmode^ do begin
dmDuplex := DMDUP_VERTICAL;
dmFields := dmFields or DM_DUPLEX;
end;
BeginDoc;
ppix:=GetDeviceCaps(Handle,LOGPIXELSX);
ppiy:=GetDeviceCaps(Handle,LOGPIXELSY);
mmx:=round(ppix/25.4);
mmy:=round(ppiy/25.4);
SetGraphicsMode(Canvas.Handle, GM_ADVANCED);
XForm.eM11 := Cos(DegToRad(270));
XForm.eM12 := Sin(DegToRad(270));
XForm.eM21 := -Sin(DegToRad(270));
XForm.eM22 := Cos(DegToRad(270));
XForm.eDx := (PageWidth div 2) - ((54 * mmy) div 2);
XForm.eDy := 85 * mmx;
SetWorldTransform(Canvas.Handle, XForm);
// Here I draw the front side of the Card
// New page for back side
NewPage;
SetGraphicsMode(Canvas.Handle, GM_ADVANCED);
XForm.eM11 := Cos(DegToRad(270));
XForm.eM12 := -Sin(DegToRad(270));
XForm.eM21 := Sin(DegToRad(270));
XForm.eM22 := Cos(DegToRad(270));
XForm.eDx := (PageHeight div 2);
XForm.eDy := 0;
SetWorldTransform(Canvas.Handle, XForm);
// Here I draw the back side of the Card
EndDoc;
try
bmp.Destroy;
except
end;
finally
// unlock devmode handle.
GlobalUnlock(Devmode);
end;
end; { If }
end;
end;
谢谢。