render to pdf with page breaks?

1,999 views
Skip to first unread message

Greg Lappen

unread,
Apr 21, 2012, 8:09:29 PM4/21/12
to phan...@googlegroups.com
Hello,

First off, phantomjs rocks.  I'm looking for a solution for converting web pages to pdf, but I can imagine all kinds of interesting uses for this!  Anyway, here's my real question:

Has anyone had success using phantomjs to render pages to pdf with page breaks?  In other words,I'd like to use the standard css page-break-before, page-break-after, page-break-inside rules to get some control over where pages are breaking - right now it seems that phantomjs ignores them.  Is this a know issue, or is it expected to generally work?

Thanks again,

Greg

Milian Wolff

unread,
Apr 25, 2012, 8:08:27 AM4/25/12
to phan...@googlegroups.com
hey there,

I've spent some time on improving these things and afaik it should "just work" if you use PhantomJS 1.5. Note though that WebKit only supports these css attributes for block elements...

If something is not working, please provide a proper example so one can take a look at it and try to fix the issues.

Rp k

unread,
Jun 26, 2014, 4:14:17 PM6/26/14
to phan...@googlegroups.com
Hi Greg,
Were you able to achieve this? I'm unable to get the page-break css rules work with phantomjs 1.9.7.
Please let me know; would be of great help.

Greg Lappen

unread,
Jun 26, 2014, 4:37:34 PM6/26/14
to phan...@googlegroups.com
We had to abandon phantomjs and use wkhtmltopdf. That was 2 years
ago and I haven't tried it since....sorry I couldn't be more helpful!
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "phantomjs" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/phantomjs/7d22wP_Ho8Y/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> phantomjs+...@googlegroups.com.
> Visit this group at http://groups.google.com/group/phantomjs.
> For more options, visit https://groups.google.com/d/optout.

Rp k

unread,
Jun 26, 2014, 4:48:46 PM6/26/14
to phan...@googlegroups.com
Np, Greg. It's a bit late in the game even to think of options other than phantomjs, so I'll keep looking for answers. Thanks for your help.

Darren Cook

unread,
Jun 26, 2014, 5:19:04 PM6/26/14
to phan...@googlegroups.com
> Np, Greg. It's a bit late in the game even to think of options other than
> phantomjs, so I'll keep looking for answers. Thanks for your help.

I noticed SlimerJS just fixed a PDF-related bug; I've not used it
myself, but I assume that means making PDFs works.

It might also be worth trying some tests with PhantomJS 2.0
(https://github.com/ariya/phantomjs/wiki/PhantomJS-2) as this may simply
be an old bug (or missing feature) that has now been fixed (added).

Darren





--
Darren Cook, Software Researcher/Developer
My new book: Data Push Apps with HTML5 SSE
Published by O'Reilly: (ask me for a discount code!)
http://shop.oreilly.com/product/0636920030928.do
Also on Amazon and at all good booksellers!

Rp k

unread,
Jun 27, 2014, 11:15:10 AM6/27/14
to phan...@googlegroups.com


On Thursday, 26 June 2014 17:19:04 UTC-4, Darren Cook wrote:
> Np, Greg. It's a bit late in the game even to think of options other than
> phantomjs, so I'll keep looking for answers. Thanks for your help.

I noticed SlimerJS just fixed a PDF-related bug; I've not used it
myself, but I assume that means making PDFs works.

It might also be worth trying some tests with PhantomJS 2.0
(https://github.com/ariya/phantomjs/wiki/PhantomJS-2) as this may simply
be an old bug (or missing feature) that has now been fixed (added).

Darren

Thanks for looking into it Darren. I relied on the phantomjs 2.0 binaries built by another dev at: https://groups.google.com/forum/#!topic/phantomjs/cgTH-jqCSGg/discussion. Phantom would simply hang when I use the windows version of the binaries from above link. I didn't attempt building it myself as it took me quite a bit of time to build phantom.exe from the trunk; hence, it would take even longer to build phantom2 as it uses additional 3rd party tools.

kannan Fa

unread,
Apr 25, 2016, 1:48:47 AM4/25/16
to phantomjs
Is there any solution for page break work in phantom js please let me know ...
Reply all
Reply to author
Forward
0 new messages