Page 1 of 1
The first page of document (not frontmatter) - different background
Posted: Tue Dec 03, 2019 3:54 pm
by DmitryS
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
.
Re: The first page of document (not frontmatter) - different background
Posted: Thu Dec 05, 2019 1:20 pm
by Costin
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
, 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
Re: The first page of document (not frontmatter) - different background
Posted: Tue Dec 10, 2019 2:31 pm
by DmitryS
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
Re: The first page of document (not frontmatter) - different background
Posted: Wed Dec 11, 2019 12:14 pm
by Costin
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
Re: The first page of document (not frontmatter) - different background
Posted: Mon Dec 30, 2019 5:06 pm
by DmitryS
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
Re: The first page of document (not frontmatter) - different background
Posted: Fri Jan 03, 2020 5:16 pm
by Costin
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
Re: The first page of document (not frontmatter) - different background
Posted: Fri Jan 10, 2020 12:53 pm
by DmitryS
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
Re: The first page of document (not frontmatter) - different background
Posted: Mon Jan 13, 2020 3:29 pm
by Costin
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
Re: The first page of document (not frontmatter) - different background
Posted: Thu Jan 16, 2020 9:36 am
by DmitryS
Thank you, Costin, it works on the topic's page.
But chapter number still appears in TOC. How to hide it?
Sincerely,
Dmitry
Re: The first page of document (not frontmatter) - different background
Posted: Thu Jan 16, 2020 7:19 pm
by Costin
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