php-phantomjs icon indicating copy to clipboard operation
php-phantomjs copied to clipboard

Is it possible to STDIN the html?

Open spawn-guy opened this issue 9 years ago • 9 comments

I appreciate the possibility to request a certain url on the Internet.

However, I wonder if it is possible to pipe some HTML directly to the phantomJS via this php-phantomjs package?

I'm on Laravel5 and Blade. and i'd like to render some template view('some.view', $some_data) and pipe it directly to phantomJS to render the needed PDF.

I have found some info here http://phantomjs.org/inter-process-communication.html only, I am not sure what is the proper way to implement this? via custom js template(i can try to do that) or is there already a way to achieve that?

spawn-guy avatar Feb 25 '16 13:02 spawn-guy

There is an option to output the page as PDF if that is what you are after?

http://jonnnnyw.github.io/php-phantomjs/4.0/usage/#output-to-pdf

Otherwise if you could give me a more concrete example I can take a look into it.

jonnnnyw avatar Mar 21 '16 19:03 jonnnnyw

here is an example: i generate some html with templating engine (Laravel Blade for example) into a variable in memory. and want to pipe this html with external css links directly into php-phantomjs library. $request->setHtmlContents($html) and get PDF/Image on an output. preferably, in memory,

for now, i have to store contents into a local file and then run the phantomjs. with URL-Request ("file:///tmp/something.html") or am i missing something from the docs information?!

ps: function does not represent actual code

spawn-guy avatar Mar 21 '16 19:03 spawn-guy

This doesn't really fit within the HTTP request/response API but I take a look and see if it's worth creating a separate API that can be used for local files and content streaming. Essentially it will be a separate kind of client that you can use for batch processing.

jonnnnyw avatar May 23 '16 08:05 jonnnnyw

First of all thanks @jonnnnyw , Im waiting for this feature to convert the locally generated HTML content to images. Im actually planning to create images with charts (not interactive like small bar charts) on the fly and send them as push notification so that we can represent the data visually for the user.

knvpk avatar Dec 03 '16 09:12 knvpk

I am currently working on this. I want to make it compatible with the changes that are happening in Version 5 so it's taking a bit longer than it normally would. Hopefully it should be released within the week.

jonnnnyw avatar Dec 05 '16 18:12 jonnnnyw

Hi, Thank you for the work.But,I have the same issue here where I have to pass a view to the template with data. Not an external URL.Is there anyway to meet this issue?As you said,you were working on it! Has it been updated? Thank you

arju88nair avatar Jan 05 '17 07:01 arju88nair

Any luck yet with the feature??? Thanks.

sudhanshu2340 avatar Jan 25 '17 13:01 sudhanshu2340

Why not just use vanilla phantomjs & rasterize.js to do this?

I've been using it to create invoices from local html files

MikeyBeLike avatar Jan 31 '17 11:01 MikeyBeLike

Please give a status on this as we are now a year later... 👍

dk-jessn avatar Dec 13 '18 09:12 dk-jessn