How do you search and replace page breaks in Libre Office?

8

1

How do you search and replace page breaks in Libre Office Writer? For example, I may want to remove all manually inserted page breaks (^m in MS Word). I can search for line breaks and paragraph breaks using regular expressions, but I don't see a page break character anywhere.

xpda

Posted 2012-02-05T06:49:30.770

Reputation: 929

Answers

2

Quite a hack, but I'd suggest unzipping the .odt file and working with raw XML. The content.xml seems to be the correct file to edit.

I have prepared a test file with content:

QQQQQ
-page break-
AAAAA

And here is the relevant part of the raw XML:

<!---*lots* of declarations--->
<office:automatic-styles>
    <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard">
        <style:paragraph-properties fo:break-before="page"/>
    </style:style>
</office:automatic-styles>
<office:body>
    <office:text text:use-soft-page-breaks="true">
        <text:sequence-decls>
            <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
            <text:sequence-decl text:display-outline-level="0" text:name="Table"/>
            <text:sequence-decl text:display-outline-level="0" text:name="Text"/>
            <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
        </text:sequence-decls>
        <text:p text:style-name="Standard">QQQQQ</text:p>
        <text:p text:style-name="P1">AAAAA</text:p>
    </office:text>
</office:body>
<!---some happy-end--->

(The real file will proably be more complex.) It seems to me that "P1" is a style created to "bear" the property of page-breaking before the paragraph. So two things come into my mind:

  • remove "P1" from <text:p /> tags
  • remove the page-breaking property from "P1" style

By the way, here I'd also recommend avoiding regexes in favor of some real XML parser.

Alois Mahdal

Posted 2012-02-05T06:49:30.770

Reputation: 2 014

While I think removing the P1 style from a paragraph would work, it would be pretty cumbersome to use on an ongoing basis. I am looking more for something like ^m in word, which can be used in search and replace. – xpda – 2012-03-26T03:50:41.263

It looks like there's not a good answer to this question, but this seems like the best answer. I would like to change to LibreOffice, but the lack of this one feature is preventing it. – xpda – 2012-03-26T03:54:04.240

4

This post in a LibreOffice mailing list suggests the AltSearch plugin. It says on the plugin page that it is capable of

  • Searching out manual page and column break and their set up or deactivation

zpletan

Posted 2012-02-05T06:49:30.770

Reputation: 894

This almost works. It can find \m but not replace it. It reports replacing the page breaks, but the page breaks remain. – xpda – 2012-03-21T01:33:39.997

1

Try using \n or \r or s/\r\n/\r/g in your regexp. \n is for liNe feeds, \r is for caRriage returns.

I don't know if this will work in Libre office. Alternative is to copy from that, into a text editor (gedit in linux, notepad++ in windows), do the search and replace, and copy it back.

Roy Rico

Posted 2012-02-05T06:49:30.770

Reputation: 4 808

Unfortunately (at least here on Debian Wheezy), LibreOffice page breaks are not preserved in copy&paste. – Alois Mahdal – 2012-03-19T21:37:43.960

0

Although not exactly what you ask for, I’ve got pretty close (using the Find & Replace function and paragraph formatting) because I had a similar problem. I realised that page-breaks actually aren’t special characters but part of paragraph formatting/style of the succeeding paragraph (or in very rare cases of the preceding one – in which case this method would need to be slightly modified).

If you happen to have the page-breaks always after specifically formatted text, you can search for that places by:

  • Edit > Find & Replace... (Ctrl + H)
  • Open Other options
  • Click Format...
  • Select specific formatting that singles out the specific paragraphs from all other text in the document
  • Tick Incuding Styles (after closing the Text format (Search) window)
  • Click Find All and close the Find & Replace window
  • Format > Pragraph...
  • on Text Flow untick Breaks > Insert (or if it isn't ticked, first tick it, apply, and repeat this step)

I wonder why Text Flow > Breaks section is greyed out in the Text format (Search), it would be much more precise if it could be searched for directly :-/

Martin

Posted 2012-02-05T06:49:30.770

Reputation: 1

0

I'm, not sure if it supports this, but I'd look at OOoPy.

OOoPy: Modify OpenOffice.org documents in Python

Alois Mahdal

Posted 2012-02-05T06:49:30.770

Reputation: 2 014

-2

Howto delete a 'manual page break' outoff a 'writer' docment? Well, when you look at the internet, there is hardly anything what handles a batch removal for pagebreaks. Say a 50 odd or more. The solution is very simple. You save the .doc file as an .xml file. Reopen the .xml file with 'writer' and there you are, all pagebreaks are gone. Don't ask me how.

Wandaa

Posted 2012-02-05T06:49:30.770

Reputation: 1