# Generate a PDF from an existing HTML

**URL:** <https://www.ruby-forum.com/t/generate-a-pdf-from-an-existing-html/188910>\
**Category:** Rails\
**Created:** [May 20, 2010, 11:46am UTC](https://www.ruby-forum.com/t/generate-a-pdf-from-an-existing-html/188910 "2010-05-20T11:46:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mffreire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/90ced4/32.png) [@mffreire](https://www.ruby-forum.com/u/mffreire)\
**Post date:** [May 20, 2010, 11:46am UTC](https://www.ruby-forum.com/t/generate-a-pdf-from-an-existing-html/188910/1 "2010-05-20T11:46:41Z")

</div>

Hi everyone,

I am having a lot of troubles with this issue the past few days and I  
would  
like any suggestions to try to solve this.

I want to generate a PDF that has a really big report table from a given  
HTML (I am not using wicked\_pdf plugin because the only thing I want  
from  
the HTML is that table. that being said I preferred to use the prawnto  
plugin).

So what I am trying to do is parse the HTML using Nokogiri. I did  
something  
like this in my reports controller: _@doc = Nokogiri::HTML(open("  
 [http://localhost/reports/1](http://localhost/reports/1)"))_. The problem is that if I do this it  
gives me  
a Timeout error. I can parse almost any webpages that are not inside my  
own  
project.

Well, my questions are: There is a better approach than doing this? Is  
there  
someway that I can use open-uri library to open my own project?

I know that I could use the prawnto to generate a table for the report,  
but  
the thing is that there are a lot of kinds of reports and for each one  
there  
is a kind of calculation. So I am trying to bypass this by parsing the  
HTML.

Thanks in advance.

Regards,  
Marco Antonio

---

<div class="post-metadata">

**Author:** ![mffreire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/90ced4/32.png) [@mffreire](https://www.ruby-forum.com/u/mffreire)\
**Post date:** [May 20, 2010, 1:26pm UTC](https://www.ruby-forum.com/t/generate-a-pdf-from-an-existing-html/188910/2 "2010-05-20T13:26:11Z")

</div>

You may need to give a relative path perhaps.

On 20 May 2010 10:44, Marco Antonio F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> So what I am trying to do is parse the HTML using Nokogiri. I did something  
> is a kind of calculation. So I am trying to bypass this by parsing the HTML.  
> To unsubscribe from this group, send email to  
> removed\_email\_address@domain.invalid[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> .  
> For more options, visit this group at  
> [http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

## –

Nandri(Thanks in Tamil),  
Amala S.
