The first page of document (not frontmatter) - different background

DmitryS
Posts: 21
Joined: Wed Nov 27, 2019 11:03 am

The first page of document (not frontmatter) - different background

Post by DmitryS » Tue Dec 03, 2019 3:54 pm

Hi again.
Please tell me how to provide the first page of the first chapter with it's own background image.
Is there some named page for this case?
I tried

Code: Select all

    @page :first {
background-image: url(page_background.svg);
    }
but it works exactly like

Code: Select all

"@page chapter:first"
.

Costin
Posts: 649
Joined: Mon Dec 05, 2011 6:04 pm

Re: The first page of document (not frontmatter) - different background

Post by Costin » Thu Dec 05, 2019 1:20 pm

Hello,

There is no dedicated named-page for the first page of the first chapter, but you could create a named-page of your own for this use-case.
More specific, you could set an "outputclass" attribute on the 1st chapter in your DITA Map / Bookmap, then match it through a CSS selector in your customization CSS and set a dedicated page style for it. Then, you should just select the very first page in the page sequence.

Let's say in your Map, you set

Code: Select all

outputclass="firstChapter"
, then in your customization CSS use:

Code: Select all

[class~="map/map"] > [class~="firstChapter"]{
	page: firstPage-firstChapter;
	border: 1px solid red;
}

@page firstPage-firstChapter:first {
	background-image: url("page_background.svg");
}
Best Regards,
Costin
Costin Sandoi
oXygen XML Editor and Author Support

DmitryS
Posts: 21
Joined: Wed Nov 27, 2019 11:03 am

Re: The first page of document (not frontmatter) - different background

Post by DmitryS » Tue Dec 10, 2019 2:31 pm

Hi Costin!
Thanks a lot! It works.
But works for chapter after TOC only. What should I modify to apply this solution to chapter with outputclass="before-toc"?
(I don't know how to combine two or more "outputclass". I found the 'before-toc' string in XSL file only.)

Sincerely,
Dmitry

Costin
Posts: 649
Joined: Mon Dec 05, 2011 6:04 pm

Re: The first page of document (not frontmatter) - different background

Post by Costin » Wed Dec 11, 2019 12:14 pm

Hi Dmitry,

It is possible to set multiple values for an attribute, separating the values with the whitespace character.
In your case, you could have multiple outputclass values, like:

Code: Select all

outputclass="firstChapter before-toc"
Regards,
Costin
Costin Sandoi
oXygen XML Editor and Author Support

DmitryS
Posts: 21
Joined: Wed Nov 27, 2019 11:03 am

Re: The first page of document (not frontmatter) - different background

Post by DmitryS » Mon Dec 30, 2019 5:06 pm

Hi Costin!
Unfortunately, they don't work together. The topic marked with outputclass="firstChapter before-toc" is before the table of contents, has its own background, but still has a number, despite the

Code: Select all

*[class ~= "map/map"][numbering ^= 'deep'] *[class ~= "map/topicref"][outputclass = "before-toc"][is-chapter]:not([is-part]) > *[class ~= "map/topicmeta"]:before {
    content: none;
}
Sincerely,
Dmitry

Costin
Posts: 649
Joined: Mon Dec 05, 2011 6:04 pm

Re: The first page of document (not frontmatter) - different background

Post by Costin » Fri Jan 03, 2020 5:16 pm

Hi Dmitry,

Actually they do work together, otherwise you either wouldn't have the page displayed before the Table Of Contents or wouldn't have the specific background set only for that first page.
It is only the selector you are trying to use is not the correct one.

More specific, among other default CSS files that oXygen comes predefined with, there is a "p-pages-and-headers.css" in Oxygen21_install_dir\frameworks\dita\DITA-OT3.x\plugins\com.oxygenxml.pdf.css\css\print folder which determines the default content for various named-pages, like the default page, toc page, frontpage, etc.

If you open that CSS document, you should see there are some rulesets that establish "default page layout":

Code: Select all

    @page :left {
        @top-left {
            content: string(maptitle) string(parttitle) string(chaptertitle) string(sectiontitle) " | " counter(page);
        }
    }

    @page :right{
        @top-right {
            content: string(maptitle) string(parttitle) string(chaptertitle) string(sectiontitle) " | " counter(page);
        }
    }
This is the CSS part that styles the page with the chapter title and page number.

So you could just overwrite it in your customization CSS, through a similar rule, based on the custom named-page you created previously ("firstPage-firstChapter") like that:

Code: Select all

@page firstPage-firstChapter:left:right {
        @top-left {
            content: none;
        }
    }
Regards,
Costin
Costin Sandoi
oXygen XML Editor and Author Support

DmitryS
Posts: 21
Joined: Wed Nov 27, 2019 11:03 am

Re: The first page of document (not frontmatter) - different background

Post by DmitryS » Fri Jan 10, 2020 12:53 pm

Hi Costin!
I should have been more precise. I need the title on this page to have no number, not a page. Selector in my CSS is about it.

Sincerely,
Dmitry

Costin
Posts: 649
Joined: Mon Dec 05, 2011 6:04 pm

Re: The first page of document (not frontmatter) - different background

Post by Costin » Mon Jan 13, 2020 3:29 pm

Hi Dmitry,

In this case, you could use another selector that matches the number before the chapter title.
In such cases, when you need to debug your CSS customization, you should use your internet browser's inspector to analyze the intermediary merged.html file and identify the rules that are applied on specific elements, so you could then override those specific selectors in your customization CSS. Please see more details on this technique in the Debugging the CSS section from the DCCP User-Guide.

In your specific case, there is a CSS rule coming from a default CSS that comes with oXygen (p-i18n-en.css) and which looks like:

Code: Select all

[class~="topic/topic"][is-chapter]:not([is-part]) > [class~="topic/title"]::before {
    content: "Chapter " counter(chapter) ". ";
}
that you should override in your customization CSS, like:

Code: Select all

*[class~="before-toc"][is-chapter]:not([is-part]) > [class~="topic/title"]::before{
	content: none !important;
}
Regards,
Costin
Costin Sandoi
oXygen XML Editor and Author Support

DmitryS
Posts: 21
Joined: Wed Nov 27, 2019 11:03 am

Re: The first page of document (not frontmatter) - different background

Post by DmitryS » Thu Jan 16, 2020 9:36 am

Thank you, Costin, it works on the topic's page.
But chapter number still appears in TOC. How to hide it?

Sincerely,
Dmitry

Costin
Posts: 649
Joined: Mon Dec 05, 2011 6:04 pm

Re: The first page of document (not frontmatter) - different background

Post by Costin » Thu Jan 16, 2020 7:19 pm

Indeed, it is not possible to remove the number in the TOC, in the version 21.
I've already logged this in our internal issue tracking system so our development team will implement an improvement in the next version of oXygen.

If that's urgent and if you are interested to test the latest version of an internal nightly build, just let us know on support@oxygenxml.com.

Regards,
Costin
Costin Sandoi
oXygen XML Editor and Author Support

Post Reply