Hello,
We are currently evaluating ViewPDF for our application. However, a requirement is total control over the printer, eg. duplex and choice of tray.
This seems to be possible by manipulating the DevMode structure, then making use of the COMPDF_PrintSetDEVMODE call.
We are using the following code to test printing to different trays:
Code
procedure TWPViewPDF.TestPrinterThings;
var
DevMode: PDeviceMode;
hDevMode: THandle;
FDevice, FDriver, FPort: array[0..255] of Char;
com: TWPComRecStruct;
tray: Integer;
begin
Printer.PrinterIndex := -1;
Printer.GetPrinter(FDevice, FDriver, FPort, hDevMode);
CommandStr(COMPDF_SelectPrinter, FDevice);
for tray := 2 to 4 do
begin
DevMode := GlobalLock(hDevMode);
try
DevMode^.dmDefaultSource := tray;
DevMode^.dmFields := DevMode^.dmFields or DM_DEFAULTSOURCE;
FillChar(com, SizeOf(com), 0);
com.Param := Cardinal(DevMode);
if SendMessage(Handle, WM_PDF_EXCOMMAND, COMPDF_PrintSetDEVMODE + FCO, Cardinal(@com)) < 0 then
raise Exception.Create('TWPViewPDF.TestPrinterThings: SetDevMode failed');
CommandStr(COMPDF_Print, '1-1');
finally
GlobalUnlock(hDevMode);
end;
end;
end;
Alles anzeigen
This does not work - all copies goes to the default tray.
Question: Is the code faulty, or is what we are doing not possible?
Chris