yumauri / gotenberg-js-client

A simple JS/TS client for interacting with a Gotenberg API
MIT License
110 stars 9 forks source link

Adding page numbers to PDF #64

Closed DeyvinC closed 9 months ago

DeyvinC commented 10 months ago

Hello @yumauri ,

I am currently using your package for converting my html files into pdf files. Thanks a lot by the way. But I'm running into a small issue. Is there any way to show page numbers on the generated PDF? For example "Page 1 of 3" and etc. I tried doing it in html but I believe the issue is when it comes down to the conversion html only reads one whole page but pdf converts it into multiple.

Your help would be greatly appreciated.

yumauri commented 10 months ago

Hello! Thank you for using my library, even though it was last updated long ago, and I still have it (upgrade to support latest Gotenberg) in my list 😅

Did you try adding footer, like it states in Gotenberg documentation? https://gotenberg.dev/docs/routes#header-footer-chromium

<html>
<head>
    <style>
    body {
        font-size: 8rem;
        margin: 4rem auto;
    }
    </style>
</head>
<body>
<p><span class="pageNumber"></span> of <span class="totalPages"></span></p>
</body>
</html>
yumauri commented 10 months ago

Also the same in the documentation for Gotenberg version 6, if you use it: https://gotenberg.dev/docs/6.x/html#header-and-footer

DeyvinC commented 10 months ago

Awesome thank you. I was looking at those docs but wasn't completely sure if it was also related to this npm package but thank you. The body style was the issue on why I couldn't see it. Got rid of that styling and now its visible.

yumauri commented 10 months ago

Did you resolve your question, can I close this issue? :)

yumauri commented 9 months ago

I conclude that you have resolved issue, so I'll close this one. Feel free to reopen it in case you experience problem again 👍