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

Page break "avoid" does nothing at all #675

Open
keenmaster486 opened this issue Jan 28, 2024 · 0 comments
Open

Page break "avoid" does nothing at all #675

keenmaster486 opened this issue Jan 28, 2024 · 0 comments

Comments

@keenmaster486
Copy link

Title says it all. Yes I've googled and googled and googled and RTFM and whatever else that immediately comes to mind, and found nothing but many people experiencing similar issues but not quite the same, or people experiencing this issue and not getting any further than I have.

I have a flex div full of divs, with each child div being itself a flex container with a header, image, and some text.

The parent div is dynamically filled with child divs, and the number of them and their individual heights are not known prior to loading the page.

Telling html2pdf to avoid page breaks on the child divs does nothing.

Using 'avoid-all' also has no effect.

My syntax:

html2pdf().set({
    pagebreak: {
        mode: ['avoid-all'],
        avoid: ['.child-div-class']
    }
}).from(e).save();

No matter what I do, it breaks in the middle of a child div despite me explicitly telling it not to do that.

Using before or after results in one child div per page, which is unacceptable because they are too short to justify that. Besides, they also result in either one extra page at the beginning or one extra page at the end, so they'd be unusable anyway.

I tried version 0.10.1, but it outputted nothing at all, just two blank pages, so back to 0.9.3.

On the plus side, this thing is actually producing readable and nicely formatted output that looks like the browser-rendered page, unlike using jsPDF.html by itself, which produces utter garbage and won't even capture the entire input, only one page's worth. Just have to resolve this page break issue and it will be perfect.

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

1 participant