Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Remove line breaks in comments

Community Beginner ,
Dec 19, 2020 Dec 19, 2020

I like to copy text in highlighted passages so they're easier to copy and reference.  But when I do that, the comments also include the line breaks, making them harder to read/copy. 

 

Is there anyway (either through Acrobat itself or a javascript code) that can remove the line breaks in the comments? 

 

Note: It's not necessary but it would be great to also select which line breaks are removed.  For example, I don't want to remove line breaks follewed by a "-" because I use them for notes.

Ex: "Long quote from" [line break 1]  "the PDF that goes over one line" [line break 2] 

- notes about the quote I just highlighted

 

I don't want to remove those line break 2, ones I inserted myself

TOPICS
How to , JavaScript
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Dec 20, 2020 Dec 20, 2020

You can do it by running this code from the JS Console:

 

this.syncAnnotScan();
var annots = this.getAnnots();
if (annots!=null) {
	for (var i in annots) {
		var annot = annots[i];
		annot.contents = annot.contents.replace(/\r([^-])/g, " $1"));
	}
}

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 20, 2020 Dec 20, 2020

You can do it by running this code from the JS Console:

 

this.syncAnnotScan();
var annots = this.getAnnots();
if (annots!=null) {
	for (var i in annots) {
		var annot = annots[i];
		annot.contents = annot.contents.replace(/\r([^-])/g, " $1"));
	}
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 26, 2020 Dec 26, 2020

Thanks for the answer! I tried the JS code but I'm getting back an error:

SyntaxError: syntax error
1:Console:Exec
undefined

Any way I can fix this? I don't know much about coding

 

Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 26, 2020 Dec 26, 2020
LATEST

Did you select the full code before running it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines