node-html-pdf icon indicating copy to clipboard operation
node-html-pdf copied to clipboard

Flexbox layouts don't work

Open jdidion opened this issue 10 years ago • 29 comments

I am using Stylus to generate the CSS for my web page. When I enable flexbox layout (flexbox=true), nothing is rendered by node-html-pdf, but Chrome displays the page fine. When I disable flexbox layout, node-html-pdf and Chrome render the same output.

jdidion avatar Apr 19 '15 18:04 jdidion

Flexbox works fine if you use Phantom JS 2.0 instead of 1.9 (the standard dependency). 1.9 used an old syntax of flexbox.

Lichtjaeger avatar Apr 19 '15 19:04 Lichtjaeger

@Lichtjaeger thanks for the hint. I'll integrate phantomjs 2 in this module as soon as it's stable on all platforms. That's also the case for the phantomjs module on npm. So we can simply switch the npm module. Until then you can use the phantomPath config option and use your locally installed phantomjs 2.

marcbachmann avatar Apr 20 '15 06:04 marcbachmann

Yes, I can confirm that it works when I install 2.0 and set the phantomPath option to point to the new location

On Apr 20, 2015, at 2:39 AM, Marc Bachmann [email protected] wrote:

@Lichtjaeger thanks for the hint. I'll integrate phantomjs 2 in this module as soon as it's stable on all platforms. That's also the case for the phantomjs module on npm. So we can simply switch the npm module. Until then you can use the phantomPath config option and use your locally installed phantomjs 2.

— Reply to this email directly or view it on GitHub.

jdidion avatar Apr 20 '15 10:04 jdidion

@jdidion hey how to install phantomjs 2? , i cant find a npm package for this

ripper2hl avatar Jul 23 '15 17:07 ripper2hl

@ripper2hl you have to install the binary yourself. You can use apt-get install, brew or a docker container.

marcbachmann avatar Jul 23 '15 17:07 marcbachmann

Okay, thanks very much !!

ripper2hl avatar Jul 23 '15 17:07 ripper2hl

[email protected] now uses phantomjs v2. Have fun

marcbachmann avatar Feb 16 '16 22:02 marcbachmann

Thanks for the update!

On Feb 16, 2016, at 5:41 PM, Marc Bachmann [email protected] wrote:

[email protected] now uses phantomjs v2. Have fun

— Reply to this email directly or view it on GitHub https://github.com/marcbachmann/node-html-pdf/issues/24#issuecomment-184904393.

jdidion avatar Feb 16 '16 22:02 jdidion

hi flexbox ins't supported. I use recent version of html-pdf thanks

MOUMBE avatar Mar 07 '17 14:03 MOUMBE

Flexbox,colors and shadows are not working . Pls find the attached input and output files.

design_new.pdf design_new.zip

sudharsanmit avatar Mar 29 '17 20:03 sudharsanmit

Yes, they broke support in version 2.1.1 in PhantomJS. ariya/phantomjs#14793

Lichtjaeger avatar Mar 30 '17 06:03 Lichtjaeger

Is there a work around for this?

taylorstine avatar Apr 11 '17 21:04 taylorstine

I tried so many different modules and finally gave up. Flex box and z shadows aren't supported.

On Tuesday, April 11, 2017, Taylor Stine [email protected] wrote:

Is there a work around for this?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.< https://ci6.googleusercontent.com/proxy/korkejQ9CDUUjOLhuBJ4wRfk1FBEWfUF6JoSfCeHoO_3pSEHK4SXLS8EIKn4AnJ5J-t8hzhMGyQphEUfFVo-Cm196yusPXeVmc2loQasCBR0nPIzU6zk9y1Y9dk_IeFTtg6CzexR8rtb04jjCnkbBskWHuGOkw=s0-d-e1-ft#https://github.com/notifications/beacon/AP-IYWdojP09ZoD2Xt8szH0NkeLC9yWHks5ru_K3gaJpZM4EDzw3.gif>

sudharsanmit avatar Apr 11 '17 21:04 sudharsanmit

Flexbox works when you use autoprefixer v6, but after upgrading to v7, it broke for some reason. With v6, you need to specify this in your package.json:

{
  ...
  "browserslist": [
    "Safari >=4"
  ]
}

kumarharsh avatar Jul 10 '17 12:07 kumarharsh

Is there already a fix for this?

jhon-andrew avatar Sep 03 '17 06:09 jhon-andrew

display: flex + flex-wrap: wrap works in this way:

display: -webkit-box
display: -webkit-flex
-webkit-flex-wrap: wrap
display: flex
flex-wrap: wrap

Order matters!

4muzar avatar Sep 13 '17 08:09 4muzar

display: -webkit-box display: -webkit-flex -webkit-flex-wrap: wrap display: flex flex-wrap: wrap

Yes, so flex works, but justify-content doesn't work!

alex-brain avatar Oct 26 '17 19:10 alex-brain

Use https://github.com/Szpadel/chrome-headless-render-pdf

It's based on chrome headless, and gives much better results. I started having problems with this library when running an older project. The phantomjs dependency was just not installing, and when installed, it complained about path not being correct, etc... It became too much of a hassle to fix it so I switched to the library using chrome-headless, and it was a breeze! Plus, that library is based on this one, so the API is nearly the same.

kumarharsh avatar Apr 17 '18 06:04 kumarharsh

The order property of flex didn't work and so didn't autoprefixer prefixed it for me. After adding -webkit-order it works!

* I figured out autoprefixer didn't work just because I was using inline styles in React.

leoskyrocker avatar Aug 02 '18 07:08 leoskyrocker

For me autoprefixer are working just fine. Just use Autoprefixer CSS Online to generate css with vendor prefixes and use them. I am using inline css in a simple html file.

Akash187 avatar Oct 20 '18 05:10 Akash187

Guys i find another project that works perfectly with flexbox html-to-pdf

gsbarreto avatar May 08 '19 11:05 gsbarreto

{ flex: 1; } is still not working for me. I am stuck. I even have tried Autoprefixer CSS online { -webkit-box-flex: 1; -ms-flex: 1; flex: 1; }

amaneer94 avatar Mar 21 '20 09:03 amaneer94

@amaneer94 try using { -webkit-box-flex: 1; -webkit-flex: 1; flex: 1; } instead?

I had trouble getting justify-content to work even with autoprefixer, but based on a phantomjs issue i stumbled upon (https://github.com/ariya/phantomjs/issues/14365) adding safari >= 4 to my autoprefixer settings seem to fix it.

You can test it on Autoprefixer CSS online my inputing safari >= 4 in the browserlist field.

sumdook avatar Apr 13 '20 21:04 sumdook

Is anyone get around with this issue ?

Piyush-Use-Personal avatar Dec 28 '20 17:12 Piyush-Use-Personal

display: -webkit-box display: -webkit-flex -webkit-flex-wrap: wrap display: flex flex-wrap: wrap

Yes, so flex works, but justify-content doesn't work!

I got justify, align, and direction working with: -webkit-justify-content: center, -webkit-align-items: center, -webkit-flex-flow: column

JSEvgeny avatar Jun 16 '21 09:06 JSEvgeny

display: -webkit-box;
display: -webkit-flex;
-webkit-flex-wrap: wrap;
display: flex;
flex-wrap: wrap;
-webkit-justify-content: center;
-webkit-align-items: center;
-webkit-flex-flow: column;

flex not working for me anyone can help?

riandev avatar Feb 19 '22 13:02 riandev

Help, the bootstrap flex layout isn't work. Any solution? Any alternative?

dan13lJD avatar Apr 11 '22 20:04 dan13lJD

Help, the bootstrap flex layout isn't work. Any solution? Any alternative?

you can write your own css styles but using prefixing : -webkit-justify-content: value;, -webkit-align-items: value;, display: -webkit-box; display: -webkit-flex; these worked for me under ExpressJS

underscoDe avatar May 05 '22 05:05 underscoDe

you can use this site to convert https://autoprefixer.github.io/ for example flex not working go to the site write {display:flex} on left box and you get { display: -webkit-box; display: -ms-flexbox; display: flex;} its really cool.

MohammadK1373 avatar Aug 26 '22 13:08 MohammadK1373