MATLAB: Do I receive errors when I try to print or print preview from a deployed application using MCR 7.8

componentenvironmentMATLAB Compilerruntimevariable

I get the following errors on the DOS command prompt:
??? Error using ==> deployprint at 223
Failed to send image to the printer. System error:
Error in ==> printdlg at 13
??? Error while evaluating uipushtool ClickedCallback
Two error message dialog boxes open up with the following messages:
Title: PrintImage Error
Message: Unknown argument: -am
Title: PrintImage Usage
Usage: PrintImage.exe file.bmp [-i | \\printserver\printer] <switches> -i: Bring up dialog box.
\\printserver\printer: Skip print dialog, use this printer.
-d: Delete file.bmp after printing it.
-hd: Header date string.
-hfa: Header font angle.
-hfn: Header font name.
-hfs: Header font size
-hfw: Header font weight.
-hm: Header margin
-hs: Header text
-l: Print in landscape mode

Best Answer

This is a conflict between different versions of the MATLAB Compiler Runtime (MCR). PrintImage.exe is called internally for "Print" and "Print Preview" operations. If multiple versions of the MCR are present in the operating system path, such that the version of MCR being used by the deployed application appears behind some other MCR version, then PrintImage.exe will be called by the incorrect version of MCR.
To resolve the issue, edit the system PATH so that the correct version of MCR appears ahead of all the other versions of MCR(s) and any other MATLAB versions that might be present in the PATH.