-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
make pageMargins dynamic #368
Comments
Yes, would be very helpful to be dynamic. I'd like to generate a different report footer just for the last page. It would nice to have pageMargins accept a function just like header/footer that has two parameters of currentPage and pageCount. |
+1 |
3 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
1 similar comment
+1 |
+1 |
1 similar comment
+1 |
i solve my problem with different header heights changing follow functions in documentContext.js.
so i can set a function in docDefinition for pageMargins like:
I save the pageMargins in the page object whenever a new one is created and if the parameters are needed I get them from the currentPage. sorry for my english, isn't my favorit language. |
@icke792 Can you create a pull-request for it? |
This was really useful for me. Please add it to the project. There seems to be a small fix to make it work with dynamic horizontal margins:
|
+1 |
2 similar comments
+1 |
+1 |
@hobbsi Did you just edit the source, build it and roll your own version? |
I used it while doing some experimentation on a personal project. And yes, that's what did. I believe you could also fork the project and do your modifications... I didn't. |
@hobbsi How would you apply this, once implemented, in the document definition? |
@liborm85 any chance the approach of @icke792 with the fix of @hobbsi gets merged if I would create a PR? Also, I have the need for a dynamic margin based on a dynamic header (see #2238) which is even a step further than what we have here. Any chance a solution taking dynamic headers into account gets merged in the end? |
A work around can be setting the content margins to negative value (only top margin) and passing an empty string to the header function. For example: pageMargins : [30, 140, 30, 30] Then on the page where you don't need header, after passed the empty string, you can sett: content.margins: [0, -110, 0, 0 ] |
Will it work for footers? |
If anyone wants to create bigger footer on a specific page you can just put your items in the footer with page condition and give it |
If you have dynamic content - ie tables that span over multiple pages it can be difficult to determine where each new page header footer dimensions should be used from just the page number I added the following code to icke792's (thanks) above
|
Did you solve the issue? |
This comment was marked as spam.
This comment was marked as spam.
I'm looking for this as well. We have a report with dynamic headers, and I need to set the page margins according to the header size. Currently, because of the limitation, I have to truncate the header in order for it to fit. But when the header is shorter, there is a gap between it and the content of the page. I'm not sure how this can be solved since the header needs to know the left and right margins in order to render, but the content needs to know the top margins, depending on the header height, in order to render; it's the chicken and the egg problem. Edit: this could be solved with the possibility to have a margin value of |
Has anyone found a solution for this? |
Can I determine It's the last page of the pdf and assign different page margin for it? |
+1 |
Books are binded and therefore have different page margins for odd and even pages, so that the text on the page appears to be in the middle and not squeezed into the books fold. I searched the documentation/issues and tested it, the pageMargins seem to be static.
The text was updated successfully, but these errors were encountered: