# Extracting HTML

**URL:** <https://www.ruby-forum.com/t/extracting-html/137306>\
**Category:** Ruby\
**Created:** [May 11, 2008, 8:45pm UTC](https://www.ruby-forum.com/t/extracting-html/137306 "2008-05-11T20:45:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![flawkes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f475e1/32.png) [@flawkes](https://www.ruby-forum.com/u/flawkes)\
**Post date:** [May 11, 2008, 8:45pm UTC](https://www.ruby-forum.com/t/extracting-html/137306/1 "2008-05-11T20:45:04Z")

</div>

Hi!

I have a problem, and I can’t find the solution.

I’m developing an app, (with ruby on rails) and I’m trying to create a  
PDF with some information that I have in my database.

The situation is the next one: In my database I have some fields that  
contains HTML source, that text it was added using FCKeditor. And now  
I’m trying to built a PDF using PDF::Writer, but the problem that I have  
is when I’m trying to insert my text in the PDF appears (as is logical)  
the HTML tags. My question is… Is there any function/plugin that  
allows me to skip that source? Or convert from HTML to Text?

Thank you very much for your time.

Jordi

---

<div class="post-metadata">

**Author:** ![flawkes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f475e1/32.png) [@flawkes](https://www.ruby-forum.com/u/flawkes)\
**Post date:** [May 11, 2008, 8:51pm UTC](https://www.ruby-forum.com/t/extracting-html/137306/2 "2008-05-11T20:51:23Z")

</div>

require ‘hpricot’

doc=Hpricot(“

# Hello World
”)  
doc.inner\_text  
=\> “Hello World”

---

<div class="post-metadata">

**Author:** ![flawkes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f475e1/32.png) [@flawkes](https://www.ruby-forum.com/u/flawkes)\
**Post date:** [May 11, 2008, 9:21pm UTC](https://www.ruby-forum.com/t/extracting-html/137306/3 "2008-05-11T21:21:22Z")

</div>

Dan D. wrote:

> require ‘hpricot’
> 
> doc=Hpricot(“
> 
> # Hello World
> ”)  
> doc.inner\_text  
> =\> “Hello World”

Hi!! Thanks a lot for your answer. I’m a newbie and I still need to  
learn a lot from Ruby and his libraries…

It worked fine!! And now, I will deep a bit in this library, because I  
suppose that with that one, I will be able to save some tags for my PDF  
code, isn’t it? (For example, bold, underline…).

Thanks again for your answer! 🙂
