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 is not working properly #183

Open
jack2jm opened this issue Sep 20, 2022 · 3 comments
Open

Page break is not working properly #183

jack2jm opened this issue Sep 20, 2022 · 3 comments

Comments

@jack2jm
Copy link

jack2jm commented Sep 20, 2022

how should I prevent it?? page break is not working properly. I had attached a screenshot here.

error 1

this is my HTML page - http://52.33.128.210/pdf-htmls/test6.html

I am generating this HTML using a dynamic section. so should i prevent a proper page break?

@phreniq
Copy link

phreniq commented Oct 12, 2022

CSS Page-breaks are a fickle beast. In order for this to work the way you expect, there are a few rules you need to follow with the structure of your HTML. First, break-* CSS rules will only work on block-level elements; display: block; (no inline-block, flex, or grid allowed). Second, and hopefully this is no longer a thing, don't use float. Lastly, if you are using anything other than position: relative; on the elements where you want breaks applied AND their parents, your mileage may vary.

I hit a similar issue and after learning the facts above was able to make things work as expected. Good luck!

@Githubant123
Copy link

how should I prevent it?? page break is not working properly. I had attached a screenshot here.

error 1

this is my HTML page - http://52.33.128.210/pdf-htmls/test6.html

I am generating this HTML using a dynamic section. so should i prevent a proper page break?

@phreniq
Copy link

phreniq commented Dec 19, 2022

I ended up upgrading the dependencies to get latest Puppeteer v19. Now I can use the latest CSS break-* rules (break-inside: avoid; is what you want). There were only 2 or 3 breaking changes (Winston was one of them) to work thru. It was pretty painless. You will also need to include a .puppeteerrc.cjs file to define the cacheDirectory if you are deploying to Heroku.

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

3 participants