# PDF::Writer crashes

**URL:** <https://www.ruby-forum.com/t/pdf-writer-crashes/52234>\
**Category:** Rails\
**Created:** [December 5, 2005, 12:05pm UTC](https://www.ruby-forum.com/t/pdf-writer-crashes/52234 "2005-12-05T12:05:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![brutyn\_nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@brutyn\_nick](https://www.ruby-forum.com/u/brutyn_nick)\
**Post date:** [December 5, 2005, 12:05pm UTC](https://www.ruby-forum.com/t/pdf-writer-crashes/52234/1 "2005-12-05T12:05:41Z")

</div>

Hey,

I have put my site online and sometimes the site crashes when I want to  
create a  
pdf file. But when I reboot the server it works again.

It crashes on:  
margin = PDF::Writer.cm2pts(1)  
Or  
pdf = PDF::Writer.prepress(:paper =\> “A4”, :orientation =\> :landscape,  
:left\_margin =\> margin, :right\_margin =\> margin, :top\_margin =\> 0,  
:bottom\_margin =\> 0)

Most of the time it is after the process:

I have a page with a list of users, I display the info from the database  
(tables  
users and clients) like for the clientname =\> Clientname: \<%=  
user.client.name %\>

But in the early stages of the site some users didnt have clients, so I  
got an  
nil error on the page. After that i wanted to create a pdf (total  
different  
section on the site), and get the errors.

Anyone has any problem with this also?? And can help me??

Thanks in advance.  
Nick

---

<div class="post-metadata">

**Author:** ![brutyn\_nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@brutyn\_nick](https://www.ruby-forum.com/u/brutyn_nick)\
**Post date:** [December 5, 2005, 5:57pm UTC](https://www.ruby-forum.com/t/pdf-writer-crashes/52234/2 "2005-12-05T17:57:55Z")

</div>

On 12/5/05, Brutyn N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have put my site online and sometimes the site crashes when I want to create a  
> pdf file. But when I reboot the server it works again.

Can you post the backtrace that you get?

## -austin

Austin Z. \* removed\_email\_address@domain.invalid  
\* Alternate: removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![brutyn\_nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@brutyn\_nick](https://www.ruby-forum.com/u/brutyn_nick)\
**Post date:** [December 5, 2005, 7:24pm UTC](https://www.ruby-forum.com/t/pdf-writer-crashes/52234/3 "2005-12-05T19:24:19Z")

</div>

the wierd thing is it works sometimes sometimes not when i got an error

NoMethodError in Geotags#print\_tag  
undefined method `cm2pts’ for PDF::Writer:Class

#{RAILS\_ROOT}/app/controllers/geotags\_controller.rb:354:in `print_tag' /usr/local/lib/ruby/gems/1.8/gems/actionpack- 1.11.0/lib/action_controller/base.rb:841:in`send’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-  
1.11.0/lib/action\_controller/base.rb:841:in  
`perform_action_without_filters' /usr/local/lib/ruby/gems/1.8/gems/actionpack- 1.11.0/lib/action_controller/filters.rb:332:in`perform\_action\_without\_benchmark’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-  
1.11.0/lib/action\_controller/benchmarking.rb:69:in  
`perform_action_without_rescue' /usr/local/lib/ruby/gems/1.8/gems/actionpack- 1.11.0/lib/action_controller/benchmarking.rb:69:in`measure’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-  
1.11.0/lib/action\_controller/benchmarking.rb:69:in  
`perform_action_without_rescue' /usr/local/lib/ruby/gems/1.8/gems/actionpack- 1.11.0/lib/action_controller/rescue.rb:82:in`perform\_action’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-  
1.11.0/lib/action\_controller/base.rb:365:in `send' /usr/local/lib/ruby/gems/1.8/gems/actionpack- 1.11.0/lib/action_controller/base.rb:365:in`process\_without\_session\_management\_support’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-  
1.11.0/lib/action\_controller/session\_management.rb:116:in `process' /usr/local/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/dispatcher.rb:38:in`dispatch’  
/usr/local/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/fcgi\_handler.rb:141:in  
`process_request' /usr/local/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/fcgi_handler.rb:53:in`process!’  
/usr/local/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/fcgi\_handler.rb:52:in  
`each_cgi' /usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/./fcgi.rb:597:in`each’  
/usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/./fcgi.rb:597:in  
`each_cgi' /usr/local/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/fcgi_handler.rb:52:in`process!’  
/usr/local/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/fcgi\_handler.rb:22:in  
`process!’  
dispatch.fcgi:24

---

<div class="post-metadata">

**Author:** ![brutyn\_nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@brutyn\_nick](https://www.ruby-forum.com/u/brutyn_nick)\
**Post date:** [December 5, 2005, 8:29pm UTC](https://www.ruby-forum.com/t/pdf-writer-crashes/52234/4 "2005-12-05T20:29:37Z")

</div>

On 12/5/05, Brutyn N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> the wierd thing is it works sometimes sometimes not when i got an error

> NoMethodError in Geotags#print\_tag  
> undefined method `cm2pts’ for PDF::Writer:Class

This is quite weird, as it seems that something is not loading  
PDF::Writer (one of the instances, perhaps?) or is undefining parts of  
it.

## -austin

Austin Z. \* removed\_email\_address@domain.invalid  
\* Alternate: removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![brutyn\_nick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@brutyn\_nick](https://www.ruby-forum.com/u/brutyn_nick)\
**Post date:** [December 5, 2005, 8:54pm UTC](https://www.ruby-forum.com/t/pdf-writer-crashes/52234/5 "2005-12-05T20:54:00Z")

</div>

Hi !

2005/12/5, Austin Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> On 12/5/05, Brutyn N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > the wierd thing is it works sometimes sometimes not when i got an error
> 
> > NoMethodError in Geotags#print\_tag  
> > undefined method `cm2pts’ for PDF::Writer:Class

One thing I found is that PDF::Writer and ActiveRecord require  
different versions of Transaction::Simple.

If you’re running on Rails Edge, remove the simple.rb file from  
active\_record/lib/vendor. Then, get Transaction::Simple 1.3.0, unpack  
into vendor, move lib/\* to vendor/, and finally, require  
Transaction::Simple before PDF::Writer and ActiveRecord in  
config/environment.rb

Not a simple workaround, but the best I found. Now, I have everything  
working.

If this is of some help to you, please say so. I’ll write an article  
for my blog about this.

Bye !
