-
Notifications
You must be signed in to change notification settings - Fork 543
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
page-break-inside: avoid is erratic #223
Comments
I'm using those css rules |
Also unable to get custom fonts to work. Looks like we will be switching to a different tool unless these issue can be fixed. |
@sjohnson32 I ended up using wkhtmltopdf. There is an npm package which make the interface between the binary and your node module. I can use custom font, and the page breaks (in or out of table) work like a charm. I don't know about the absolute elements, but you can give it a try. |
lol. I initially used this module because I wasn't able to get wkhtmltopdf to work at all. Regarding the Sorry for the issues. I can't do much to fix those. Maybe we can put together a list with all the issues, so people are aware of them when they try to use this module or another one based on phantomjs. |
@marcbachmann In fact the linked module is only an interface between the binary and the node application. You have two options, install wkhtmltopdf on your environment, or define the path of the binary to use. In my case it was the second option, as I'm making a nwjs application which must embed the binary. Anyway what you are proposing could also be a great option, in my case it wasn't really what I needed. |
It just ignores the page-break-inside property.... |
I have the same issue with WKHTMLTOPDF 0.12.4, regardless of browser used. in a webapp. Even when I say media="print" the print-window/-console does not adhere to the setting, in any browser on Windows. Very frustrating, even making all elements display:block; (which is a prerequisite). It does not matter if I try this on a Hx, p, table, tr, td or div, on all HTML-tags this CSS-setting is ignored. Anyone having this working anywhere? The settings page-break-before and page-break-after at least are working in the print-window/-console. But not the -inside setting :-( UPDATE: found a solution/workaround and posted it here: wkhtmltopdf/wkhtmltopdf#2982 |
Has anybody found a solution to this issue? |
I solved it by adding the following css class to the element you prefer not to break (say the inner-most div you wish to keep in tact):
I have seen it in this StackOverflow post . |
In my case, the problem was a parent element with |
This problem is still relevant. |
Has anybodoy another working solution? |
@augustosnk12 I noticed that |
@vasco3 Thanks for the answer but I'm not using any flexbox in my code... :'( |
@augustosnk12 are you using grid? |
@vasco3 I'm using tables |
Avoid to use thead. It work to me while text inside thead become double at the end of page and the top of page below. |
I've tested the html in chrome print preview, the css is correct but |
I had |
I have a complex html template that I am converting to a pdf. It has icons created from several absolute positioned elements. I do not want the page to break in the middle of these icons. I am using css to tag the icon container with "page-break-inside: avoid". When I print the html from the browser, the page breaks work correctly so I'm confident the css is correct. But when the pdf is rendered this css is not honored and the page breaks split the icons.
I am using the same css on another container that contains only text and the page breaks properly around it.
So my question: is there anything in node-html-pdf that would keep certain elements from honoring the css?
I have tried adjusting the page height, format, borders, css and have seen no change to the icon issue.
The text was updated successfully, but these errors were encountered: