Forum How do I...?

Blank Page Use Footer from Previous Page

barrett777
Hello,

I tried searching the forum, but could only find cases where users wanted to remove footers from blank pages

I have two sections. The second section has style 'page-break-before: right;'

Because of this, sometimes a blank page is inserted between the sections

This blank page does have my global header, but no footer

I want it to use the section specific footer from the previous section; I want the blank page to be part of the previous section

Can I do this?

Edited by barrett777

dauwhe
Have you tried used the blank-page pseudo-class to control what footer appears on blank pages?

Thanks,

Dave
barrett777
Hi Dave,

Yes, but I can only apply that globally. I'm wanting to use my section-specific footer on blank pages that are inserted between sections
mikeday
Are you also using named pages for the sections? eg. "@page section:blank { ... }"

Alternatively, perhaps you could use page-break-after on the first section instead of page-break-before on the second?
barrett777
Thanks for the reply! I've spent a couple hours banging my head on this. I've got close but not quite there.

Here is how my HTML structure used to go:

<div TableOfContents>
<div TOC Footer></div>
</div>
<div Content Section 1 style='page-break-before: right;'></div>

In this scenario, my problem is that a blank page is inserted between the Table of Contents and the Content. I want this blank page to have the footer from the Table of Contents.

I tried addressing @page TOC:blank, but this did not apply to the blank page between the TOC and content.

I tried doing page-break-after on the TOC instead of page-break-before on Content, but this still did not apply to the blank page between

My current 'closest' scenario:

I've added <div style="page-break-before: right;"></div> inside of the Table of Contents div, at the end.

New HTML structure:

<div TableOfContents>
<div TOC Footer></div>
TOC Content...
<div style='page-break-before: right;'></div>
</div>
<div Content Section 1></div>

This does create a blank page with the TOC footer, which is great! However, this creates a 2nd TOC page after this, but it is not considered 'blank'. I'm guessing this is from the empty div.

I've attached my HTML file. I have two questions here:

How to get rid of the 2nd 'empty' page after the intended blank page?

Is there a way to specify @page:blank:left and @page:blank:right?

Edited by barrett777

barrett777
Or are there any other alternatives?

I'm using a CSS counter for something else, and that persists until I reset it

Is there any way to set/save a string using CSS or Javascript or something in the Table of Contents, and then apply it to the footer between the sections?

There are a lot of sections in the book, so I need to be able to change what is in the footer for these blank pages between sections
mikeday
I will take a look.
mikeday
You can use the CSS string-set property to save a string value which can be used in the footer.
barrett777
Ooh this looks good, thanks! I'll try this out tomorrow and let you know if it solves my problem
barrett777
Okay I'm getting closer to the problem :) I wasn't able to put anything into the global footer, so I dug deeper.

I have two problems. One of them I can't replicate so it's probably my own issue somewhere in my mess of HTML. I'll figure that out later.

The second problem, I've attached 3 small demos. Basically, I have two sections, each with their own footer. It doesn't matter where I put a page break between the sections, they always use the second section's footer.

I think I have a workaround for this, but this would be much simpler for me if this was a bug fix :)

In my opinion, the blank page inserted in Demo 1 should belong to the first section, and use the first section's footer.

I also feel that Demo 2 should use the first section's footer, but that is more debatable.

Even if you disagree with me, though, I think there should be some way to use 'page-break-after' and have the added page use the previous section's footer.

Please let me know if this makes sense or if I'm misunderstanding something :)
  1. Demo 1 - Page Break Within First Section - Uses Second Section Footer.html0.6 kB
  2. Demo 2 - Page Break After First Section - Uses Second Section Footer.html0.6 kB
  3. Demo 3 - Page Break Before Second Section - Uses Second Section Footer.html0.6 kB
barrett777
So I found a solution for my situation, in case others have this problem.

I couldn't find any way to insert a blank page which uses the footer from the previous section.

What I ended up doing is basically using the Section 1 footer for all Section 2 blank pages:

@page Section2:blank {
@bottom {
content: flow(Section1Footer);
}
}

#Section2 {
page-break-before: right;
page: Section2;
}

Drawback: This only works if you don't use blank pages within 'Section 2', since you are basically giving all of these to your previous section.

I hope a better solution will be found in the future. Personally I believe the best solution would be that 'page-break-after: right' would add a blank page that is part of that section. Currently, no matter how you insert a blank page, it is part of the next section.

Edited by barrett777

mikeday
We will take another look at the page breaking behaviour, it's a tricky situation as any break point can potentially involve multiple adjacent blocks.
mikeday
The latest builds now make the blank page belong to the previous section, which should help in this situation.
arthurattwell
I've been testing this in the latest builds. In my case, I need blank pages to belong to the previous section for PDF page labels to be accurate (e.g. where a blank exists between roman numeral pages and decimal pages, the blank must have a roman-numeral PDF page label).

* In 10r7 I get unpredictable results from `page-break-after: left` vs `page-break-after: right`. (I've attached a zip containing a sample. My CSS file includes comments explaining the issue.)

* In build 20160331, when using `page-break-after: right` to create a blank left, the blank correctly belongs to the previous section. However, `page-break-before: right` no longer seems to work at all. (I've attached two samples as variations using build 20160331, one using page-break-after and one using page-break-before.)

I assume this'll be fixed in a future release. When it is, when using 'page-break-before: right', will the blank page created belong to the previous section or the following section?

I suspect in most cases it's best if it belongs to the previous section, since the next section intuitively starts on the right, not on the blank. However, I imagine that this could break some existing documents that depend on the blank belonging to the previous section (e.g. double-page-spreads with a background-color).
  1. 10r7.zip46.9 kB
  2. build20160331-test-1.zip50.6 kB
  3. build20160331-test-2.zip50.1 kB
mikeday
There was another issue involving interaction between @page:break and page-break-before on multiple input documents. This has now been fixed in the latest builds, thanks for letting us know! :)