How to put line numbers on existing blank pages?

I just realize my mistake:

I want the line numbers to flow onto the next blank page

So my approach does not work.

By the way, tables only allow 8192 rows.

Thanks Earnest, I think the list approach could very well work, but how can the numbers distance from the left margin be changed? If possible I want the numbers in the list flush with the left margin.

Secondly, you say about copying the list and pasting it on each subsequent page. This works, but is there a way to automate this process with a macro? Do you have an example of macro code that I could use for this?

Many thanks

@EarnestAl: the frame is not anchored To page. If it is, the frame must effectively be manually inserted on every page. It is in fact anchored To paragraph in the header. Thus it is automatically repeated on every instance of the same page style.

@ajlittoz I don’t know the purpose of the exercise but it seems to have a definite number of blank pages of differing styles. If the frame is anchored to the header (there is no room for a header in the sample given) then I don’t know if the the numbering would remain sequential from style to style, but it would require more work on each change of

You are absolutely right, Anchored to page can cause big problems. An inserted page later on would not get a sequentially numbered frame and might break the numbering if there were an attempt to paste a frame from another page.

Another way to do this would be to fill every existing page with line breaks and then turn on numbering (like in the Picture Example below). But is there some automatic way to fill every existing page with line breaks, either with some macro code or other automated way?

Picture Example

The fact that we try to outsmart Writer clearly shows this track is not the good one.

Let’s get back to the original problem: annotate a document. You said it is a PDF. Who created it? If you did, make a Writer version of it and work with it. If you annotate somebody else’s work, then it is not in its final shape. Request an editable copy of it.

Annotations are best made with the comment feature. Proof reading fixes use the track changes feature.

As a last resort, find some OCR application to transform the PDF into plain text at least. You’ll format it once and work on it from there on.

I did not create the PDF documents, so don’t have the source. OCR is a very bad approach, as it is time consuming and can change the formatting. PDF editors are a bad option, as I can only work on one page at a time. For thousands of pages this is tedious. If I can just find a way to fill these existing blank pages with line breaks, then I can turn on numbering in writer. It’s then so simple and quick to overlay one pdf to another pdf.

I mentioned OCR as a last resort measure because, as you rightfully point out, you must rebuild the formatting. But you however do it only once, provided the original document does not get edited over and over.

The simplest and best way is to request an editable copy from the author.

The task you describe in a comment of 287498/how-to-delete-all-page-content-but-leave-blank-pages would be much easier if you had an .odt (or eventually a .doc(x)) because you would then change Default Style to set font colour to white. Thus text is still there, formats the same but does not print. This is the only trick I know to be sure the structure of the document remains the same.

way to put line numbers on existing blank pages in Writer

Pages do not exist in Writer until text request a page to be laid out on. In addition line numbering numbers only existing lines. So if your page is blank (i.e. has no contents, save perhaps a single empty paragraph), you won’t get any numbering (save again 1 in front of the empty paragraph).

As said, line numbering numbers lines. If your page is blank, how tall would be potential lines? They don’t exist and consequently have no formatting. Which font size should be used? Which spacing between paragraphs (this space is not numbered)? Etc.

Once again, you’re trying to use Writer outside its designed domain. This explains why it is so difficult.

Create a numbered list Click on first page and press F12, click Edit > Direct Cursor Mode then carefully click at the bottom of your page just out from the margin, the left of the page should fill with numbers, click Edit > Direct Cursor Mode to turn off Direct Cursor Mode.

Create a frame interactively, anchored to page (so it is outside the text, Page Wrap. There seems to be a fixed number of pages so insertion of pages wouldn’t be an issue).

Cut the numbered list described above and paste into frame. Alter the numbering: right-click, select Bullets and Numbering. In the dialog that opens select the Position tab, change Aligned at to 0.0 cm, Numbering followed by Nothing, Indent at 0.0 cm, OK.

Select the list and change Paragraph Style to Text Body (assuming your text uses Text Body style). Modify Text Body Style so there is no extra space after the end of a paragraph. (If you want a paragraph spacing then use two returns

Adjust the frame so the numbers accurately align with some dummy text, ensure same style (Text Body).

Copy and paste the frame into every page starting from the last page and working backward. For some reason the the numbers reverse their order after saving and closing in LO; is this a known issue?).

Sequential numbering from 1 to around 10000 for two hundred pages pasting at 3 seconds per page = 600 hundred seconds = 10 minutes. Sorry, I cannot help with a macro.

Sample attached

I had assumed the problem might have been related to translation/study of/transcription of a document, probably a hard to read one.

Given the discussion above I don’t believe that that trying to number lines in a pasted/inserted pdf is going to work. Line spacing would have to match exactly on each individual page. There are no shortcuts. As @ajlittoz says OCR the pdf.

It is worth getting the best OCR program you can buy for a task like this, something that allows you to edit and correct the OCR within the program itself. Trying to use the OCR program’s layout rendering is likely to create a big mess so export as plain text and maybe recreate the layout in LO, but only if it really is important. The blank sample pages look like they would be hard work for a reader.

Line spacing does not have to match the exact text. It is only there for a rough reference. The only way I have found to accomplish my task is to fill up a single page completely with a text character and export to PDF. I then export my few hundred blank pages to pdf and use a simple command line program to overlay the single page with the text character onto the hundreds of blank pages. Once this is complete, I then convert this pdf to ODT and I once again have my blank pages in writer, but these are filled with a single text character. To get rid of this text character, I then use “find and replace” and replace the character with a blank space. I then turn on line numbering and have line numbers on my blank pages. This works perfectly for what I want to achieve, but I can’t believe there is no way to put line numbers on existing blank pages in Writer, either by a macro or some other trick.

Just curious. Did you try copying the frame from my sample and pasting it into some pages?

Yes the list method works, but it is necessary to click on every page. I am trying to cut down the amount of manual steps. But thanks for your suggestion

An option editing the content.xml file to add new paragraphs and create a numbered list with the paragraphs of all pages:

  • Add a second paragraph in page 1 (it will be useful to add some content to this paragraph to find it easily a few steps latter).
  • Save.
  • Extract and edit the content.xml file.
  • Find the recently added paragraph, take note of the style-name, and detele the paragraph.¹
  • Find <text:p text:style-name="P[0-5]"/> and replace all 80 times² with &<text:p text:style-name="P6"/>
  • Save and replace the content.xml file in its container file.
  • Open the file.
  • Select all.
  • Press F12 to create numbered list.

Edit: Your sample file has 5 page styles: P1-P5. Note the P[0-5] in the find text that I proposed (no P6). You need to Find & Replace; just 80 clicks on the Replace All button (no Paste 80 times). Each click add a new paragraph to each page. Maybe instead of P[0-5] you need to use P[0-9]{1,3} (this will search from P0 to P999).

The style-name of the paragraph with AAAAAAA content is P6? Or instead of 6 there is another number close to a few hundred?

All pages in the document have the same height (as in the sample)? In that case 80 additional paragraphs per page are enough. If not, there we have a problem. I don’t know how many page sizes this work has, but a better way around this problem is to use a single page style for all pages of the same size (something I suggested in my first comment). That way, in each style the new paragraph could be added a different number of times.

¹ <text:p text:style-name="P6">some content</text:p>; P6 is the style-name of the new paragraph.

² 81 lines fit on each page.

³ I used [0-5] and P6 based on the sample provided.

Tested with LibreOffice (x64); OS: Windows 10.0.

Add Answer is reserved for solutions. If you think the answer is not satisfactory, add a comment below, or click edit (below your question) to add more information. Thanks.

Check the mark (Answer markCorrect answer mark) to the left of the answer that solves your question.

If the answer helped you, you can mark the up arrow (Upvote mark) that is on the left (to vote, you need to have karma of at least 5).

Thanks for your reply. I added a paragraph with the wording AAAAAAA, saved and extracted the content.xml. As per your instructions, I replaced with <text:p text:style-name=“P6”/> and pasted 80 times (adding prefix “&” before the string results in error). I then replaced the content.xml. But pasting 80 times just fills the first page. I don’t understand why it is pasted 80 times? While 80 times may fill one page size, what happens if there are many mixed page sizes in the same document? You would have to work out how many times you have to paste it for each page of different sizes and then edit the content.xml accordingly. It would be very tedious with hundreds of pages of different sizes.

Attached below is the test file that I create with your method. I don’t understand how the method can quickly work for a document comprising of many pages of different sizes? Please look at the following test file created with your method:

I have tried both of these:

<text:p text:style-name="P[0-5]"/>


<text:p text:style-name="P[0-9]{1,3}"/>

For the replace I have tried:

&<text:p text:style-name="P6"/>

I am using notepad++ Please see screenshot of my approach below . Not sure what I am doing wrong?


@tommydog, Edit the content.xml file in Writer. To do it, I add a .wri extension to the file name.

The regular expressions works in the Find & Replace dialog of Writer (don’t know if notepad++ understand them).

Yes, I think that was the problem. It seems the text editors of was using were not recognising the expressions. It’s all perfect now - thanks.

Out of interest is there any quick way to edit the XML files using the find and replace dialogue to set page margins for every page in the document? I want all pages to have a left margin of 1.5cm from the edge of the page and a top / bottom margin of 0.5 cm for all pages regardless of size and orientation?

Not sure, but think that we need to play with the styles.xml file to change margins. I need to test it before.