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.

Feature Request: header/footer template page number literal string injection

See original GitHub issue

There are currently several issues related to displaying headers and footers that are different between pages. Here’s a non-exhaustive list of related tickets:

#2167 #2089 #3383 #2961 #2916 #2089 #2484

Many of these issues stem from the lack of JS support in the header and footer templates as discussed in one of my previous issues: #2167. Looking at this list of issues, one of the common use-cases seems to be wanting to display headers or footers differently between pages. I wanted to propose a solution that would alleviate this main use-case while full script interpretation in the templates is still pending.

Currently the header and footer templates allow you to use class names to inject the page number into the html as referenced here. The current CSS spec does not provide a way to select elements based on content, but you can select elements based on attributes. My proposal is this: can the templates provide a way to inject the page number as a literal string in the html, and not through a class name. For example, a syntax like this:

<div>
    <h1 data-page="{{pageNumber}}">I only render on the first page</h1>
</div>

Which would be parsed as:

<div>
    <h1 data-page="1">I only render on the first page</h1>
</div>

Then using an inline style block, the page could be styled based on this data attribute like so:

<div>
    <style>
        h1{
            display: none;
        }
        h1[data-page="1"]{
            display: block;
        }
    </style>
    <h1 data-page="1">I only render on the first page</h1>
</div>

If this form of page number injection were possible it would likely alleviate this common use-case. Thanks for everyone’s hard work on this product!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:18
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
RockNHawkcommented, Jan 25, 2020

I resolved by generate PDF twice: first time: generate full PDF then get the pageCount; second time:gen the PDF page one by one and add a request parameter pageNumber=x then the page handle the request parameter to determine which page is current generating.

Last, megre all the PDF page into one PDF.

0reactions
stale[bot]commented, Jul 26, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add page numbers to a header or footer in Word
Add page numbers to a header or footer. Click or tap in the header or footer where you want the page numbers to...
Read more >
IBM Security AppScan Standard: User Guide
It features the most advanced testing methods to help protect your site from the ... Show only requests that contain the text string...
Read more >
Chapter 6: Layouts - Logback
Layouts are logback components responsible for transforming an incoming event into a String. The format() method in the Layout interface takes an object ......
Read more >
Templates
LitElement uses lit-html templates; this page summarizes the features of lit-html templates, for more details, see Writing templates and the Template syntax ...
Read more >
picocli - a mighty tiny command line interface
The converter annotation does not require a CommandLine instance so it can be used with the ... injected by picocli public static void...
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