| T O P I C R E V I E W |
| hinsona |
Posted - Feb 24 2026 : 14:42:01 Hi,
After updating to ImageEn 14.2.7, we're getting a dialog stating that a setting isn't supported by the currently selected printer when calling PdfViewer.Print(False) for silent printing.
Here's the relevant code:
LogMessage('enable pdf viewer.');
img.PdfViewer.Enabled := True;
LogMessage('set pdf viewer options.');
img.PdfViewer.Options := img.PdfViewer.Options + [iepoAnnotations];
// Printer.PrinterIndex := Printer.Printers.IndexOf('MyTestPrinter');
// Printer.Orientation := poPortrait;
LogMessage('set position.');
pdfStream.Position := 0;
LogMessage('load stream.');
img.PdfViewer.LoadFromStream(pdfStream);
LogMessage('enter print loop.');
for I := 0 to CopyCount do
begin
LogMessage('before print.');
img.PdfViewer.Print(False);
LogMessage('after print.');
end; The printer is set up with Letter paper size and duplex is off as its system defaults. We've experimented with various printer settings, like paper size, tray selection, orientation etc. but have been unable to determine which specific setting is causing the conflict.
What we've found is that if we use Print(True) or run the application as administrator, the print job completes successfully with no issues. When using Print(False) while running under a standard user account produces the unsupported setting dialog every time. The same code, same printers (at many locations), same PDFs, the only difference is elevation.
This was working fine under standard user accounts prior to updating to 14.2.7. Something appears to have changed in how Print(False) accesses or configures printer settings that now requires elevated privileges.
Environment:
ImageEn 14.2.7 Delphi 10 Seattle Windows 11 Printer: HP LaserJet Pro M402
Has anyone else encountered this after the 14.2.7 update? It seems like the silent print path may be attempting to read or modify printer settings in a way that requires admin access, whereas previous versions did not. Is there a known change in 14.2.7 that affects how DEVMODE or printer configuration is handled during silent printing?
Any guidance would be appreciated.
Thanks. |
| 6 L A T E S T R E P L I E S (Newest First) |
| xequte |
Posted - Feb 27 2026 : 19:53:26 Thanks for the detailed follow-up.
It sounds like an edge case, so I think at this stage we'll just keep an eye on it and see if other users encounter similar issues.
Nigel Xequte Software www.imageen.com
|
| hinsona |
Posted - Feb 27 2026 : 11:13:17 Hi Nigel,
I went back and tested on 13.7.0 as well and found the same behavior. So this isn't a regression from the update. The PDFium DLL version is the same across both.
After extensive debugging, I believe I've found the root cause. It's specific to certain printers which in our case the HP LaserJet Pro MFP 4103fdw. We tested multiple drivers: HP Universal Printing PCL 6 v7.4.0, UPD v8.1.0, and the model-specific V3 and V4 drivers. All produce the same error on silent print.
Our key observation was that when using PdfViewer.Print(True) (with dialog) it worked perfectly on the same printer. The difference is that the print dialog forces a call to DocumentProperties, which populates a valid DEVMODE structure. The silent path skips this.
I traced it through the ImageEn source:
TIEPdfViewer.Print(False) -> TPdfDocumentPrinter.Print -> BeginPrint -> PrinterStartDoc
In PrinterStartDoc (iexPdfiumCore.pas, ~line 11029), Printer.BeginDoc() is called directly without first ensuring the printer's DEVMODE is properly initialized.
For this particular printer, Printer.Capabilities returns an empty set, which seems to indicate that Delphi's TPrinter hasn't properly queried the driver. So when BeginDoc is called, the driver rejects it with "The settings for the selected printer are not supported."
Our workaround was to call DocumentProperties via the Win32 API before calling Print(False):
procedure InitializePrinterDevMode;
var
hPrn: THandle;
DevModeSize: Integer;
pDevMode: PDeviceMode;
Device, Driver, Port: array[0..255] of Char;
DeviceMode: THandle;
begin
Printer.GetPrinter(Device, Driver, Port, DeviceMode);
if not OpenPrinter(@Device, hPrn, nil) then
Exit;
try
DevModeSize := DocumentProperties(0, hPrn, @Device, nil, nil, 0);
if DevModeSize <= 0 then
Exit;
pDevMode := AllocMem(DevModeSize);
try
if DocumentProperties(0, hPrn, @Device, pDevMode^, pDevMode^, DM_OUT_BUFFER) = IDOK then
begin
DeviceMode := GlobalAlloc(GHND, DevModeSize);
try
Move(pDevMode^, GlobalLock(DeviceMode)^, DevModeSize);
GlobalUnlock(DeviceMode);
Printer.SetPrinter(Device, Driver, Port, DeviceMode);
except
GlobalFree(DeviceMode);
raise;
end;
end;
finally
FreeMem(pDevMode);
end;
finally
ClosePrinter(hPrn);
end;
end; We are only doing this when Printer.Capabilities = [] so it only runs when needed.
I don't know if this could be useful when the silent print path is used? This is essentially what the dialog path already does, and it would make silent printing work more reliably with printers where they don't properly initialize DEVMODE.
Thanks.
|
| xequte |
Posted - Feb 25 2026 : 21:23:01 Hi
I cannot see any particular change to the PDF printing code since v13.7.0, so if you are getting a different result, please check the version of the PDFium DLLs (iepdf32.dll for 32-bit) you are using.
Nigel Xequte Software www.imageen.com
|
| xequte |
Posted - Feb 25 2026 : 13:33:17 Hi
OK, thanks. Did you use the same version of the iepdf32.dll with both ImageEn versions?
Nigel Xequte Software www.imageen.com
|
| hinsona |
Posted - Feb 25 2026 : 09:01:59 13.7.0
I'm going to go back to this version to verify it's functioning. |
| xequte |
Posted - Feb 24 2026 : 22:37:17 Hi
Do you recall what version you were using prior to v14.2.7, which worked as expected?
Nigel Xequte Software www.imageen.com
|
|
|