Force page title to be the highest heading level for a page
This page of the Scroll PDF doc: http://k15t.com/display/PDF/How+Scroll+Handles+Headings defines the default algorithm for promoting the highest level of headings found on a page to h1 because most users default to the page title + a general repeat of the page title as the first heading on the page. That makes sense as a general rule.
We stopped doing that a long time ago - our page titles reflect the page content, and don't repeat the title as a top heading (our introductory text just starts on the page). We use h2 headings to connote the highest level of subsections on the page, with h3, h4, etc. under that. So we have:
>Page title
intro text (if any)
>>Subsection1 (h2)
>>>sub-sub-section1 (h3)
>>Subsection2 (h2)
In my template, I have the Static Pages setting for Content configured to insert the page title as an h1 on every page, with a CSS rule to page break before every h1. However, the subsections (which were h2) are being promoted to h1 levels, which means the subsections are ending up on new pages, and inflating the size of my PDF export (129 Confluence pages has become just under 500 pages in PDF, with lots of half-blank pages).
Is there any method I could use to force the h2 headings on my pages to stay h2 in this scenario?
Thanks in advance -
Cassandra
-
As soon as I posted this, I had an idea and it seems to work.
I added a style to the Static Pages definition to force a page break before the page title, and then removed the rule from my CSS to page break before every h1. Now I get the behavior I want for my scenario.
For others who may be interested in the same, here is my definition for the 'Content' section of the Static Pages configuration:
<div style ="page-break-before: always;">
<h1>$page.title</h1>
</div> -
Thanks for the tip. It works.
However I faced a problem.
The page title now appears in the page that I'm exporting. However the "h2" headers are of the same size as the "h1" thus making the exported PDF look a bit weird with all the headers of the same size.
I know I can tweak the css. But is there any other way to let the page title to be treated as a "h1" header?
-
Hi James,
I don't know if I understand your problem right. Have you had a look at this page: http://www.k15t.com/display/PDF/Changing+the+Font+Size+on+the+Title+page
Does this help?Why doesn't change the font size of h1 (respectively h2) via CSS work for you? If you'd provide some further information, I'd be happy to help.
Cheers,
Nils -
Hi Nils,
My page has the following structure:
- Page title
- h2 header
- more h2 headers...
When I export my page as PDF, without the "title" page, I don't get the page title listed anywhere. All my "h2" headers are exported as "h1" headers with page breaks.This is the structure of my exported PDF:
- h1 header
- more h1 headers...
I understand this is the expected behaviour. So when I applied the "Static page" tweak, along with the css tweak to remove page break before "h1" headers, the page title appears as a "h1" header and so do my "h2" headers which are still treated as "h1" headers. So my exported PDF has the following structure now:
- Page title (h1)
- h1 header
- more h1 headers...
I understand, I can further tweak the css here to treat only the "page title" as "h1" and treat other "h1" (div.section1 h1) headers as h2.
Please sign in to leave a comment.
Comments
7 comments