Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Extra Header / Footer Options #12

Closed
beeing opened this issue Feb 14, 2021 · 20 comments
Closed

Feature: Extra Header / Footer Options #12

beeing opened this issue Feb 14, 2021 · 20 comments
Assignees
Labels
enhancement New feature or request

Comments

@beeing
Copy link

beeing commented Feb 14, 2021

Hi, this is a library that I've thought of as an idea earlier. And thanks for sharing such useful library.

Just to make this library more versatile, there's some features that may be useful for more presentable reports.

  1. Different first page header / footer
  2. Custom "start from" page number
  3. Odd/even page header / footer (not so important, usually for printing)

Hope you can consider the above options for your library.

Thanks in advance.

@PejmanNik
Copy link
Owner

Hi, Thank you for using it. 👍😁

Nice. I also have some useful features in mind, but I'm not sure how many users this package has. I'll be happy to develop it as long as it can help a few people.

By the way, I'm open to any PR.

@PejmanNik PejmanNik added enhancement New feature or request good first issue Good for newcomers labels May 2, 2021
@rafipiccolo
Copy link
Contributor

i use this package sinces many months to generate people presentations : description, photos, admin documents, ... pretty nice rendering

@PejmanNik
Copy link
Owner

Thank you @rafipiccolo

@gmcouto
Copy link

gmcouto commented Jun 17, 2021

I love this package as it lets me render properly footer and headers due to DPI change. What would be nice to have is the code for header and footer to be on a different html, so it's styles doesn't have to be on the main HTML also.

@PejmanNik PejmanNik removed the good first issue Good for newcomers label Jun 19, 2021
@rhadamez
Copy link

rhadamez commented Jun 29, 2021

I have been searching this last week of some good library to generate pdf using nodejs at backend, the ones I found I get some problems like: performance, problems to render different header/footer, and the ones that solve these problems has a terrible syntax to code. Maybe this one is gonna get what I need. Gonna have a look.

@jpike88
Copy link

jpike88 commented Sep 2, 2021

This feature is a dealbreaker for us, as we just want a header on the first page of the reports we make. We're currently using MPDF and would switch to this if it had that function

@PejmanNik
Copy link
Owner

@jpike88 There is a similar request, you can subscribe to get updated when it added to the lib
#31

@PejmanNik
Copy link
Owner

@beeing I'm here with a piece of good news :)

I'm working on a new React Lib (like React-pdf) but using puppeteer as the pdf generator in order to support HTML/CSS/JS. And that will resolve all these issues. We can customize the rendering algorithm in any way. So there will be all of the requested features with way more like footer notes, left/right static parts, custom tables, watermarks, etc.

I'll link all other requests to this one; hopefully, we will have a beta version in a month or two.

@PejmanNik PejmanNik self-assigned this Sep 12, 2021
@PejmanNik
Copy link
Owner

As an update, we will have these components in the new lib. I think it will cover almost all the requested features.
Untitled-2021-07-27-0817

@jpike88
Copy link

jpike88 commented Sep 20, 2021

great news! love the mockups

@leqwasd
Copy link

leqwasd commented Dec 7, 2021

Hi, I am considering using this. At this point, we are generating static HTML with react and react-dom/server, then feeding that html into Puppeteer's page, and rendering PDF.

I don't even care about the page numbers themselves, I just want a different footer on the first page, and a different on all of the other pages. The current "api" for detecting that is rather... Unappealing.
In React - you cannot make onchange attribute like "onchange = onChange(this)", I had to add this line in the scripts to bind this the change function document.getElementById("footer").setAttribute("onchange", "onChange(this)");

Beside, having a footer like this:

        <div id="footer">
            <div id="footer-innner">
                pageNumber: <span className="pageNumber" />
            </div>
        </div>

And included script like this:

    document.getElementById("footer").setAttribute("onchange", "onChange(this)");
    function onChange(element) {
        const pageNumberElement = element.getElementsByClassName("pageNumber")[0];
        if (pageNumberElement.textContent === "1") {
            document.getElementById("footer-innner").style.display = "none";
        }
        if (pageNumberElement.textContent === "2") {
            pageNumberElement.style.color = "red"
        }
        if (pageNumberElement.textContent === "3") {
            pageNumberElement.style.color = "blue";
        }
    }

Just hides "the first" footer, but prints red on the first page, blue on the second page and nothing on the third page.
I just think, this is too fragile system and API.

Why can't they just finish the darn CSS Paged Media Module Level 3 thing...

As I understand.. You cut #footer and #header, along with <style> and <script> tags, and make a new "page" to render a footer and header separately, right? If so, I think, if you would inject into heade a script, which just defines those 3 variables (pageNumber, pageCount and title) as a global variables.

then detecting the changes would be sipler -

<!-- This would be injected by the puppeteer-report -->
<script>
window.pageNumber = {x};
window.pageCount = {y};
window.title= {z};
</script>
<!-- This would be copy/pasted from our HTML -->
<script>
if (window.pageNumber % 2 === 0) {
    document.getElementById("footer").classList.add("odd");
} else {
    document.getElementById("footer").classList.add("even");
}
</script>

@1valdis
Copy link

1valdis commented Dec 17, 2021

@PejmanNik , you were not sure how many people would use this package... So after a few hours of banging my head against puppeteer's built-in pdf rendering, and particularly its issues around header and footer, your library is a lifesaver. It is so simple to use and I don't have to split main body, header and footer into different htmls and somehow hardcode/load them, they all just stay in one document and it's so convenient. Not only that - but works like charm too. Thank you very much for it!

To everyone who came here from Puppeteer issues list, definitely give this lib a try!

@zacol
Copy link

zacol commented Mar 14, 2022

@PejmanNik Hi there :) Can you share with us what is the current progress? Maybe we can help somehow with the development?

@PejmanNik
Copy link
Owner

@zacol Hi, Thank you, sure.
The development is almost done. But I think it needs a lot of tests to cover all the edge cases, but unfortunately, as the core parts are already done, and I need to do a lot of tests + debug + fix without any challenges, it is extremely frustrating for me, and I don't have any progress in the past month.

I'll try to clean the project and make it ready for the test, maybe you or anyone else have time to run more tests, and we can finally publish a beta version.

So in summary, the project needs a lot of tests + documentation.

@PejmanNik
Copy link
Owner

As an update I'm working on documentation now, I have only weekends and can take a while but I had great progress, also published this blog today about it:
https://dev.to/pejmannik/jikji-layout-library-for-building-effortless-reports-in-react-4op4

@ChronicStone
Copy link

Hi @PejmanNik,

I've been quite hyped when you released your article, been following the progress since you announced your project, and I am really interested into helping testing / contributing. Are we gonna see an alpha/beta hit soon? Do you need any help to finalize / document the project?

Anyway, thanks for your work, even puppeteer-report is really well made, looking forward to see Jikji in action 😄

@PejmanNik
Copy link
Owner

Hi @ChronicStone, thank you for your interest. ❤
Yes, I think I'll release the alpha version next weekend. and I'm sure there will be a lot of bugs that need to be fixed. I will be happy to see your PRs 😁.
I just published the documentation, I appreciate it very much if you have time to review and create PR to improve it, I'm not the best writer 🤦‍♂️

https://github.com/PejmanNik/jikji
https://jikji.xyz/

ah, Thank you very much 🤩

@ChronicStone
Copy link

@PejmanNik Hi there,

Went through the docs, and this really looks amazing ! Some parts of the docs are a bit confuse, but guess I first need to play around with the lib to help improve it.

Can't wait to try the beta. when can he expect to start playing with it?

@PejmanNik
Copy link
Owner

Fair enough. I think it should be ready by next weekend.
Can you please point me to which pages were confusing to you? Thank you

@PejmanNik
Copy link
Owner

@ChronicStone or anyone interested, I just publish the entire library and appreciate any feedback.
https://github.com/PejmanNik/jikji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

10 participants