问题
I have a PVC card printer which prints on both sides of a card at the same time. take a look at this question: Delphi double-side printer
I managed to enable the duplex printing mode of the printer. now the problem is that the first page which is the front side of the card is printed fine but the back side which is the second page is printed in black and white and a very low quality. something like a monochrome bitmap.
this is the output of my program which is printed using MS XPS document printer. as you can see there is no problem here, but when I select the PVC printer, I have problems in printing the back side.
Left page is the front side of the card which is printed fine but the right page is the back side of the card and is printed in black and white and a very low quality.

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;
Thank you.
来源:https://stackoverflow.com/questions/28514198/delphi-duplex-printing