Add Blank Pages before end

Post here questions and problems related to editing and publishing DITA content.
scarey
Posts: 6
Joined: Mon Dec 08, 2025 5:11 pm

Add Blank Pages before end

Post by scarey »

I have a backmatter topic (an address page) at the end of my bookmap

Code: Select all

<backmatter><topicref href="addresses.dita" toc="no"></topicref></backmatter>
I have a custom page style for the backmatter to add a date to the footer

Code: Select all

@page back-cover{	
	@top-left   { content:none !important;}
	@top-right  { content:none !important;}
	@bottom-center { content:none !important;}
	@bottom-right { content: oxy_xpath('format-date( current-date(), "[Y0001]-[M01]-[D01]", "en", (), ())'); }
}
*[class ~= "map/map"] > *[class ~= "topic/topic"][is-backmatter] {
  page: back-cover;
}
I want to insert 3 blank pages before the final page so I added the following to my CSS:

Code: Select all

/* add blank pages before back page */
@page my-blank-page { 
    /* Hide the page numbers */
    @top-left {content: none;}
    @top-right {content: none;}
    @bottom-left {content: none;}
    @bottom-right {content: none;}
}

*[class ~= "map/map"] > *[class ~= "topic/topic"][is-backmatter]:before(2){
    page:my-blank-page;
    display:block;
    content: '\2002';
    break-after:always;
}

*[class ~= "map/map"] > *[class ~= "topic/topic"][is-backmatter]:before(1){
    page:my-blank-page;
    display:block;
    content: '\2002';
    break-after:always;
}
If I have only one 'before' statement, it adds a single blank page that matches the 'my-blank-page' template.
If I use the code above, the first blank page takes on the 'back-cover' template (with the date), then it's followed by 2 blank pages using the 'my-blank-page' template and finally the address topic.

This is more difficult to debug as the blank pages don't show up at all in the html file.

Have I set this up right? Is this even possible? How can I avoid it using the backmatter footer on the first blank page?
julien_lacour
Posts: 778
Joined: Wed Oct 16, 2019 3:47 pm

Re: Add Blank Pages before end

Post by julien_lacour »

Hello,

This is a little more complex because before/after pseudo-elements are usually "placed" inside the selected element.
A workaround could be to do the opposite: instead of adding the blank pages before the backmatter topic, you could add them after the backmatter preceding sibling (the last part of chapter of your bookmap):

Code: Select all

*[class ~= "map/map"] > *[class ~= "topic/topic"]:not([is-backmatter]):has(* + *[class ~= "topic/topic"][is-backmatter]):after(1) {
    page:my-blank-page;
    display:block;
    content: '\2002';
    break-after:always;
}
*[class ~= "map/map"] > *[class ~= "topic/topic"]:not([is-backmatter]):has(* + *[class ~= "topic/topic"][is-backmatter]):after(2) {
    page:my-blank-page;
    display:block;
    content: '\2002';
    break-after:always;
}
*[class ~= "map/map"] > *[class ~= "topic/topic"]:not([is-backmatter]):has(* + *[class ~= "topic/topic"][is-backmatter]):after(3) {
    page:my-blank-page;
    display:block;
    content: '\2002';
    break-after:always;
}
Regards,
Julien
scarey
Posts: 6
Joined: Mon Dec 08, 2025 5:11 pm

Re: Add Blank Pages before end

Post by scarey »

Almost! That adds 3 blank pages as required but it does so after each chapter because all the chapters are adjacent to the backmatter

Adding 'nth-last-of-type(2)' seems to do the trick!

Code: Select all

*[class ~= "map/map"] > *[class ~= "topic/topic"]:not([is-backmatter]):nth-last-of-type(2):has(* + *[class ~= "topic/topic"][is-backmatter]):after(1) {
    page:my-blank-page;
    display:block;
    content: '\2002';
    break-after:always;
}
*[class ~= "map/map"] > *[class ~= "topic/topic"]:not([is-backmatter]):nth-last-of-type(2):has(* + *[class ~= "topic/topic"][is-backmatter]):after(2) {
    page:my-blank-page;
    display:block;
    content: '\2002';
    break-after:always;
}
*[class ~= "map/map"] > *[class ~= "topic/topic"]:not([is-backmatter]):nth-last-of-type(2):has(* + *[class ~= "topic/topic"][is-backmatter]):after(3) {
    page:my-blank-page;
    display:block;
    content: '\2002';
    break-after:always;
}
FWIW, this now means I can pad the back page and use an Adobe Acrobat script to remove the trailing empty pages until the page count is a multiple of 4

Thanks
Last edited by scarey on Fri Jan 16, 2026 6:55 pm, edited 1 time in total.
Post Reply