Copy text without new line + carriage return

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Paul - Tracker Supp, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software

Post Reply
Timur Born
User
Posts: 694
Joined: Tue Jun 26, 2012 1:50 pm

Copy text without new line + carriage return

Post by Timur Born » Wed Apr 18, 2018 4:04 pm

Hello.

Is there a way to copy text out of a PDF without line breaks (new line + carriage return)? Yesterday I had to copy a floating text consisting of columns around images and then needed to get rid of all the line breaks. I did this by copying the text to Notebook++ and then replacing all \n and \r with empty characters, but maybe there is an easier way?

User avatar
TrackerSupp-Daniel
Site Admin
Posts: 3155
Joined: Wed Jan 03, 2018 6:52 pm

Re: Copy text without new line + carriage return

Post by TrackerSupp-Daniel » Thu Apr 19, 2018 12:10 am

Hi Timur,
I think for the time being, your method is the simplest around. If I can find one to do this from directly within the editor I will come let you know :)
Daniel McIntyre
Support Technician
Tracker Software Products (Canada) LTD

Sales: +1 (250) 324-1621
Fax: +1 (250) 324-1623

User avatar
David.P
User
Posts: 904
Joined: Thu Feb 28, 2008 8:16 pm
Location: Germany

Re: Copy text without new line + carriage return

Post by David.P » Fri Apr 20, 2018 5:48 pm

Hi all,

I found that at least with some PDF's, copying the text "as Rich Text" for example via context menu, can copy entire paragraphs as continuous (flowing) text without new lines and/or carriage returns.

Hth & regards
David.P
David.P
PDF-XChange Pro

User avatar
Paul - Tracker Supp
Site Admin
Posts: 4990
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada
Contact:

Re: Copy text without new line + carriage return

Post by Paul - Tracker Supp » Fri Apr 20, 2018 6:05 pm

I'm not seeing any difference between copy and copy as rich text.

David - does it matter what document you copy from to get this difference?

All my copy/paste efforts past entire paragraphs appropriately. It sounds like Timur has a relatively complex layout?
Yesterday I had to copy a floating text consisting of columns around images and then needed to get rid of all the line breaks.
Does this happen the same way for you Timur on any document or is this a specific case?
_________________
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com

Timur Born
User
Posts: 694
Joined: Tue Jun 26, 2012 1:50 pm

Re: Copy text without new line + carriage return

Post by Timur Born » Fri Apr 20, 2018 7:15 pm

Two columns of text floating around a center image. It doesn't matter whether I copy as text or rich-text the lines are copied as seen in the original. In order to copy that to pure text in a more readable form I have to first remove the /n/r.

When I copy from Editor I also have to remove lots of "-" (words divided between lines) whereas Adobe Reader copies the text without the latter even when they appear in the original PDF. So for the time being I will use Adobe Reader to copy these kind of texts, because it saves me from removing the "-" on top of the /n/r.

Image
Last edited by Timur Born on Fri Apr 20, 2018 8:02 pm, edited 1 time in total.

User avatar
Paul - Tracker Supp
Site Admin
Posts: 4990
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada
Contact:

Re: Copy text without new line + carriage return

Post by Paul - Tracker Supp » Fri Apr 20, 2018 7:25 pm

Understood.

Do we have and or may we have that document to "play" with here?
_________________
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com

Timur Born
User
Posts: 694
Joined: Tue Jun 26, 2012 1:50 pm

Re: Copy text without new line + carriage return

Post by Timur Born » Fri Apr 20, 2018 8:02 pm

You can use the following PDF, it contains several pages of similar formatting and also contains lots of "-" separated lines.

http://www.ulisses-spiele.de/download/2 ... a_261d.pdf

User avatar
Paul - Tracker Supp
Site Admin
Posts: 4990
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada
Contact:

Re: Copy text without new line + carriage return

Post by Paul - Tracker Supp » Fri Apr 20, 2018 10:30 pm

Thanks Timur

have a great weekend!
_________________
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com

Timur Born
User
Posts: 694
Joined: Tue Jun 26, 2012 1:50 pm

Re: Copy text without new line + carriage return

Post by Timur Born » Wed Sep 04, 2019 10:09 am

In the meantime I am using an Autohotkey script that automatically strips new line + carriage return when I paste text via ALT+CTRL+V instead of CTRL+V.

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13919
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Copy text without new line + carriage return

Post by Tracker Supp-Stefan » Wed Sep 04, 2019 11:22 am

Thanks for the tip Timur!

Cheers,
Stefan

Timur Born
User
Posts: 694
Joined: Tue Jun 26, 2012 1:50 pm

Re: Copy text without new line + carriage return

Post by Timur Born » Wed Sep 04, 2019 11:47 am

This is the AHK code I am using. It specifically looks for different cases that may or may not warrant a new line + carriage return. So paragraphs should stay intact. It also removes dashes "-" that are used to break words in two lines. Last but not least, it replaces several space characters with a single one.

I shamelessly copied the code from another source and then did a few minor edits.

Code: Select all

Paste:

; Note for following code that `r`n = newline

;Code the paragraph breaks with a special combinations
StringReplace Clipboard, Clipboard, .`r`n, -.-, All
StringReplace Clipboard, Clipboard, ?`r`n, -?-, All
StringReplace Clipboard, Clipboard, !`r`n, -!-, All
StringReplace Clipboard, Clipboard, :`r`n, -:-, All
;StringReplace Clipboard, Clipboard, `r`n`r`n, -*-, All

;Remove a dash followed by newline, since that's probably a single word across a linebreak
StringReplace Clipboard, Clipboard, -`r`n, , All

;Replace a single newline with a space
;StringReplace Clipboard, Clipboard, %A_Space% `r`n, %A_Space%, All
;StringReplace Clipboard, Clipboard, `r`n, %A_Space%, All

;Replace multiple adjacent spaces with a single one
Clipboard := RegExReplace(Clipboard, "\s+" , " ")

;Replace the paragraph break codes with newlines
StringReplace Clipboard, Clipboard, -.-, .`r`n, All
StringReplace Clipboard, Clipboard, -?-, ?`r`n, All
StringReplace Clipboard, Clipboard, -!-, !`r`n, All
StringReplace Clipboard, Clipboard, -:-, :`r`n, All
;StringReplace Clipboard, Clipboard, -*-, `r`n, All

Send ^v ;paste

return

User avatar
Will - Tracker Supp
Site Admin
Posts: 6905
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Copy text without new line + carriage return

Post by Will - Tracker Supp » Wed Sep 04, 2019 11:49 am

Thanks Timur, I'm sure others will find that useful! :)
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com

Post Reply