Hi @Sturach,
Reinstall with the full software for resolve this error:
HP Deskjet 2540 All-in-One Printer series Full Feature Software and Drivers
http://support.hp.com/us-en/drivers/selfservice/hp-deskjet-2540-all-in-one-printer-series/5295960/mo...
Add update the firmware:
HP Deskjet 2540 All-in-One Printer series/HP Deskjet Ink Advantage 2540 All-in-One Printer series Firmware Update
http://ftp.hp.com/pub/softlib/software13/printers/congo/DJ2540_R1547A.exe
I hope that helps !

Can I ask you a favor ?
If the question is clarified, mark my answer as "resolved" and click on the icon of the "hand" to provide "congratulations" in recognition.
Have a nice week !

I´m a volunteer in the HP Forum !