# Need help with report building. PDF or IMG or what?

**URL:** <https://www.ruby-forum.com/t/need-help-with-report-building-pdf-or-img-or-what/144032>\
**Category:** Rails\
**Created:** [July 24, 2008, 8:02pm UTC](https://www.ruby-forum.com/t/need-help-with-report-building-pdf-or-img-or-what/144032 "2008-07-24T20:02:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [July 24, 2008, 8:02pm UTC](https://www.ruby-forum.com/t/need-help-with-report-building-pdf-or-img-or-what/144032/1 "2008-07-24T20:02:48Z")

</div>

This is real important, so I hope you can help!

Okay I have to take this report:  
[http://www.ub04.net/downloads/UB04\_10-23-06\_B%20W%20PDF.pdf](http://www.ub04.net/downloads/UB04_10-23-06_B%20W%20PDF.pdf)

and fill it in with ruby on rails. I need advice on the best way to do  
that. They are basically only going to need to print the document, that  
makes it somewhat easier, but still this ain’t easy.

So what should I do? Last time I had to do something like this I just  
reverse engineered an HTML version of the form. This probably won’t  
happen this time because the report is so complicated.

Could I add my text with some sort of positioning to the PDF? With like  
PDF writer? And can you get me started on how to do this?

Should I just treat the whole report as an image and try to figure out  
how to draw the text I need. And can you get me started on how to do  
this?

Or what?

Thank you all so much if you can help me!

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [July 24, 2008, 8:14pm UTC](https://www.ruby-forum.com/t/need-help-with-report-building-pdf-or-img-or-what/144032/2 "2008-07-24T20:14:47Z")

</div>

On Thu, 2008-07-24 at 20:02 +0200, Alex Williams wrote:

> reverse engineered an HTML version of the form. This probably won’t
> 
> Thank you all so much if you can help me!

* * *

[http://wiki.rubyonrails.org/rails/pages/HowtoGeneratePDFs](http://wiki.rubyonrails.org/rails/pages/HowtoGeneratePDFs)

I use both rjb (ruby java bridge with itext) and pdftk - depending upon  
what I need to do. itext can’t do checkboxes.

Craig

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [July 24, 2008, 8:39pm UTC](https://www.ruby-forum.com/t/need-help-with-report-building-pdf-or-img-or-what/144032/3 "2008-07-24T20:39:26Z")

</div>

Hi Alex,

Alex Williams wrote:

> Could I add my text with some sort of positioning to the PDF?  
> With like PDF writer? And can you get me started on how to  
> do this?

I did something very similar using PDF::Writer. You can see a demo at  
[YourTimeMatters.com](http://YourTimeMatters.com) and, if you’re interested in seeing how I did it,  
the  
code’s at [rubyforge.org/projects/ccredit](http://rubyforge.org/projects/ccredit). Feel free to contact me  
offlist  
if you’d like. Note that I seem to have something screwed up a little  
bit  
with the CSS for the fieldset around the ‘reports’ on the final page in  
FireFox. Looks fine in IE ;-p.

HTH,  
Bill

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [July 25, 2008, 2:53pm UTC](https://www.ruby-forum.com/t/need-help-with-report-building-pdf-or-img-or-what/144032/4 "2008-07-25T14:53:41Z")

</div>

Hi Alex,

Alex Williams wrote:

> Thank you Bill and Craig. I’ve been trying to get PDF::Writer  
> to work for a little while now. HOWEVER, it looks like it can  
> only create them, it cannot open an EXISTING PDF file and  
> edit it.
> 
> Is there a way to do that?

Your original post didn’t mention the need to read / edit existing PDF  
files. If you do, the answer depends primarily on whether those files  
are  
ones you generated, or ones generated by third parties.

If you need to edit PDFs that you generated, you can follow the route I  
took. I used PDF::Writer to create PDF files that Acrobat understands  
and  
can display, and pdftk to attach XML files containing the data that’s  
displayed via the PDF. The PDF itself essentially becomes an image, but  
my  
app (or any other that understands the XML schema) can extract the XML  
data  
from the PDF, edit it, and create a new PDF (or overwrite the old one).

If, on the other hand, you need to read / edit PDFs that were generated  
by  
someone else, you’re probably going to have to use Adobe’s tools. There  
are  
some tools around that can read / extract form data from older versions  
of  
Adobe’s PDFs, but Adobe’s changed the whole way that’s handled in recent  
versions. The old approach was known as FDF, I think. I can’t remember  
what the new one’s called but the bottom line is, AFAIK, there are no  
open  
source libraries to generate / consume the new format. The standard’s  
open,  
so you could conceivably generate your own. But be careful. Adobe’s  
license says something like “if you use any of our tools, you can’t use  
any  
of anybody else’s”.

HTH,  
Bill

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [July 24, 2008, 9:59pm UTC](https://www.ruby-forum.com/t/need-help-with-report-building-pdf-or-img-or-what/144032/5 "2008-07-24T21:59:49Z")

</div>

Bill W. wrote:

> Hi Alex,
> 
> Alex Williams wrote:
> 
> > Could I add my text with some sort of positioning to the PDF?  
> > With like PDF writer? And can you get me started on how to  
> > do this?
> 
> I did something very similar using PDF::Writer. You can see a demo at  
> [YourTimeMatters.com](http://YourTimeMatters.com) and, if you’re interested in seeing how I did it,  
> the  
> code’s at [rubyforge.org/projects/ccredit](http://rubyforge.org/projects/ccredit). Feel free to contact me  
> offlist  
> if you’d like. Note that I seem to have something screwed up a little  
> bit  
> with the CSS for the fieldset around the ‘reports’ on the final page in  
> FireFox. Looks fine in IE ;-p.
> 
> HTH,  
> Bill

Thank you Bill and Craig. I’ve been trying to get PDF::Writer to work  
for a little while now. HOWEVER, it looks like it can only create them,  
it cannot open an EXISTING PDF file and edit it.

Is there a way to do that?

Thank you again!
