# Pdf fdf implemenation

**URL:** <https://www.ruby-forum.com/t/pdf-fdf-implemenation/123218>\
**Category:** Rails\
**Created:** [December 15, 2007, 12:04am UTC](https://www.ruby-forum.com/t/pdf-fdf-implemenation/123218 "2007-12-15T00:04:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [December 15, 2007, 12:04am UTC](https://www.ruby-forum.com/t/pdf-fdf-implemenation/123218/1 "2007-12-15T00:04:21Z")

</div>

Does such a plugin for handling the marriage of rails data into existing  
PDF forms exist?

This would be really cool.

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [December 15, 2007, 10:59pm UTC](https://www.ruby-forum.com/t/pdf-fdf-implemenation/123218/2 "2007-12-15T22:59:39Z")

</div>

On Fri, 2007-12-14 at 16:03 -0700, Craig W. wrote:

> Does such a plugin for handling the marriage of rails data into existing  
> PDF forms exist?
> 
> This would be really cool.

* * *

Is there really no one doing this at all?

I’m shocked because there are tools for perl and php for using pdftk and  
merging data into PDF forms on the fly and it seems like such a slam  
dunk for RoR

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [December 16, 2007, 2:13am UTC](https://www.ruby-forum.com/t/pdf-fdf-implemenation/123218/3 "2007-12-16T02:13:21Z")

</div>

Hi Craig,

Take a look at [http://wiki.rubyonrails.org/rails/pages/HowtoGeneratePDFs](http://wiki.rubyonrails.org/rails/pages/HowtoGeneratePDFs)  
or

Google rails pdf writer

Best regards,  
Bill

----- Original Message -----  
From: “Craig W.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Saturday, December 15, 2007 4:58 PM  
Subject: [Rails] Re: \*\*\*\*[Rails] pdf fdf implemenation

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [December 16, 2007, 4:19am UTC](https://www.ruby-forum.com/t/pdf-fdf-implemenation/123218/4 "2007-12-16T04:19:35Z")

</div>

For a project I am looking at doing in the future I have been  
searching for something that will let me take existing pdfs so that I  
can individualize them for specific users… I was recommended the  
following app (it isn’t free though): PDF Batch Stamp Tool, at:  
[http://www.pdf-tools.com](http://www.pdf-tools.com)… It is a command line tool, but it looks  
like it would do what I am looking for quite painlessly… Don’t know  
if this is what you are looking for, but maybe it will help.

Best Regards,  
Mark

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [December 16, 2007, 2:49am UTC](https://www.ruby-forum.com/t/pdf-fdf-implemenation/123218/5 "2007-12-16T02:49:01Z")

</div>

PDF Writer can’t do that as far as I can tell…I’ve been through it and  
trust me, I’ve googled my little ears off. Finally found what I wanted  
at [rubyforge.org](http://rubyforge.org)

What I did find that worked was pdf-stamper gem (uses the Ruby Java  
Bridge) which has remarkably sparse documentation but I actually got it  
to work (YEAH!) but the link in the middle of the page (PDF Form Fill)  
that does it without java might even be better (or worse…)

Thanks, I don’t generally look at [wiki.rubyonrails.org](http://wiki.rubyonrails.org) because past  
disrepair has been disconcerting.

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [December 16, 2007, 4:28am UTC](https://www.ruby-forum.com/t/pdf-fdf-implemenation/123218/6 "2007-12-16T04:28:21Z")

</div>

On Sat, 2007-12-15 at 19:19 -0800, mksys wrote:

> For a project I am looking at doing in the future I have been  
> searching for something that will let me take existing pdfs so that I  
> can individualize them for specific users… I was recommended the  
> following app (it isn’t free though): PDF Batch Stamp Tool, at:  
> [http://www.pdf-tools.com](http://www.pdf-tools.com)… It is a command line tool, but it looks  
> like it would do what I am looking for quite painlessly… Don’t know  
> if this is what you are looking for, but maybe it will help.

* * *

if you look at the post you replied to (mine), you’ll see that the issue  
is solved with free software (ruby gem called pdf-stamper)

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 27, 2008, 10:26pm UTC](https://www.ruby-forum.com/t/pdf-fdf-implemenation/123218/7 "2008-02-27T22:26:15Z")

</div>

Hey Craig –

I’m trying to do the same thing, and have come across the same total  
lack of documentation. Do you have any code snippets you’re willing to  
share? Thanks!

-Lucas

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 5, 2009, 9:27pm UTC](https://www.ruby-forum.com/t/pdf-fdf-implemenation/123218/8 "2009-02-05T21:27:30Z")

</div>

Hi Craig!  
Me too digging with this same situation of pdf-stamping, I’m here and  
has been through many other googled posts. I have setup everything-  
rjb,JAVA\_HOME,jdk, and pdf/stamper gem. In stamper.rb file of the gem, I  
don’t have any Fdf class. Only one class Stamper is there.  
Here is the code [http://pastie.org/381005](http://pastie.org/381005) of my stamper.rb file  
but in your code snippet above, you have used FDF, (@fdfobj = Fdf.new  
) on the 2nd line of the method.  
Did you just wrote it for the example sake or you do really have this  
class in your gem??  
Can you paste the code of your stamper.rb file or I’d be greatful to  
send the zipped version of this gem folder at  
millisami[at]gmail[doc]com!!!

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 27, 2008, 11:32pm UTC](https://www.ruby-forum.com/t/pdf-fdf-implemenation/123218/9 "2008-02-27T23:32:34Z")

</div>

On Wed, 2008-02-27 at 22:26 +0100, Lucas Haley wrote:

> Hey Craig –
> 
> I’m trying to do the same thing, and have come across the same total  
> lack of documentation. Do you have any code snippets you’re willing to  
> share? Thanks!

* * *

you don’t give any indication where you’re at so I’m not sure that this  
will be helpful but first…

I am using mongrel\_cluster so I added the following little snippet to  
the init.d/mongrel\_cluster

JAVA\_HOME=/usr/java/jdk1.6.0\_03  
export JAVA\_HOME

added the following to application.rb (you have to install the gems  
first)  
require “rjb”  
require “pdf/stamper”

then my controller snippet has…

def guardian\_fdf\_form  
@client = Client.find(params[:id])  
@fdfobj = Fdf.new  
@fdfobj.url = “http://my\_local\_webserver/Agreement.pdf”  
myfdf = @fdfobj.create\_header  
myfdf += @fdfobj.add\_data({“guardian”,@client.clwholename})  
myfdf += @fdfobj.specify\_pdf(@fdfobj.url)  
myfdf += @fdfobj.create\_footer  
send\_data(myfdf, {:type =\> “application/vnd.fdf”,  
:stream =\> false,  
:filename =\> “Agreement\_out.fdf”})  
end

Craig
