Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use PhantomJS as a client-side library?

Tags:

pdf

phantomjs

I am currently evaluating different libraries for HTML to PDF export. Some of them do implement HTML to PDF conversion, but it is labeled as experimental.

PhantomJS sounds like a solid option, but I don't know for sure if it will be possible to generate the PDF at client side so... is it possible? how?

like image 696
Roman Rdgz Avatar asked Mar 09 '15 08:03

Roman Rdgz


People also ask

What is the use of PhantomJS?

PhantomJS is a discontinued headless browser used for automating web page interaction. PhantomJS provides a JavaScript API enabling automated navigation, screenshots, user behavior and assertions making it a common tool used to run browser-based unit tests in a headless system like a continuous integration environment.

Does Reactjs use PhantomJS?

React JS uses phantom js to render the webpages on server-side b. React JS is a framework c. React JS improves the performance of the applications by using the concept of virtual DOM d. In React JS, the data flow will happen in a single direction 2.

What PhantomJS 2?

PhantomJS is a headless web browser scriptable with JavaScript. It runs on Windows, macOS, Linux, and FreeBSD. Using QtWebKit as the back-end, it offers fast and native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.


1 Answers

No, PhantomJS is a complete standalone browser. If you like to compile PhantomJS with emscripten to JavaScript and then run it in the browser, you can certainly try, but it would be probably hard to do.

The easiest way would be to have a PhantomJS server running that takes the HTML that needs to be rendered and returns the resulting PDF. PhantomJS provides the webserver module for this. Of course, you can use PhantomJS with a proper node.js server through a bridge like phantom.

like image 77
Artjom B. Avatar answered Dec 08 '22 16:12

Artjom B.