Copy text without new line + carriage return

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

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

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

Copy text without new line + carriage return

Post by Timur Born »

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: 8440
Joined: Wed Jan 03, 2018 6:52 pm

Re: Copy text without new line + carriage return

Post by TrackerSupp-Daniel »

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 :)
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
David.P
User
Posts: 1510
Joined: Thu Feb 28, 2008 8:16 pm

Re: Copy text without new line + carriage return

Post by David.P »

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: 6837
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 »

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?
Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Timur Born
User
Posts: 874
Joined: Tue Jun 26, 2012 1:50 pm

Re: Copy text without new line + carriage return

Post by Timur Born »

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: 6837
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 »

Understood.

Do we have and or may we have that document to "play" with here?
Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Timur Born
User
Posts: 874
Joined: Tue Jun 26, 2012 1:50 pm

Re: Copy text without new line + carriage return

Post by Timur Born »

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: 6837
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 »

Thanks Timur

have a great weekend!
Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Timur Born
User
Posts: 874
Joined: Tue Jun 26, 2012 1:50 pm

Re: Copy text without new line + carriage return

Post by Timur Born »

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: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Copy text without new line + carriage return

Post by Tracker Supp-Stefan »

Thanks for the tip Timur!

Cheers,
Stefan
Timur Born
User
Posts: 874
Joined: Tue Jun 26, 2012 1:50 pm

Re: Copy text without new line + carriage return

Post by Timur Born »

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: 6815
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 »

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