Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

wrong section in header/footer #3016

Closed
nathanwebb opened this issue Jun 23, 2016 · 3 comments
Closed

wrong section in header/footer #3016

nathanwebb opened this issue Jun 23, 2016 · 3 comments

Comments

@nathanwebb
Copy link

Hi,

When a page doesn't have any H1 tags, then the previous section is carried over. That creates a bug where the previous page had multiple sections. So the following takes place:

  1. On the first page, the section is determined as being the topmost H1 tag.
  2. On the first page, any additional H1 tags are ignored.
  3. On the second page, there are no H1 tags, so the topmost H1 tag from the previous page is the "section". I suspect that subsections (and subsubsections) are similarly affected.

If a page doesn't have any H1 tags, the bottom-most H1 tag of the previous page should be used as the section.

Steps to reproduce

Use this command with a minimal example:

wkhtmltopdf --header-center "[section]" basic.html test.pdf

input file - basic.html

<div style="page-break-after:always;">
  <h1>Title Page</h1>
</div>
<div style="page-break-after:always;">
  <h1>My first section</h1>
  <p>This is a section</p>
  <h1>My second section</h1>
  <p>Here is some text, for the second section</p>
</div>
<div style="page-break-after:always;">
  <p>This is text in the second section. The header should say that it is the second section</p>
  <p>Here is some text, for the second section</p>
</div>
<div style="page-break-after:always;">
  <h1>My third Section</h2>
  <p>Here is some text, for the this section</p>
</div>

Expected results

The third page header should say "My second section"

@garygreen
Copy link

I'm also experiencing this, it would make sense to have the "latest" header be the actual section rather than the first one output on the page.

@garygreen
Copy link

Seems like another issue is open #1654

@Tomsgu
Copy link
Contributor

Tomsgu commented Sep 25, 2018

Closing as a duplicate of #1654.

@Tomsgu Tomsgu closed this as completed Sep 25, 2018
@Tomsgu Tomsgu added Duplicate and removed NeedInfo labels Sep 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

4 participants