I'm not sure if this was the problem (or why it would be) but I experimented by changing the IP address from auto to static, then back to auto. The printer then had an IP address from the one originally assigned when first set up. But now it seems it prints all documents and PDF files.
Incidentally, the HP Print and Scan Doctor. never found any problems and always said the printer was fine.
Thanks for your help.
John