I wanted the entire page (not just the text content).
It didn't occur to me that the provider of the pdf file from which I wish to copy the page might have put such settings in place ... I probably ought to respect his intentions.
I've just tried the script with another pdf file that doesn't have any security settings - and the script then works fine.