Install Ruby Gems in SketchUp

Hi All,

I have installed the ruby gems are

Gem.install "wkhtmltopdf"
[#<Gem::Specification:0x6a31fa0 wkhtmltopdf-0.1.2>]
Gem.install "pdfkit"
[#<Gem::Specification:0x64d34b4 pdfkit-0.8.2>]

After installing the gems, I can’t work on this, it’s getting an error.

Error: #<Errno::ENOENT: No such file or directory - which wkhtmltopdf>
C:/Users/Admin/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Gems64/gems/pdfkit-0.8.2/lib/pdfkit/configuration.rb:22:in ``'
C:/Users/Admin/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Gems64/gems/pdfkit-0.8.2/lib/pdfkit/configuration.rb:22:in `wkhtmltopdf'
C:/Users/Admin/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Gems64/gems/pdfkit-0.8.2/lib/pdfkit/pdfkit.rb:32:in `initialize'
C:/Users/Admin/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Plugins/decorpot-extension/lib/add_dimension.rb:243:in `new'

If anyone knew, please help me for pdf generated.

Siva S

In general, installing Ruby gems in Sketchup is not supported due to many of them using C bindings that need to be compiled separately. You’ll want to find a library that uses pure Ruby if possible.

Have you looked at this?

Configuration for PDFKit

I’m pretty sure the authors are suggesting to run which wkhtmltopdf in PowerShell or cmd.exe or a similar terminal to find the wkhtmltopdf binary.

I’m pretty sure which is not a command of the Windows/Wine API. So I am wondering why your Ruby Gems installation is trying to call which.

  • Can you check that RUBY_PLATFORM is not altered and gives the Windows version of Ruby?

  • Did you install the pdf gem in Windows/Wine?

  • Did you check whether it has a Windows version at all, since it is binary?

proves that the gem is not designed to be used on Windows (although the underlying wkhtmltopdf has a Windows release). Afterall, Ruby is mostly used for web development and web apps are almost solely deployed on unixoid systems. The developer didn’t even care to mention system requirements.

What you can do:

  • request from the SketchUp team to make available a SketchUp build for Linux (at least for a Linux SDK there would be very serious use cases, since it allows .skp files to be used in web apps). Others have failed with that, and even if, barely anyone of your extension users would fulfill the requirements of your extension.
  • develop your extension on macOS, which is unixoid. This would restrict your extension to be solely compatible for macOS users.
  • use a different PDF library that can be used on Windows and macOS
  • figure out how to apply this hacky workaround to make pdfkit use the Windows version of wkhtmltopdf. Apparently you need to call the method wkhtmltopdf=(path). Don’t forget that this workaround must work for everyone who installs your extension.
1 Like

Hi @Aerilius,

I have installed Prawn gem in Sketchup. When I convert HTML to pdf format, I got an error
Here is my code:

pdf_generator =

I got an error while using this code in a ruby script.

Error: #<NameError: uninitialized constant Prawn::Html>

Please give some solutions for solving this issue.

Siva S

If “Prawn::Html” is uninitialized, it means you need to initialize it. That means you need to check whether the gem (that defines it) is loaded and whether it really defines Prawn::Html and that it has not been renamed.