Nathan H
Nathan H

Reputation: 49371

Using `wicked_pdf` in a non-rails project

All the documentation for wicked_pdf assume you are using rails.

But I want to use this feature in a non-rails environment (a Jekyll plugin, written in Ruby).

Trying to use pdf = WickedPdf.new.pdf_from_string(page.content) returns Error: uninitialized constant WickedPdf.

How do I initialize WickedPdf without the rails generate wicked_pdf provided in their documentation?

Upvotes: 2

Views: 307

Answers (2)

Oto Brglez
Oto Brglez

Reputation: 4193

wicked_pdf depends on active_support/core_ext - as you can see in lib/wicked_pdf.rb. However you can use it outside of controller "context" like this...

pdf = WickedPdf.new.pdf_from_string('<h1>My life is wicked.</h1>')

Upvotes: 1

Nathan H
Nathan H

Reputation: 49371

I had to add gem 'activesupport' to my gemfile, then use require 'wicked_pdf' in my source code.

Upvotes: 1

Related Questions