question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Table headers duplicated when rendering PDF

See original GitHub issue

What happens: printing the final PDF, the table header seems to be repeated over all the table randomly (see attached pic).

When it happens: My code renders fine on the “edit” mode, fine on the “print” mode (clicking on ‘get PDF’) but the issue appears on the printing preview windows to actually print or save the PDF. If I save the PDF the issue remains.

Note: I’m using Chrome on a Mac. It seems happening if you have a two-column section, then a <div class='wide'> , followed by a table in a two-column section (see brew code below). Do you see the same problem? Is there a way to fix it?

schermata 2017-01-31 alle 15 43 49

Additional Details

Brew code to reproduce :

Click to expand


<div class='wide' style='text-align: center;'>
# Character Name
</div>

 
**Concept:** Character Concept

Some text here for the description of the character to be. Some text here for the description of the character to be
 


<div class='wide' style='text-align: center;'>
### ~~ :: ~~ :: ~~ :: ~~
### Charisma:  +2  ;  Parry:  5  ;  Pace:  6”  ;  Robustness:  5
</div>

##### Cookie Tastiness
| Tastiness | Cookie Type |
|:----:|:-------------|
| -5  | Raisin |
| 8th  | Chocolate Chip |
| 11th | 2 or lower |
| 14th | 3 or lower |
| 17th | 4 or lower |
| 8th  | Chocolate Chip |
| 11th | 2 or lower |
| 14th | 3 or lower |
| 17th | 4 or lower |

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
calculuschildcommented, Feb 3, 2017

Solution:

Add this bit of CSS to the code:


.phb table thead { display: table-row-group;}

From w3 schools: “…when printing a large table that spans multiple pages, the [thead and tfoot] elements can enable the table header and footer to be printed at the top and bottom of each page.” It looks like the column-span: all is somehow causing subsequent tables to confuse chrome’s PDF printer about where the top of a new page is. display: table-row-group will force it to print just like any other table row, only once per page.

1reaction
calculuschildcommented, Feb 3, 2017

I would recommend it be added to the codebase, yeah. There might need to be some testing to make sure it didn’t mess anything else up, but I’m pretty sure it wouldn’t.

My real question though is why the column-span: all is causing the PDF printer to get confused in the first place. Might be a bug in Chrome’s PDF rendering backend (and they do have lots of bugs), or something else in the Homebrewery making it weird. I did a test on my local machine with some unstyled html, but the printing bug doesn’t show up until I apply the Homebrewery css styles to it. It didn’t seem to be anything within the thead sections that was causing the problem (deleting them changed how the headers looked but they still printed all over the table).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disable table header repeating on page break when ...
PhantomJS seems to have issues with trying to make the table headers repeat on page breaks; the headers are sometimes in ...
Read more >
Repeat HTML Table in Render as PDF VF Page [duplicate]
In my PDF Visualforce page, below table breaks and goes to new page. Is there any way that I can repeat the header...
Read more >
Tagging repeating table header
The repeated Header rows in tables that span 2 or more pages/columns is an error that started around InDesign 2019. The duplicate headers...
Read more >
Adding columns duplicates table header
I want to add two more columns into the table but for some reason my table header duplicates itself. Screencap: :.
Read more >
Repeated Table Headers
To repeat the <thead> elements on each page, set the repeatHeaders option. For more information on how to render recurrent table headers with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found