# How to put line numbers on existing blank pages?

I have a document comprising of a few hundred blank pages (different page sizes and orientations) that I wish to put line numbers on. I can enable line numbering in Writer, however when I hold the enter key down, and get to the end of the first page, a new page is created. I don't want this, as I want the line numbers to flow onto the next blank page. Attached at the bottom is a small sample of the blank pages that I wish to fill with line numbers (various sizes and orientation). I need a quick way to do this, as in practice I will have hundreds of blank pages, and the order,orientation, size of these blank pages must be preserved. I simply want line numbers from the top to bottom on these existing blank pages. Is there a setting I can change in Writer to enable this, or alternatively does anyone have any example of a macro script that would work?

EDIT - I have found an ugly hack to do what I want to do. But am still looking for a way to do this in Writer. Below is the approach I have taken:

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.

C:\fakepath\Blank pages.odt

Test file created by leory method: C:\fakepath\test.odt

edit retag close merge delete

1

You haven't explained what you really want, and what you expect will happen when you add text. Do the numbers have to be printable? See your previous question 287282

If you just want printable blank pages with numbers at the beginning using your layouts then you could just do a numbered list on the first page. 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 page should fill with numbers, click Edit > Direct Cursor Mode to turn off Direct Cursor Mode.

Copy the list and paste it on each subsequent page.

( 2021-01-14 22:57:42 +0200 )edit
1

You are using 5 names for 2 page styles. You can use 2 styles (MP0 and MP1), activating headers and adding a frame to the header with a table with numbers. See sample file line numbers on existing blank pages.odt with table in MP0 style.

Tested with LibreOffice 6.4.7.2 (x86); OS: Windows 6.1.

( 2021-01-14 23:16:37 +0200 )edit

Good point @LeroyG. I would be inclined to combine both, although I don't understand the purpose of the exercise.

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

Take the numbered list I described from the first page and paste into frame. Adjust the frame so the numbers accurately align with some dummy text, ensure same style as body.

Copy and paste it into every page. Sequential numbering from 1 to around 16000.

( 2021-01-15 01:10:43 +0200 )edit

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.

( 2021-01-15 01:45:22 +0200 )edit

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

( 2021-01-15 02:29:05 +0200 )edit

@Earnest Al: 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.

( 2021-01-15 08:25:18 +0200 )edit

@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 page.style.

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.

( 2021-01-15 08:51:45 +0200 )edit

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

( 2021-01-15 10:51:05 +0200 )edit
1

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.

( 2021-01-15 12:01:39 +0200 )edit

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.

( 2021-01-15 12:43:36 +0200 )edit

Sort by » oldest newest most voted

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 6.4.7.2 (x64); OS: Windows 10.0.

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

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

more

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 ...(plus)

( 2021-01-18 12:20:24 +0200 )edit

I have tried both of these:

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


AND

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

screenshot

( 2021-01-19 12:35:59 +0200 )edit

@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).

( 2021-01-19 15:00:12 +0200 )edit

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?

( 2021-01-19 17:44:37 +0200 )edit

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

( 2021-01-19 21:09:29 +0200 )edit

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 6.4.7.2; 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

more

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.

( 2021-01-15 22:45:10 +0200 )edit

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 ...(plus)

( 2021-01-16 10:44:29 +0200 )edit

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

( 2021-01-19 10:49:24 +0200 )edit

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

( 2021-01-19 12:32:19 +0200 )edit