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

how does one enable page numbers like in your sample pdfs? #66

Open
milkshakeuk opened this issue Jan 22, 2025 · 3 comments
Open

how does one enable page numbers like in your sample pdfs? #66

milkshakeuk opened this issue Jan 22, 2025 · 3 comments

Comments

@milkshakeuk
Copy link

milkshakeuk commented Jan 22, 2025

see title

@milkshakeuk
Copy link
Author

I figured it out

@page {
  size: A4;
  margin: 1.20cm;

  @bottom-center {
    content: "Page " counter(page) " of " counter(pages);
  }
}

@FlorianHeigl
Copy link

FlorianHeigl commented Jan 23, 2025

for others: the above snippet is from custom.css, not the pdf stylesheet. since it's defined for @page it only applies to pag(inat)ed media and as such you don't see it except on print. I found a reference to a 'smashing magazine' article: designing for print with css which helped me understand a bit.

@milkshakeuk did you manage to also use @top-center somehow? I'm completely at a loss trying to get a chapter title on every page.

@nbanyan
Copy link

nbanyan commented Jan 24, 2025

@FlorianHeigl https://printcss.net/articles/page-margin-boxes has a lot of good info on print specific CSS and those location tags. In my attempts to use various HTML to PDF solutions I've found that some features like these may not work with some tools. It's possible that CSS features like these can work when using a browser's print dialog while being ignored by pypdf.

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

No branches or pull requests

3 participants