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

Custom format on page numbering #158

Open
ayoyoness opened this issue Jul 7, 2018 · 10 comments
Open

Custom format on page numbering #158

ayoyoness opened this issue Jul 7, 2018 · 10 comments

Comments

@ayoyoness
Copy link

ayoyoness commented Jul 7, 2018

Hi,

would it be possible to use a custom format on the page numbers?
What we have at the moment is great but it should accommodate different formatting.
For example instead of: 1/7 , one could use 1 of 7 or Page 1 of 7 or in totally different language: Seite 1 von 7
Is this already supported?
alternatively, is there a way to obtain the total number of pages as well as the current page number? so that one can remove the default page numbering and add a custom one as part of the footer.

Many thanks,

@yogthos
Copy link
Collaborator

yogthos commented Jul 7, 2018

Hi,

I think this is what you're looking for:

(pdf
  [{:footer{:text "page"
           :footer-separator " of "}
    :pages true}
  [:paragraph
   "hello"]]
  "pages.pdf")

The above produces a footer that reads page 1 of x.

@ayoyoness
Copy link
Author

right!
would I still be able to have a "regular" footer while doing it this way?
or those two are mutually exclusive?
apologies if my questions are trivial... just a newbie :)

@yogthos
Copy link
Collaborator

yogthos commented Jul 8, 2018

It's one or the other. This way you can make a fancier footer that should do everything the regular footer does.

@ayoyoness
Copy link
Author

so how can i make a footer that is more than one line while still customizing the page number?
is there another key that could be used?

@ayoyoness
Copy link
Author

just figured a workaround... you can use both :table and :text
so a table with just a single column will do the trick... it's not pretty but it works :)

@ayoyoness
Copy link
Author

totally off-topic
but still related:
is it possible to use collate to merge a couple of pdfs,
and add the page numbering footer, that does count the total page and current page number?
that is on the overall resulting merged document.

@yogthos
Copy link
Collaborator

yogthos commented Jul 9, 2018

Ah yeah a footer table is the way to go there. Regarding collating, I don't think there's a way to do that currently. It might be possible to provide page numbering as part of the API, so then you could generate both PDFs, collate them, and add page numbers after.

@ayoyoness
Copy link
Author

yeah,
in the same that you could add watermark when generating a pdf,
we should be able to add a layer on top of two or more pdfs merged into a single document, to put in page numbers.

@yogthos
Copy link
Collaborator

yogthos commented Jul 10, 2018

Watermarks are already supported, so it could be a similar hook to that. There's a callback when each page is generated, and it could be exposed for an arbitrary function to post process the page.

@yogthos
Copy link
Collaborator

yogthos commented Jul 18, 2018

I don't think I'll have time to look at this in the near future, but if you'd be up for making a pr I can help with that.

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

2 participants