DocRaptor vs PhantomJS

PhantomJS is a “headless browser” (a web browser, just for programming, without a visible interface). Exporting screen captures to PDF, PNG, and JPG is just one of many PhantomJS features. DocRaptor uses PrinceXML, an engine designed specifically for creating PDFs. PhantomJS is built on the WebKit browser.

Note: Since this article was originally published, PhantomJS was discontinued by its mainteners. We have a new article about open-source HTML to PDF libraries with more up-to-date information.

PhantomJS is an excellent screen capture tool, but there are some major differences you should be aware of when choosing between DocRaptor and PhantomJS.

  1. Are you ok with larger documents?
    Simply put, PhantomJS is not as good at PDF generation as Doc
    Raptor. It is a screen capture tool, not a dedicated PDF generator. In general, we found documents generated by PhantomJS tend to be 15-40% larger than the same document generated by DocRaptor. PhantomJS also has particular difficulty with complex documents. Winner: DocRaptor
  2. Are you (or your customers) printing the documents? For printed documents, CSS3 page media queries are important features such as page numbers and document sizing. DocRaptor supports these queries, letting you make printer-ready documents using just CSS styles. PhantomJS does not support these queries at all. The other major open-source alternative to DocRaptor, wkhtmltopdf, does support many of these options, albeit in a roundabout fashion. Additionally, DocRaptor offers PDF/A-1B ISO standard support for improved archiving and printing.
    Winner: DocRaptor
  3. Do you want document thumbnails? PhantomJS can generate a PNG snapshot of your document. You’ll need to use another tool like ImageMagick to resize the PNG to thumbnail size, but image export functionality is a must have for many projects. Winner: PhantomJS (with ImageMagick)
  4. Would you like to generate Excel files too? DocRaptor can convert HTML to PDF and xls/xlsx, making it a one-stop shop for report generation. Winner: DocRaptor
  5. Do you want to manage and support PDF generation? Infrastructure and support costs are the big differences between DocRaptor and PhantomJS. Debugging failed documents can be painful without a detailed document generation log like DocRaptor’s. Generating PDFs takes up more server capacity than typical web page requests and often requires dedicated servers to handle the load.

    DocRaptor gives you reliable infrastructure, capacity for millions of documents and access to world-class support. You’ll never have to worry about getting too many requests, or whether you can handle a very complicate PDF document. It’s important to consider every factor when choosing a PDF generation solution, and the results may shock you. Winner: DocRaptor (in most cases, but not always)

We hope this document helps. If you have further questions, please leave a comment or email!

Ready to get started? Try DocRaptor for free with unlimited test documents.