Prawn on Rails

515 views
Skip to first unread message

macsig

unread,
Aug 26, 2008, 6:14:48 PM8/26/08
to Prawn
Hello, I'm working on a Rails app and right now to create some PDF I
use PDF::writer but since it is creating my some issues (and because
it is basically dead) I have decided to switch to Prawn.


To start I have a simple question, how can I import in within my app?
I mean after installing the gem have I to add something on my
environment file.
To use PDF::writer I added "require 'pdf/writer'".


Basically what I do is generate a PDF in my model, do I need prawnto ?


THANKS and HAVE a GOOD 1!

Michael Prior

unread,
Aug 26, 2008, 6:31:31 PM8/26/08
to prawn...@googlegroups.com
yes-- to use the prawn library you will have to require it.
and no-- you don't have to use prawnto and in fact some prefer not to,
however it does make life easier in most normal situations (in my
humble opinion)-- but what else would you expect the prawnto creator
to say.
if you want to try prawnto just follow the instructions at
www.cracklabs.com/prawnto

p.s. a new prawnto version is on its way in the next day or so-- some
nice additional features and a little better documentation..

macsig

unread,
Aug 26, 2008, 6:46:17 PM8/26/08
to Prawn
Thanks Michael for your reply.

I have added config.gem "prawn" in my environment (and restarted
the server).
but when I try to generate a simple PDF I get uninitialized constant
User::Prawn. User is the model within I' trying to generate the PDF.

Am I missing something?


THANKS


On Aug 26, 3:31 pm, "Michael Prior" <michael.pr...@gmail.com> wrote:
> yes-- to use the prawn library you will have to require it.
> and no-- you don't have to use prawnto and in fact some prefer not to,
> however it does make life easier in most normal situations (in my
> humble opinion)-- but what else would you expect the prawnto creator
> to say.
> if you want to try prawnto just follow the instructions atwww.cracklabs.com/prawnto
>
> p.s. a new prawnto version is on its way in the next day or so-- some
> nice additional features and a little better documentation..
>

thorny_sun

unread,
Aug 26, 2008, 7:04:24 PM8/26/08
to Prawn
pastie your controller and any other relevant bits... or just use
prawnto

macsig

unread,
Aug 26, 2008, 7:27:51 PM8/26/08
to Prawn
The code I use is quite simple


Prawn::Document.generate "foo.pdf" do
font "Times-Roman"
text "Hello World", :at => [200,720], :size => 32
end


Thanks but if it is not necessary I prefer to go without prawnto

Gregory Brown

unread,
Aug 26, 2008, 7:29:52 PM8/26/08
to prawn...@googlegroups.com
On Tue, Aug 26, 2008 at 7:27 PM, macsig <sigb...@gmail.com> wrote:
>
> The code I use is quite simple
>
>
> Prawn::Document.generate "foo.pdf" do
> font "Times-Roman"
> text "Hello World", :at => [200,720], :size => 32
> end
>
>
> Thanks but if it is not necessary I prefer to go without prawnto

I can't believe rails makes things so complicated.

I never learned how to register dependencies because I have no idea
what good it does me.
Instead of messing around with that junk, try just doing:

config.after_initialize do
require "prawn"
end

in your environment.rb. If that has problems... did you um.... gem
install prawn ??


--
Technical Blaag at: http://blog.majesticseacreature.com | Non-tech
stuff at: http://metametta.blogspot.com

Jeremy McAnally

unread,
Aug 26, 2008, 7:41:46 PM8/26/08
to prawn...@googlegroups.com
The config.gem stuff is so it will yell at you if you don't have it
installed/can install it with a rake task. Quite convenient actually.

--Jeremy

--
http://jeremymcanally.com/
http://entp.com/
http://omgbloglol.com

My books:
http://manning.com/mcanally/
http://humblelittlerubybook.com/ (FREE!)

Gregory Brown

unread,
Aug 26, 2008, 7:43:53 PM8/26/08
to prawn...@googlegroups.com
On Tue, Aug 26, 2008 at 7:41 PM, Jeremy McAnally
<jeremym...@gmail.com> wrote:
>
> The config.gem stuff is so it will yell at you if you don't have it
> installed/can install it with a rake task. Quite convenient actually.

>> Prawn::Document
NameError: uninitialized constant Prawn
from (irb):1

Look's like I've either not got it installed, or not loaded it. Seems
pretty easy to me using the features already built into Ruby.

-greg

macsig

unread,
Aug 26, 2008, 8:17:24 PM8/26/08
to Prawn
got it !!! thanks


>   require "prawn"

Reply all
Reply to author
Forward
0 new messages