I have an RTF document that has sections of red, blue, and even pink text. I want to put this document on an e-reader, but it is e-ink, and as such black-and-white.
I need to know if there’s a way to search and replace the colored text with, say, underlines of different types, so I can still follow the text as it is meant to be.
[UPDATED] Yes, this is possible, but the approach used depends on the origins of the RTF file, since difference software will leave you with different markup (so it seems). Sunny’s document is best treated with #2, below, “CTRL-H and Regex”. Obviously, all testing should be done in a copy of the file, so you have your original, coloured version still available!
(1) Position your cursor within the colour block you want to modify.
(2) Click the “AltSearch” icon, and select the “Properties” drop down, then the last option listed: “Same format of characters (based on cursor)”. It should look like this:
(3) When you click on that option, you’ll see the “search” field populated as shown in the screen shot: that’s the color of your text at cursor. Now click the Find All button (hidden in the screen shot), then Close the AltSearch dialog. All text in that colour is now “selected”.
(4) Now use the Format > Character... > Font Effects > [Underlining] to choose your underlining of choice for this colour. Click OK.
(5) Repeat process for each colour.
When you’re finished, use CTRL-A to select ALL, and set the Font Colour to “Automatic” from the drop-down on the toolbar.
That’s you done. You should end up with all your text in black, but with the various bits of text that were originally colours now in various styles of underlining.
2. CTRL-H and Regex
You can also use the “native” search-replace function. First, use CTRL-H to bring up the “Find & Replace” dialog. Click the “Other Options” drop-down, if it isn’t already open, and check the “Regular expressions” box:
(1) In the “Search for” field, put .* (that is, “dot” followed immediately by “asterisk”). Then click on the Format... button, and choose the “Font Effects” tab. Select the colour desired (Sunny’s document uses “Light red”, “Light blue”, and “Light magenta”).
(2) In the “Replace with” field, put & (ampersand) which means = “the text found in my search”. Again choose the Format... button, but now choose “Automatic” for the font colour, and choose the “Underlining” style of choice for this colour.
(3) Hit Replace All, and you should have the coloured text chosen replaced with black text and its distinctive underlining.
(4) Repeat for each colour needing to be changed.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
It’s not as tricky as it might sound, and once you’ve done it a couple times, will go very quickly, I think. This works for me with LibO Writer 4.1.4.2, and I’m on Linux Mint 13 LTS (Xfce) at the moment. Hope that helps!
I selected the text and brought up the AltSearch dialog. However, when selecting the option shown, I received the following error… (Turns out I can’t post images. Sorry.)
This also pulls up the macro code where the error is caused.
It appears to be looking for a format name, not the existing formatting at that point.
Since it’s RTF, I’m not sure format names apply.
Since you seem to be able to perform this function, would it be possible for me to send the file to you and have you make the changes? Unless you can find a way around my error, I’m not sure there’s much else I can do.
@Sunny1 - Hmmm… I can replicate this. Sorry. Let’s do a little more investigating before I update my answer. Can you attach the file to your answer now? Or put it on dropbox or something and share the link? I’m pretty confident we can sort this, but it would help to have precisely the file you’re working with, if you’re willing.
Could it be that the RTF format’s properties can’t be handled by the extension’s code? @Sunny1 you could try to save the document as an ODT before attempting the replacements. What formats does the e-reader accept? LibO allows you to save the modified ODT back to RTF after the modifications are made. We’d only need to know if LibO’s RTF plays well with your e-reader model.
@CyanCG - I had attempted what you suggest in my experiements, and got different results depending on the origins of the RTF file. I’ve discovered more than one way to search on colour, but the results differ starkly depending on the underlying code – I assume. Which has to do with the document’s origins, I expect.
@dajare (et al) - For anyone who wishes, here’s the link to a folder with both RTF and DOC versions of the file. Convert to your hearts’ content, but let me know how it goes.
@Sunny1 - it did work (interesting document!), and results added to my “Answer”, above. Use option #2, and you should be fine. (I live in hope!) I tested on the RTF, by the way, not the DOC.
@dajare - That has done the trick! Thanks so much for the insight and assistance. I am indebted to you for your help. I will be taking the link to the files down soon, just in case anyone else wants a peek at the document or wants to try they’re hand at this technique. Probably the end of the week.
@Sunny1 - hurrah! Glad it worked. Good question, and I learned something too! Could you mark that answer as “correct” (click the little check-mark symbol at the top of the Answer) so the issue is recorded as resolved? Thanks!