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

Ability to change header in the middle of the document #229

Open
mattiuusitalo opened this issue Apr 19, 2023 · 5 comments
Open

Ability to change header in the middle of the document #229

mattiuusitalo opened this issue Apr 19, 2023 · 5 comments

Comments

@mattiuusitalo
Copy link
Contributor

We need to add chapter name to the header. It could be useful to add something like
[:new-header ....]

which contains the new header that will be applied after that.

@mattiuusitalo
Copy link
Contributor Author

I suppose #154 covers a bit of this. It's only that I need the Document object itself also.

So if append-to-doc would be

(defn- append-to-doc [stylesheet references font-style width height item ^Document doc ^PdfWriter pdf-writer]
  (cond
    (= [:pagebreak] item) (.newPage doc)
    (= [:clear-double-page] item) (clear-double-page stylesheet references font-style width height item doc pdf-writer)
    :else (.add doc
                (make-section
                 (assoc font-style
                        :stylesheet stylesheet
                        :references references
                        :left-margin (.leftMargin doc)
                        :right-margin (.rightMargin doc)
                        :top-margin (.topMargin doc)
                        :bottom-margin (.bottomMargin doc)
                        :page-width width
                        :page-height height
                        :doc doc
                        :pdf-writer pdf-writer)
                 (or item [:paragraph item])))))

This feature wouldn't have to be in the core but provided by the client.

@mattiuusitalo
Copy link
Contributor Author

Actually, looks like one can access the Document from PdfWriter

@yogthos
Copy link
Collaborator

yogthos commented Apr 26, 2023

Yeah, you can use that hook to get to the doc. If there's an improvement for ergonomics here that would be useful I'm open to a PR as well. :)

@mattiuusitalo
Copy link
Contributor Author

I could add some info about this extensibility feature in the README as it is a bit buried at the moment? That would promote the feature even without making a new release.

@yogthos
Copy link
Collaborator

yogthos commented Apr 26, 2023

That would be much appreciated. 👍

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

No branches or pull requests

2 participants