2

I often copy text from PDFs into my notes and doing so almost always creates formatting issues. So to start, I'm just trying to create a simple script to remove newline characters from text copied to my clipboard.

Here's a LINK to the pdf I'm currently using.

I've tried this:

import pyperclip
text = pyperclip.paste()
new_text = text.strip()
pyperclip.copy(new_text)

I've also tried this:

import pyperclip
text = pyperclip.paste()
new_text = text.replace('\n', "")
pyperclip.copy(new_text)

I've read all of the related questions and answers on this subject but can't make it work.

martineau
  • 119,623
  • 25
  • 170
  • 301
CRP31
  • 25
  • 4

1 Answers1

1

Try also removing "\r". Some modules/programs don't adress the different types of line breaks in windows and other OSs

  • 1
    This did the trick. I had tried that as well but my original code removing "\r" was using 'text' instead of "new_text". Thanks! – CRP31 Aug 08 '20 at 14:52