Then this is the same as using any other Ruby library. If you're
using config.gem you may need to futz around with it so rails loads
the right stuff, but otherwise, nothing special here. Shelve your
reports somewhere in the loadpath and fire away.
> - to use authlogic+lockdown/acl9 (may be devise soon)
Doesn't sound related to Prawn.
> - to generate private PDFs for specific authenticated users
Not sure whether you're talking about security at the PDF level or the
application level. If you either stream the PDFs on demand, or create
hashed download URLs and check your user credentials there, that
should do the trick on the application level. If you're looking at
building passworded or encrypted PDFs, have a look at prawn-security.
http://github.com/madriska/prawn-security
This is technically unsupported in Prawn <=0.5.x, but is inbound for
becoming part of the Prawn 0.6 release, so it's ready for use.
> - to let each user have access only to her own documents
Isn't this accomplished by your previous questions?
That's something you'll need to get over on the Rails mailing list,
though. There isn't anything special about using Prawn in Rails, so
all of the questions are basically about Rails and would be better
served by that community.
> I found that the method render instead of render_file should be better
> for my purpose.
Sure, or you can use send_data if you don't want to bother writing to
file. Depends on your needs.
> Moreover in the docs it says not to put PDF code in the controller...
Typically this just means that you do something like this:
MyFancyReport.render_pdf
> I will try in practice... maybe you think I should use prawnto, but I
> would like to depend on the least components as possible...
Not to discourage those who find Prawnto useful, but I have never used
it and probably would never have a need for it. Any Prawn work I've
done in Rails has been just directly with Prawn.
-greg
Without Prawnto, you could do something like
class MyController < ApplicationController
def my_action
pdf = Prawn::Document.new(:page_size => "A4") do
text "Hello world."
end
send_data(pdf.render, :type => 'application/pdf', :disposition
=> 'attachment',
:filename => 'hello_world.pdf')
end
end
Then you could tidy this up by making your own class that inherits
from Prawn::Document or that wraps around it, so you might have
pdf = HelloWorldDocument.new
instead. And you could of course define your own send_pdf controller
method to tidy up the send_data bit.
I'm sorry Tyron, but Prawn is an alpha-level, hackers-only framework
at the moment. Unless you're comfortable reading its source and
fixing things yourself, you really should wait until 1.0. If you
need help configuring a Rails app, ask the Rails list.
-greg
It's mainly a matter of support. We're not in a position to guarantee
that docs will be up to date, tutorials readily available, etc.
So answering the same beginner questions can be a drain on our
resources. Of course, this is something we can fix with a FAQ, and
luckily other Prawn contributors aren't as curmudgeonly as I am.
I mean it though, by 1.0 Prawn should be relatively easy to use with
lots of resources, even for beginners.
-greg