How to get Page Number & ~ Count on first page only if at least a second page follows?

I know how to specify the appropriate fields to get them placed, but I haven’t found a way to get them as a result* of a conditional field. … or any other combination of fields. *) works in conditions but the (2 possible) results seem to accept constants only.
Years ago I had no problems solving this, but after an update it didn’t work any more.
Now the only way I found to solve this is a more than clumsy and really ugly work around:
Put a frame containing the conditional field (condition: PAGE == 1) in front of (above) the page fields, specify the first of the results as █████ and format the Font of the frame’s content with appropriate attributes and effects. (size bigger than that of the text to hide, color white, negative kerning)

If anybody knows the correct, more elegant way to solve this, I’ll highly appreciate corresponding hints!


p.s.: OS = Manjaro Linux 6.4.6-1, LO = LibreOffice Community 7.5.5.2 (X86_64), save format ? … what is that and where to find?

I haven’t inserted an image. █ is a character (U+2588 FULL BLOCK). The “strokes” are the “spaces” between the characters with no negative kerning specified. █████ is a text constant that the conditional field accepts.

Header or footer doesn’t make any difference. (other than the position, which is neither a problem nor in the scope of the question.)

In case of multiple pages it looks, on the first numbered page like “1/3” or “1 von 25” or "Seite 1 von ". If it’s just a single page I want to suppress it completely.

And yes, I’ll prepare a stripped down version of the O(D|T)T-file - even though nobody who knows the solution without the work around needs it.
(If there’s indeed no direct solution any more, it might help others with the same question.)

Please, edit your question (= modify it, don’t add a comment; be contributor-friendly by grouping all necessary info at a single location) to make it understandable.

Start by mentioning OS name, LO version (all 4 digits) and save format.
Your inserted image is unreadable: black background with very thin low-contrast strokes; describe what it is made of.

Specify exactly what you want: is this a header or a footer? Does it look like “Page 1/3”, “Page 1” if there is a single page or nothing at all if there is a single page because there is no need then to number pages?

For best advice, attach a 2-page sample for analysis of your present solution.

@nitja
What does this mean:

„█“ U+2588

Since I did not (yet?) get the Hidden Paragraph to work in the desired way …

  • and no, @ grantler, the attached ODT in your post shows “1/1” in the footer
    (and “1/1” should never be visible, while “1/ᐸnᐳ” with n > 1 should) -

… here’s the above mentioned example with the work around:
test ᛌ꓆ dynamic꓆ ︖ᛌ header.odt (14.5 KB)

Click somewhere into the text area, delete a line(feed) and watch the 2nd page disappear together with the numbering on the first page.

p.s.: no idea, why this has been inserted here rather than as last post

Have you checked this on page preview (Toggle Print Preview) or in a printout?
I have checked this on page preview (no page numbers to see) and additionally on a PDF “printout”. Nothing in the footer…
Probably a problem of displaying hidden text (paragraph; character):
menu View | Hidden Field Paragraphs
.
:grinning:
.
EDIT
Instead of page preview better use print preview.
/EDIT

1 Like

WOW! - no, admittedly, I never thought that this could make a difference here, since it wasn’t necessary for my solution with nested fields in a much older version of LO.
It’s great and works for exports, like PDFs, JPGs … as well.

I gave a look at your sample file. It is badly formatted.


The date at the beginning should have its own paragraph style. With this simple solution you can flush it at right and also define in the style the spacing below it as well many other parameters.

Instead, you create a frame (styled Datum) which you anchored To Page. This anchor mode is wrong 99% of the time, though in your case you get the intended result because it is on the first page which I assume always exists. Inside this frame you insert a 1-column×1-row table. For which reason? The single cell contains a date field.

All this can be simplified to a simple paragraph with the date field. By playing with the style parameters you achieved the same result (and perhaps more) through a less stressing way (for Writer). In the end, your document is lighter, more stable and more reliable. And performance is improved.

You anchored frame Deckweiß für einzelne Seite To page because you wanted it only on the first page but since this frame is related to a “text object” which position can change with edits, the frame should be anchored relative to it. But then it would be repeated on every page because the “text object” is in the header. Read my solution with conditional paragraphs. To page is a very special anchor mode which is reserved for DTP-like jobs. Your document doesn’t belong in this category.

I don’t see the purpose frame Loch- & Falz-Marken anchored To paragraph in the footer. It is empty and used only once because it appears in a First Page-styled page. You seem to have copied it in subsequent pages but as direct formatting because the style is now Rahmen1, changing a bit the settings.

Apparently, the paragraph in this frame is only an anchor point for two other empty frames (Falsmarke oben and Lochmarke) but for borders. You could as well have anchored directly both latter frames in the footer. And this would make more sense since frames can’t be strictly constrained to remain inside another frame (you can alter position parameters to be relative to page).

As a general rule, always try to have the simplest and lightest structure in your documents. Don’t nest when it is not necessary. Don’t use frames or tables when you can do the same thing with text paragraphs. You won’t then struggle to fix interactions between elements. Mastering frames requires expert knowledge and even at this level you can’t always be sure that the planned layout is reached.

1 Like

@ajlittoz
The problem of businessletters is that the (by LO) given templates don’t refer to folding marks or punch marks. See the German DIN 5008 for businessletters:
.
DIN_5008_Form_A.svg
DIN_5008_Form_B.svg
.
It’s an annoying chore to fulfil each of the required DIN specifications. Neither Writer (frames) nor Word (tables) can handle the comlex demands in a sufficient way, IMHO.
Nevertheless your pieces of advice give good hints for stable and adequate creating of (business) documents. Thanks a lot!

If I have some time, I’ll try to design a mockup for it. Are the folding and punch marks repeated on every page? Or do they appear only on the first one?

There is no actual “law”. Many companies still use pre-printed stationary, so marks are on every page.
.
IMHO folding marks are only necessary on the first page. One will usually fold all sheets of a letter at once, when putting them in the envelope. When the stack is to big to fold, one would change to bigger envelopes. (A typical letter may have up to 3 sheetsplus envelope, before the price is increased…)
.
Punch marks can be useful on every page, as one may split a stack of sheets to fit a smaller hole-punch.

You could set folding and punch marks on page one and on each right page ore only on page one.
The DIN_5008_Form_B business letter has a bigger header for the company logo and likely is used more often. So page 1 could have First Page style. Following pages are regularly designed in another way, so Default Page style could do (left pages and right pages). It is sensible to create on all right pages the folding and punch marks…

Assuming you want to create a “dynamic” header or footer (until you give a detailed specification), you create as many header or footer paragraphs as you have cases.

Here, they are:

  • A the document has a single page
  • B the document has more than one page

which amounts to two case. Thus, you type two paragraph.

  • A the paragraph contains “Single page document” or nothing at all
  • B the paragraph contains “Page <page_number_field> out of <page_count_field>

Then put cursor at start of paragraph A, Insert>Field>More Fields, Functions tab, Type Hidden Paragraph, Condition PAGE==1. At start of paragraph B, do the same except condition is PAGE>1.

Of course, if paragraph A contains nothing at all, you can dispense yourself from creating it. The example above is given only to show that you can have as many different conditional headers or footers with as many condition expressions as you need. Make sure that the condition results are exclusive from each other, otherwise several paragraphs are visible (but this may be intentional).

If you want to edit the field attributes, enable View>Field Names otherwise one of the paragraphs remains hidden or, alternatively, enable View>Field Hidden Paragraphs.

Tested under LO 7.5.3.2, Fedora 38, KDE Plasma desktop

1 Like

In addition to @ajlittoz’ solution (only one step).


On old
https://web.archive.org/web/20220712144438/http://www.ooowiki.de/VersteckterAbsatz.html
you can find this solution:


You want the footer of your document to remain empty if the document is 1-page, but in a multi-page document you want a text “Page X of Y” to appear in the footer of all pages - including the first one. This cannot be solved with different page templates.
Instead, use the same page template for all pages where you have enabled the footer line. Insert the text “Page X of Y” into the footer, using the field command Insert → Field Command → Page Number for “X”, of course, and Insert → Field Command → Page Number for “Y”.

Finally, use Insert → Field Command → Other… → Functions to insert the Hide Paragraph field command with a condition such as PAGE L 2 in the footer. When the condition occurs - the document has less than 2 pages in total - the paragraph is hidden, the footer remains empty and the page text area increases downwards accordingly.

Translated with www.DeepL.com/Translator (free version)

EDIT
PAGE L 2 likely means the same as PAGE < 2
/EDIT

Source of image:
https://web.archive.org/web/20220712144438im_/http://www.ooowiki.de/attachments/VersteckterAbsatz/versteckter_absatz.png

versteckter_absatz


This solution was created for OpenOffice 2.x (or even StarOffice 4 or 5...), it still works on LibreOffice 7.5.5.2, see attached document:

NoPageCountOnPageOneIfNoOtherPageFollows.odt (9.3 KB)

1 Like