# PDFWriter and Page Breaks

**URL:** <https://www.ruby-forum.com/t/pdfwriter-and-page-breaks/166326>\
**Category:** Ruby\
**Created:** [April 23, 2009, 10:37pm UTC](https://www.ruby-forum.com/t/pdfwriter-and-page-breaks/166326 "2009-04-23T22:37:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [April 23, 2009, 10:37pm UTC](https://www.ruby-forum.com/t/pdfwriter-and-page-breaks/166326/1 "2009-04-23T22:37:14Z")

</div>

I’m sure this is something that someone here has done. More probably,  
I’m missing the obvious.

In order to produce a report, I need to know when the text I’m printing  
(or about to print - I’m not picky) is going to do a page overflow so  
that I can put the neadings on the new page. I’ve been going through the  
API, and I don’t see how to check this.

Can anyone offer some insights into this?

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [April 24, 2009, 9:30am UTC](https://www.ruby-forum.com/t/pdfwriter-and-page-breaks/166326/2 "2009-04-24T09:30:28Z")

</div>

Michael S. wrote:

> I’m sure this is something that someone here has done. More probably,  
> I’m missing the obvious.
> 
> In order to produce a report, I need to know when the text I’m printing  
> (or about to print - I’m not picky) is going to do a page overflow so  
> that I can put the neadings on the new page. I’ve been going through the  
> API, and I don’t see how to check this.
> 
> Can anyone offer some insights into this?

It doesn’t. You have to do it by yourself. If it is out of page borders  
it will be printed out of borders.

by  
TheR

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [April 24, 2009, 1:33pm UTC](https://www.ruby-forum.com/t/pdfwriter-and-page-breaks/166326/3 "2009-04-24T13:33:02Z")

</div>

> It doesn’t. You have to do it by yourself. If it is out of page borders  
> it will be printed out of borders.

That smart text insertion wraps both lines and pages is documented.  
Unless the documentation is wrong, it won’t be out of borders when using  
the text method. The question is how to measure the height of the next  
item to print so that I can do a “manual” new page and insert headings.

Even if smart text insertion didn’t auto-wrap and “You have to do it by  
yourself”, the question remains the same. “How do I measure the vertical  
height of the text I’m about to add to the document?”

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [April 28, 2009, 9:28am UTC](https://www.ruby-forum.com/t/pdfwriter-and-page-breaks/166326/4 "2009-04-28T09:28:15Z")

</div>

Why don’t you try Prawn?

[http://prawn.majesticseacreature.com/](http://prawn.majesticseacreature.com/)

---

<div class="post-metadata">

**Author:** ![wickie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/ba9def/32.png) [@wickie](https://www.ruby-forum.com/u/wickie)\
**Post date:** [April 30, 2009, 6:55am UTC](https://www.ruby-forum.com/t/pdfwriter-and-page-breaks/166326/5 "2009-04-30T06:55:10Z")

</div>

On Tue, Apr 28, 2009 at 3:27 AM, jonty [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Why don’t you try Prawn?
> 
> [http://prawn.majesticseacreature.com/](http://prawn.majesticseacreature.com/)

A good idea generally, but keep in mind that the OP will need to do  
manual calculations whether he uses PDF::Writer or Prawn. They just  
might be slightly more pleasant to do in Prawn. We do have very rough  
header support, but anything interesting needs to be done manually  
(for now). Hopefully we’ll improve in that area soon.

-greg
