wicked_pdf doesn't work on Windows

Rohit Sharma 2010-11-27
wicked_pdf doesn't work on Windows

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 windowss user. You get the error

[sourcecode language=”ruby”]NotImplementedError: fork() function is unimplemented on this machine[/sourcecode]

This error is generated because wicked_pdf still struggles to provide support for Windows OS. So after a lot of gooooogling I came up to this……

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

[sourcecode language=”ruby”]gem install win32-open3[/sourcecode]

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/wicked_pdf/lib directory and open the file wicked_pdf.rb
On line 6 of this file you have

[sourcecode language=”ruby”]require ‘open3’[/sourcecode]

Change this line to

[sourcecode language=”ruby”]require ‘win32/open3’[/sourcecode]

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

Its works.