While Printer is connected Check for Updates for OS X. If no updates try the following.
You can try doing some basic resets.
Shutdown iMac
Disconnect printer from iMac
Reset SMC - Disconnect iMac from electrical socket and reconnect after 30 seconds
Reset PRAM - "As quickly as you can after pressing the power button" Hold down Command Option P and R until you hear the startup noise for the second time. Then release the keys.
After LOGIN Reconnect printer
****Test printer
If still not successful
Shutdown iMac
As quickly as you can after pressing the power button hold down the Shift key until you see the Apple Logo and then release the shift Key
You will be in safe mode. *****Screen will look a little funky but thats normal for Safe Mode*********
Test Printer
If still failing seek help from HP
Exit Safe Mode by restarting iMac