wicked_pdf doesn't work on Windows

November 27, 2010

  • Rails
  • Ruby
  • ruby-on-rails
  • plugins
  • html-to-pdf
  • Source Code
  • wicked_pdf
  • win32/open3
  • Portable Document Format

Lately I had to implement the functionality of exporting an HTML page in PDF format in one of my Projects. Since I was using Ruby on Rails so I decided upon using the plugin wicked_pdf.

You get all the guidelines on the github site for implementing wicked_pdf. So I am not going into it. But if you are a windows user. You get the error

NotImplementedError: fork() function is unimplemented on this machine

This error is generated because the plugin still struggles to provide support for Windows OS. So after doing some research I came up to this:

Step 1 :- Install the gem win32-open3, this can be done using the following script

gem install win32-open3

The win32-open3 library provides a working implementation of the open3 library for MS Windows. In addition, it provides the Open4 class, which also returns pid information. Note that this library is unnecessary with Ruby 1.9.x because of its support for native threads.

Step 2 :- Now go to the plugins/wickedpdf/lib directory and open the file wickedpdf.rb

On line 6 of this file you have

require ‘open3’

Change this line to

require ‘win32/open3’

Step 3 :- And now try using the guidelines provided on github for the implementation of wicked_pdf.

Test. It works.

Have a great day. Hope this was helpful.


Mumbai, Maharashtra, India


Copyright © 2021