How to tidy copied PDF text with a CoPa script

Below is a CoPa script for tidying copied PDF text. I call it lfkill (for “linefeed killer”) and use it quite a bit for grabbing chunks of text in PDFs and pasting them into text or LibreOffice Writer documents. In other words, it does what’s shown above without the copied text having to be saved to a new file.