jonnnnyw / php-phantomjs

Execute PhantomJS commands through PHP
MIT License
1.44k stars 432 forks source link

Is it possible to STDIN the html? #88

Open spawn-guy opened 8 years ago

spawn-guy commented 8 years ago

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?

jonnnnyw commented 8 years ago

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.

spawn-guy commented 8 years ago

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

jonnnnyw commented 8 years ago

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.

knvpk commented 7 years ago

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.

jonnnnyw commented 7 years ago

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.

arju88nair commented 7 years ago

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

sudhanshu2340 commented 7 years ago

Any luck yet with the feature??? Thanks.

MikeyBeLike commented 7 years ago

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

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

dk-jessn commented 5 years ago

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