Generating a pdf from form data and serving it back

hey everybody,

this is unfortunately my second time typing this out since googlegroups
never posted my first message.

here’s my deal:

working on a rails app where the user fills in some form data and then
with
the given info i build a pdf with pdf-writer. after the pdf generates i
want
to have a link created on the next page for the user to download the pdf
to
their local machine. few questions: where’s the best place to store the
pdf
in the rails tree (i imagine somewhere in public) for the user to be
able to
download it. also, since many users will be using this interface i need
a
mechanism to junk stale reports. i suppose it could be done with a cron
or
backgroundrb type deal where it compares the timestamp of the file and
the
current time and deletes the file after a certain amount of time has
passed
(probably have a mechanism to regen the reports anyway)…

any other issues i might need to look out for?

thanks in advance…

stuart (the other one)

On 10/16/06, Stuart W. [email protected] wrote:

want to have a link created on the next page for the user to download the
pdf to their local machine. few questions: where’s the best place to store
the pdf in the rails tree (i imagine somewhere in public) for the user to be
able to download it.

It may not be a problem, but if you put the generated file into the
public
tree somewhere, then that file is available for anyone to download. If
you
store it outside your public tree you will need to serve it up with a
controller action that utilises send_data

also, since many users will be using this interface i need a mechanism
to

junk stale reports. i suppose it could be done with a cron or backgroundrb
type deal where it compares the timestamp of the file and the current time
and deletes the file after a certain amount of time has passed (probably
have a mechanism to regen the reports anyway)…

It may be possible for BackgroundDRB to look after this. If your
controller
passes the request to a background worker, the controller action may be
able
to clean up the file after download is complete. I’m not sure about
this
one though.

Maybe someone who has a better knowledge of BackgroundDRB would be able
to
answer this part better.

You can find BackgroundDRB at
http://brainspl.at/articles/tag/drb

Hope that helps

Unless it would cause a big performance hit, you might want to think
about not storing the PDFs at all. I have apps that generate CSV (for
opening with a spreadhseet program) and do PDF form-filling on demand.
It’s not a problem for me since those functions don’t get hit too
frequently and what I’m generating isn’t more db or cpu-intensive than a
typical CRUD webpage.

Stuart W. wrote:

hey everybody,

this is unfortunately my second time typing this out since googlegroups
never posted my first message.

here’s my deal:

working on a rails app where the user fills in some form data and then
with
the given info i build a pdf with pdf-writer. after the pdf generates i
want
to have a link created on the next page for the user to download the pdf
to
their local machine. few questions: where’s the best place to store the
pdf
in the rails I tree (i imagine somewhere in public) for the user to be
able to
download it. also, since many users will be using this interface i need
a
mechanism to junk stale reports. i suppose it could be done with a cron
or
backgroundrb type deal where it compares the timestamp of the file and
the
current time and deletes the file after a certain amount of time has
passed
(probably have a mechanism to regen the reports anyway)…

any other issues i might need to look out for?

thanks in advance…

stuart (the other one)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs